You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2020/06/19 18:11:52 UTC

[maven-resolver] branch MRESOLVER-124 created (now b38122a)

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a change to branch MRESOLVER-124
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git.


      at b38122a  [MRESOLVER-124] Remove deprecated API usages

This branch includes the following new commits:

     new b38122a  [MRESOLVER-124] Remove deprecated API usages

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-resolver] 01/01: [MRESOLVER-124] Remove deprecated API usages

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MRESOLVER-124
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git

commit b38122a341578532a85d2de1312d334b48fb0dec
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Thu Jun 18 17:53:34 2020 +0200

    [MRESOLVER-124] Remove deprecated API usages
---
 .../aether/transport/http/AuthSchemePool.java      |  4 +-
 .../eclipse/aether/transport/http/GlobalState.java | 54 +++++++++----
 .../aether/transport/http/HttpTransporter.java     | 89 +++++++++++++---------
 .../eclipse/aether/transport/http/LocalState.java  |  6 +-
 .../aether/transport/http/SharingHttpContext.java  | 10 +--
 .../aether/transport/http/SslSocketFactory.java    | 87 ---------------------
 .../http/X509HostnameVerifierAdapter.java          | 79 -------------------
 7 files changed, 102 insertions(+), 227 deletions(-)

diff --git a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/AuthSchemePool.java b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/AuthSchemePool.java
index 1957688..384227f 100644
--- a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/AuthSchemePool.java
+++ b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/AuthSchemePool.java
@@ -22,7 +22,7 @@ package org.eclipse.aether.transport.http;
 import java.util.LinkedList;
 
 import org.apache.http.auth.AuthScheme;
