Do not use ClientConfig 52/101652/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 1 Jul 2022 15:02:08 +0000 (17:02 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 1 Jul 2022 17:16:52 +0000 (17:16 +0000)
We are not doing anything with the configuration, just take a plain
client instead. This removes a dependency on the actual implementation.

Change-Id: I398b1bf40237788c52d28c01ac5c4117ae40e0ec
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit a4b7bcf22c7f39884d1398c2017e88ea9dbacfc9)

aaa-shiro/impl/pom.xml
aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/realm/MoonRealm.java
aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/realm/util/http/SimpleHttpClient.java

index d26b3794b260e36bb22a7331b7c821f263215f31..cbfbed9af32682e2d113a067b0502c4a5e8b358e 100644 (file)
@@ -41,12 +41,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
             <artifactId>aaa-idm-store-h2</artifactId>
         </dependency>
 
-        <!-- jersey client for moon authN -->
-        <dependency>
-            <groupId>org.glassfish.jersey.core</groupId>
-            <artifactId>jersey-client</artifactId>
-            <scope>provided</scope>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.aaa</groupId>
             <artifactId>aaa-cert</artifactId>
@@ -82,6 +76,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.service.http</artifactId>
         </dependency>
+        <dependency>
+            <groupId>javax.annotation</groupId>
+            <artifactId>javax.annotation-api</artifactId>
+            <optional>true</optional>
+        </dependency>
         <dependency>
             <groupId>com.guicedee.services</groupId>
             <artifactId>javax.inject</artifactId>
index f531354aad45da9a09800f000e6ae51602cec161..646416fbb89141305c15bdce2b80ed20652911ac 100644 (file)
@@ -27,7 +27,6 @@ import org.apache.shiro.authc.UsernamePasswordToken;
 import org.apache.shiro.authz.AuthorizationInfo;
 import org.apache.shiro.realm.AuthorizingRealm;
 import org.apache.shiro.subject.PrincipalCollection;
-import org.glassfish.jersey.client.ClientConfig;
 import org.opendaylight.aaa.shiro.moon.MoonPrincipal;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -82,8 +81,7 @@ public class MoonRealm extends AuthorizingRealm {
     }
 
     public MoonPrincipal moonAuthenticate(final String username, final String password, final String domain) {
-        final ClientConfig config = new ClientConfig();
-        final Client client = ClientBuilder.newClient(config);
+        final Client client = ClientBuilder.newClient();
 
         final String hostFromShiro = moonServerURL != null ? moonServerURL.getHost() : null;
         final String server;
index 1e267e6267821b6da4b091dbec35f5d2f53192e5..beed0b015693e4249dc1640ad9a131537f666474 100644 (file)
@@ -13,7 +13,6 @@ import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.SSLContext;
 import javax.ws.rs.client.Client;
 import javax.ws.rs.client.ClientBuilder;
-import org.glassfish.jersey.client.ClientConfig;
 
 /**
  * An utility that represents an HTTP client that allows to make
@@ -99,11 +98,13 @@ public class SimpleHttpClient {
          * @return the client.
          */
         public SimpleHttpClient build() {
-            final ClientConfig clientConfig = new ClientConfig();
-            providers.forEach(clientConfig::register);
-            Client client = ClientBuilder.newBuilder().sslContext(sslContext).hostnameVerifier(hostnameVerifier)
-                    .withConfig(clientConfig).build();
-            return new SimpleHttpClient(client);
+            final ClientBuilder clientBuilder = ClientBuilder.newBuilder()
+                .sslContext(sslContext)
+                .hostnameVerifier(hostnameVerifier);
+
+            providers.forEach(clientBuilder::register);
+
+            return new SimpleHttpClient(clientBuilder.build());
         }
 
     }