FileDocCategorySizeDatePackage
AdminRMISSLClientSocketFactory.javaAPI DocGlassfish v2 API7059Fri May 04 22:30:32 BST 2007com.sun.appserv.management.client

AdminRMISSLClientSocketFactory

public class AdminRMISSLClientSocketFactory extends Object implements Serializable, RMIClientSocketFactory
Not for public use

RMISSLClientSocketFactory which allows the configuration of security parameters by an RMI client; by default is not possible to configure these parameters. This is the "stub" class that gets downloaded to the client.

Looks for RMISSLClientSocketFactoryEnv, and if found, uses it to get configuration.

Fields Summary
static final long
serialVersionUID
private transient SSLSocketFactory
mFactory
private transient MyEnvImpl
mEnvImpl
Constructors Summary
public AdminRMISSLClientSocketFactory()

	
		
	
	
		mEnvImpl	= new MyEnvImpl();
	
Methods Summary
public synchronized java.net.SocketcreateSocket(java.lang.String host, int port)

    	final String	target	= host + ":" + port;
    	
		trace( "createSocket: " + target );
    	
    	final AdminRMISSLClientSocketFactoryEnv	env	= getEnv();
    	
        if ( mFactory == null)
        {
        	mFactory = createSocketFactory( env );
			trace( "createSocket: created socket factory" );
        }
        
		//trace( "creating socket: " + target );
        final SSLSocket sslSocket	= (SSLSocket)mFactory.createSocket( host, port );
        
		final HandshakeCompletedListener	listener	= env.getHandshakeCompletedListener( );
		if ( listener != null )
		{
			trace( "createSocket: added HandshakeCompletedListener: " + listener );
			sslSocket.addHandshakeCompletedListener( listener );
		}
		
    	
		trace( "created socket: " + target );
        return( sslSocket );
    
private final javax.net.ssl.SSLSocketFactorycreateSocketFactory(AdminRMISSLClientSocketFactoryEnv env)

		SSLSocketFactory	factory	= null;
		
        try
        {
        	final TrustManager[]	trustManagers	= env.getTrustManagers( );
            
            final SSLContext sslContext = SSLContext.getInstance( "TLSv1" );
            sslContext.init( null, trustManagers, null );
            factory = sslContext.getSocketFactory();
        }
        catch (Exception e)
        {
        	e.printStackTrace();
            throw (IOException) new IOException().initCause(e);
        }
        
        return( factory );
	
private synchronized AdminRMISSLClientSocketFactoryEnvgetEnv()
Note that the environment is useless if it gets downloaded, since it would never be possible for a client to configure it! However, that is OK as default behavior will be used.

		return( AdminRMISSLClientSocketFactoryEnvImpl.getInstance() );
	
private static javax.net.ssl.TrustManager[]getTrustAny()

		final TrustManager[]	trustManagers	= new TrustManager[ 1 ];
		trustManagers[ 0 ]	= TrustAnyTrustManager.getInstance();
		return( trustManagers );
	
private static char[]toCharArray(java.lang.String s)

		return( s == null ? null : s.toCharArray() );
	
private final voidtrace(java.lang.Object o)

		if ( getEnv().getTrace() )
		{
			final String	name	= this.getClass().getName();
			Logger.getLogger( name ).info( toString() + ": " + o.toString() );
		}