-import org.apache.http.client.params.AuthPolicy;
+import org.apache.http.client.config.AuthSchemes;
 import org.apache.http.impl.auth.BasicScheme;
 
 /**
@@ -47,7 +47,7 @@ final class AuthSchemePool
         {
             authScheme = authSchemes.removeLast();
         }
-        else if ( AuthPolicy.BASIC.equalsIgnoreCase( schemeName ) )
+        else if ( AuthSchemes.BASIC.equalsIgnoreCase( schemeName ) )
         {
             authScheme = new BasicScheme();
         }
diff --git a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/GlobalState.java b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/GlobalState.java
index 29ef555..c00973d 100644
--- a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/GlobalState.java
+++ b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/GlobalState.java
@@ -27,15 +27,21 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.http.HttpHost;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.scheme.PlainSocketFactory;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.impl.conn.PoolingClientConnectionManager;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.HttpClientConnectionManager;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.eclipse.aether.RepositoryCache;
 import org.eclipse.aether.RepositorySystemSession;
 import org.eclipse.aether.util.ConfigUtils;
 
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLSocketFactory;
+
+import static org.apache.http.conn.ssl.SSLConnectionSocketFactory.getDefaultHostnameVerifier;
+
 /**
  * Container for HTTP-related state that can be shared across incarnations of the transporter to optimize the
  * communication with servers.
@@ -88,7 +94,7 @@ final class GlobalState
 
     private static final String CONFIG_PROP_CACHE_STATE = "aether.connector.http.cacheState";
 
-    private final ConcurrentMap<SslConfig, ClientConnectionManager> connectionManagers;
+    private final ConcurrentMap<SslConfig, HttpClientConnectionManager> connectionManagers;
 
     private final ConcurrentMap<CompoundKey, Object> userTokens;
 
@@ -141,21 +147,21 @@ final class GlobalState
 
     public void close()
     {
-        for ( Iterator<Map.Entry<SslConfig, ClientConnectionManager>> it = connectionManagers.entrySet().iterator();
+        for ( Iterator<Map.Entry<SslConfig, HttpClientConnectionManager>> it = connectionManagers.entrySet().iterator();
               it.hasNext(); )
         {
-            ClientConnectionManager connMgr = it.next().getValue();
+            HttpClientConnectionManager connMgr = it.next().getValue();
             it.remove();
             connMgr.shutdown();
         }
     }
 
-    public ClientConnectionManager getConnectionManager( SslConfig config )
+    public HttpClientConnectionManager getConnectionManager( SslConfig config )
     {
-        ClientConnectionManager manager = connectionManagers.get( config );
+        HttpClientConnectionManager manager = connectionManagers.get( config );
         if ( manager == null )
         {
-            ClientConnectionManager connMgr = newConnectionManager( config );
+            HttpClientConnectionManager connMgr = newConnectionManager( config );
             manager = connectionManagers.putIfAbsent( config, connMgr );
             if ( manager != null )
             {
@@ -170,13 +176,29 @@ final class GlobalState
     }
 
     @SuppressWarnings( "checkstyle:magicnumber" )
-    public static ClientConnectionManager newConnectionManager( SslConfig sslConfig )
+    public static HttpClientConnectionManager newConnectionManager( SslConfig sslConfig )
     {
-        SchemeRegistry schemeReg = new SchemeRegistry();
-        schemeReg.register( new Scheme( "http", 80, new PlainSocketFactory() ) );
-        schemeReg.register( new Scheme( "https", 443, new SslSocketFactory( sslConfig ) ) );
+        RegistryBuilder<ConnectionSocketFactory> registryBuilder = RegistryBuilder.<ConnectionSocketFactory>create()
+                .register( "http", PlainConnectionSocketFactory.getSocketFactory() );
+
+        if ( sslConfig == null )
+        {
+            registryBuilder.register( "https", SSLConnectionSocketFactory.getSocketFactory() );
+            // check also SSLConnectionSocketFactory.getSystemSocketFactory()
+        }
+        else
+        {
+            SSLSocketFactory sslSocketFactory = ( sslConfig.context != null )
+                    ? sslConfig.context.getSocketFactory() : (SSLSocketFactory) SSLSocketFactory.getDefault();
+
+            HostnameVerifier hostnameVerifier = ( sslConfig.verifier != null )
+                    ? sslConfig.verifier : getDefaultHostnameVerifier();
+
+            registryBuilder.register( "https", new SSLConnectionSocketFactory(
+                    sslSocketFactory, sslConfig.protocols, sslConfig.cipherSuites, hostnameVerifier ) );
+        }
 
-        PoolingClientConnectionManager connMgr = new PoolingClientConnectionManager( schemeReg );
+        PoolingHttpClientConnectionManager connMgr = new PoolingHttpClientConnectionManager( registryBuilder.build() );
         connMgr.setMaxTotal( 100 );
         connMgr.setDefaultMaxPerRoute( 50 );
         return connMgr;
diff --git a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java
index 15fa36a..9491d94 100644
--- a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java
+++ b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java
@@ -25,6 +25,7 @@ import java.io.InterruptedIOException;
 import java.io.OutputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.nio.charset.Charset;
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
@@ -39,11 +40,13 @@ import org.apache.http.HttpHeaders;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
+import org.apache.http.auth.AuthSchemeProvider;
 import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.params.AuthParams;
 import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.HttpResponseException;
+import org.apache.http.client.config.AuthSchemes;
+import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpHead;
 import org.apache.http.client.methods.HttpOptions;
@@ -51,14 +54,17 @@ import org.apache.http.client.methods.HttpPut;
 import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.http.client.utils.DateUtils;
 import org.apache.http.client.utils.URIUtils;
-import org.apache.http.conn.params.ConnRouteParams;
+import org.apache.http.config.Lookup;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.config.SocketConfig;
 import org.apache.http.entity.AbstractHttpEntity;
 import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.impl.client.DecompressingHttpClient;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.impl.auth.BasicSchemeFactory;
+import org.apache.http.impl.auth.DigestSchemeFactory;
+import org.apache.http.impl.auth.KerberosSchemeFactory;
+import org.apache.http.impl.auth.NTLMSchemeFactory;
+import org.apache.http.impl.auth.SPNegoSchemeFactory;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
 import org.eclipse.aether.ConfigurationProperties;
 import org.eclipse.aether.RepositorySystemSession;
@@ -140,13 +146,47 @@ final class HttpTransporter
             ConfigUtils.getMap( session, Collections.emptyMap(), ConfigurationProperties.HTTP_HEADERS + "."
                 + repository.getId(), ConfigurationProperties.HTTP_HEADERS );
 
-        DefaultHttpClient client = new DefaultHttpClient( state.getConnectionManager() );
-
-        configureClient( client.getParams(), session, repository, proxy );
-
-        client.setCredentialsProvider( toCredentialsProvider( server, repoAuthContext, proxy, proxyAuthContext ) );
-
-        this.client = new DecompressingHttpClient( client );
+        String credentialCharset = ConfigUtils.getString( session,
+                ConfigurationProperties.DEFAULT_HTTP_CREDENTIAL_ENCODING,
+                ConfigurationProperties.HTTP_CREDENTIAL_ENCODING + "." + repository.getId(),
+                ConfigurationProperties.HTTP_CREDENTIAL_ENCODING );
+
+        Lookup<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
+                .register( AuthSchemes.BASIC, new BasicSchemeFactory( Charset.forName( credentialCharset ) ) )
+                .register( AuthSchemes.DIGEST, new DigestSchemeFactory( Charset.forName( credentialCharset ) ) )
+                .register( AuthSchemes.NTLM, new NTLMSchemeFactory() )
+                .register( AuthSchemes.SPNEGO, new SPNegoSchemeFactory() )
+                .register( AuthSchemes.KERBEROS, new KerberosSchemeFactory() )
+                .build();
+
+        SocketConfig socketConfig = SocketConfig.custom()
+                .setSoTimeout( ConfigUtils.getInteger( session, ConfigurationProperties.DEFAULT_REQUEST_TIMEOUT,
+                        ConfigurationProperties.REQUEST_TIMEOUT + "." + repository.getId(),
+                        ConfigurationProperties.REQUEST_TIMEOUT ) )
+                .build();
+
+        int timeout =
+                ConfigUtils.getInteger( session, ConfigurationProperties.DEFAULT_CONNECT_TIMEOUT,
+                        ConfigurationProperties.CONNECT_TIMEOUT + "." + repository.getId(),
+                        ConfigurationProperties.CONNECT_TIMEOUT );
+
+        RequestConfig requestConfig = RequestConfig.custom()
+                .setConnectTimeout( timeout )
+                .setConnectionRequestTimeout( timeout )
+                .setSocketTimeout( socketConfig.getSoTimeout() ).build();
+
+        HttpClientBuilder clientBuilder = HttpClientBuilder.create()
+                .setUserAgent( ConfigUtils.getString( session, ConfigurationProperties.DEFAULT_USER_AGENT,
+                        ConfigurationProperties.USER_AGENT ) )
+                .setDefaultSocketConfig( socketConfig )
+                .setDefaultRequestConfig( requestConfig )
+                .setDefaultAuthSchemeRegistry( authSchemeRegistry )
+                .setConnectionManager( state.getConnectionManager() )
+                .setDefaultCredentialsProvider(
+                        toCredentialsProvider( server, repoAuthContext, proxy, proxyAuthContext ) )
+                .setProxy( proxy );
+
+        this.client = clientBuilder.build();
     }
 
     private static HttpHost toHost( Proxy proxy )
@@ -159,27 +199,6 @@ final class HttpTransporter
         return host;
     }
 
-    private static void configureClient( HttpParams params, RepositorySystemSession session,
-                                         RemoteRepository repository, HttpHost proxy )
-    {
-        AuthParams.setCredentialCharset( params, ConfigUtils.getString( session,
-                ConfigurationProperties.DEFAULT_HTTP_CREDENTIAL_ENCODING,
-                ConfigurationProperties.HTTP_CREDENTIAL_ENCODING + "." + repository.getId(),
-                ConfigurationProperties.HTTP_CREDENTIAL_ENCODING ) );
-        ConnRouteParams.setDefaultProxy( params, proxy );
-        HttpConnectionParams.setConnectionTimeout( params, ConfigUtils.getInteger( session,
-                ConfigurationProperties.DEFAULT_CONNECT_TIMEOUT,
-                ConfigurationProperties.CONNECT_TIMEOUT + "." + repository.getId(),
-                ConfigurationProperties.CONNECT_TIMEOUT ) );
-        HttpConnectionParams.setSoTimeout( params, ConfigUtils.getInteger( session,
-                ConfigurationProperties.DEFAULT_REQUEST_TIMEOUT,
-                ConfigurationProperties.REQUEST_TIMEOUT + "." + repository.getId(),
-                ConfigurationProperties.REQUEST_TIMEOUT ) );
-        HttpProtocolParams.setUserAgent( params, ConfigUtils.getString( session,
-                ConfigurationProperties.DEFAULT_USER_AGENT,
-                ConfigurationProperties.USER_AGENT ) );
-    }
-
     private static CredentialsProvider toCredentialsProvider( HttpHost server, AuthenticationContext serverAuthCtx,
                                                               HttpHost proxy, AuthenticationContext proxyAuthCtx )
     {
diff --git a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/LocalState.java b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/LocalState.java
index ebc5bd5..b8a791f 100644
--- a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/LocalState.java
+++ b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/LocalState.java
@@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentMap;
 
 import org.apache.http.HttpHost;
 import org.apache.http.auth.AuthScheme;
-import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.HttpClientConnectionManager;
 import org.eclipse.aether.RepositorySystemSession;
 import org.eclipse.aether.repository.RemoteRepository;
 import org.eclipse.aether.transport.http.GlobalState.CompoundKey;
@@ -40,7 +40,7 @@ final class LocalState
 
     private final GlobalState global;
 
-    private final ClientConnectionManager connMgr;
+    private final HttpClientConnectionManager connMgr;
 
     private final CompoundKey userTokenKey;
 
@@ -74,7 +74,7 @@ final class LocalState
         }
     }
 
-    public ClientConnectionManager getConnectionManager()
+    public HttpClientConnectionManager getConnectionManager()
     {
         return connMgr;
     }
diff --git a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/SharingHttpContext.java b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/SharingHttpContext.java
index 33b8b2f..e47b3d1 100644
--- a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/SharingHttpContext.java
+++ b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/SharingHttpContext.java
@@ -21,7 +21,7 @@ package org.eclipse.aether.transport.http;
 
 import java.io.Closeable;
 
-import org.apache.http.client.protocol.ClientContext;
+import org.apache.http.client.protocol.HttpClientContext;
 import org.apache.http.protocol.BasicHttpContext;
 
 /**
@@ -43,13 +43,13 @@ final class SharingHttpContext
     {
         this.state = state;
         authCache = new SharingAuthCache( state );
-        super.setAttribute( ClientContext.AUTH_CACHE, authCache );
+        super.setAttribute( HttpClientContext.AUTH_CACHE, authCache );
     }
 
     @Override
     public Object getAttribute( String id )
     {
-        if ( ClientContext.USER_TOKEN.equals( id ) )
+        if ( HttpClientContext.USER_TOKEN.equals( id ) )
         {
             return state.getUserToken();
         }
@@ -59,7 +59,7 @@ final class SharingHttpContext
     @Override
     public void setAttribute( String id, Object obj )
     {
-        if ( ClientContext.USER_TOKEN.equals( id ) )
+        if ( HttpClientContext.USER_TOKEN.equals( id ) )
         {
             state.setUserToken( obj );
         }
@@ -72,7 +72,7 @@ final class SharingHttpContext
     @Override
     public Object removeAttribute( String id )
     {
-        if ( ClientContext.USER_TOKEN.equals( id ) )
+        if ( HttpClientContext.USER_TOKEN.equals( id ) )
         {
             state.setUserToken( null );
             return null;
diff --git a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/SslSocketFactory.java b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/SslSocketFactory.java
deleted file mode 100644
index 4426da4..0000000
--- a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/SslSocketFactory.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package org.eclipse.aether.transport.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *  http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocket;
-import javax.net.ssl.SSLSocketFactory;
-
-import org.apache.http.conn.ssl.X509HostnameVerifier;
-
-/**
- * Specialized SSL socket factory to more closely resemble the JRE's HttpsClient and respect well-known SSL-related
- * configuration properties.
- * 
- * @see <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#Customization">JSSE
- *      Reference Guide, Customization</a>
- */
-final class SslSocketFactory
-    extends org.apache.http.conn.ssl.SSLSocketFactory
-{
-
-    private final String[] cipherSuites;
-
-    private final String[] protocols;
-
-    SslSocketFactory( SslConfig config )
-    {
-        this( getSocketFactory( config.context ), getHostnameVerifier( config.verifier ), config.cipherSuites,
-              config.protocols );
-    }
-
-    private static SSLSocketFactory getSocketFactory( SSLContext context )
-    {
-        return ( context != null ) ? context.getSocketFactory() : (SSLSocketFactory) SSLSocketFactory.getDefault();
-    }
-
-    private static X509HostnameVerifier getHostnameVerifier( HostnameVerifier verifier )
-    {
-        return ( verifier != null ) ? X509HostnameVerifierAdapter.adapt( verifier )
-                        : org.apache.http.conn.ssl.SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER;
-    }
-
-    private SslSocketFactory( SSLSocketFactory socketfactory, X509HostnameVerifier hostnameVerifier,
-                              String[] cipherSuites, String[] protocols )
-    {
-        super( socketfactory, hostnameVerifier );
-
-        this.cipherSuites = cipherSuites;
-        this.protocols = protocols;
-    }
-
-    @Override
-    protected void prepareSocket( SSLSocket socket )
-        throws IOException
-    {
-        super.prepareSocket( socket );
-        if ( cipherSuites != null )
-        {
-            socket.setEnabledCipherSuites( cipherSuites );
-        }
-        if ( protocols != null )
-        {
-            socket.setEnabledProtocols( protocols );
-        }
-    }
-
-}
diff --git a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/X509HostnameVerifierAdapter.java b/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/X509HostnameVerifierAdapter.java
deleted file mode 100644
index ac0825b..0000000
--- a/maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/X509HostnameVerifierAdapter.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.eclipse.aether.transport.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *  http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-import java.security.cert.X509Certificate;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.SSLSocket;
-
-import org.apache.http.conn.ssl.X509HostnameVerifier;
-
-/**
- * Makes a standard hostname verifier compatible with Apache HttpClient's API.
- */
-final class X509HostnameVerifierAdapter
-    implements X509HostnameVerifier
-{
-
-    private final HostnameVerifier verifier;
-
-    public static X509HostnameVerifier adapt( HostnameVerifier verifier )
-    {
-        if ( verifier instanceof X509HostnameVerifier )
-        {
-            return (X509HostnameVerifier) verifier;
-        }
-        return new X509HostnameVerifierAdapter( verifier );
-    }
-
-    private X509HostnameVerifierAdapter( HostnameVerifier verifier )
-    {
-        this.verifier = verifier;
-    }
-
-    public boolean verify( String hostname, SSLSession session )
-    {
-        return verifier.verify( hostname, session );
-    }
-
-    public void verify( String host, SSLSocket socket )
-        throws IOException
-    {
-        if ( !verify( host, socket.getSession() ) )
-        {
-            throw new SSLException( "<" + host + "> does not pass hostname verification" );
-        }
-    }
-
-    public void verify( String host, X509Certificate cert )
-    {
-        throw new UnsupportedOperationException();
-    }
-
-    public void verify( String host, String[] cns, String[] subjectAlts )
-    {
-        throw new UnsupportedOperationException();
-    }
-
-}