FileDocCategorySizeDatePackage
HttpUrlConnector.javaAPI DocGlassfish v2 API6297Fri May 04 22:36:24 BST 2007com.sun.enterprise.admin.jmx.remote.http

HttpUrlConnector

public class HttpUrlConnector extends com.sun.enterprise.admin.jmx.remote.UrlConnector
A Concrete implementation of UrlConnector that uses {@link java.net.URLConnection.openConnection} and HttpUrlConnection to communicate with the server.
author
Kedar Mhaswade
since
S1AS8.0
version
1.0

Fields Summary
private HostnameVerifier
hv
private X509TrustManager[]
tms
private X509KeyManager[]
kms
private SSLSocketFactory
ssf
private static final Logger
logger
Constructors Summary
public HttpUrlConnector(JMXServiceURL serviceUrl, Map environment)
Creates a new instance of HttpUrlConnector

/*, 
        DefaultConfiguration.LOGGER_RESOURCE_BUNDLE_NAME );*/

           
    
         
        super(serviceUrl, environment);
        hv = (HostnameVerifier)environment.get(
                DefaultConfiguration.HOSTNAME_VERIFIER_PROPERTY_NAME);
        if (hv == null) 
            hv = new SunOneBasicHostNameVerifier(serviceUrl.getHost());

         //fetching any custom SSLSocketFactory passed through environment
        ssf = (SSLSocketFactory)environment.get(
                DefaultConfiguration.SSL_SOCKET_FACTORY);
        
        //No custom SSLScoketFactory passed. So now fetch the X509 based managers
        //to get the SSLSocketFactory configured using SSLContext
        if (ssf == null) {
            //fetching any trustmanagers passed through environment - default is 
            //SunOneBasicX509TrustManager
            Object tmgr = environment.get(DefaultConfiguration.TRUST_MANAGER_PROPERTY_NAME);
            if (tmgr instanceof X509TrustManager[]) 
                tms = (X509TrustManager[])tmgr;
            else if (tmgr instanceof X509TrustManager)
                tms = new X509TrustManager[] { (X509TrustManager)tmgr };
            else if (tmgr == null)
                tms = new X509TrustManager[] { new SunOneBasicX509TrustManager(
                                                    serviceUrl, environment)};
            

            //fetching any keymanagers passed through environment - no defaults
            Object kmgr = environment.get(DefaultConfiguration.KEY_MANAGER_PROPERTY_NAME);
            if (kmgr instanceof X509KeyManager[]) 
                kms = (X509KeyManager[])kmgr;
            else if (kmgr instanceof X509KeyManager) 
                kms = new X509KeyManager[] { (X509KeyManager)kmgr };
        }

        initialize();
    
Methods Summary
private voidinitialize()

        if (ssf == null) {
            SSLContext sslContext = null;
            try {
                sslContext = SSLContext.getInstance("SSLv3");
                sslContext.init(kms, tms, new SecureRandom());
            } catch(GeneralSecurityException e) {
                throw new RuntimeException(e);
            }

            if( sslContext != null ) 
                HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
            
        } else HttpsURLConnection.setDefaultSSLSocketFactory(ssf);
        
        HttpsURLConnection.setDefaultHostnameVerifier( hv );
    
protected voidvalidateEnvironment()

        super.validateEnvironment();
    
protected voidvalidateJmxServiceUrl()

        //additional validation