FileDocCategorySizeDatePackage
AdminSslServerSocketFactory.javaAPI DocGlassfish v2 API7075Fri May 04 22:33:54 BST 2007com.sun.enterprise.admin.server.core.jmx.ssl

AdminSslServerSocketFactory

public class AdminSslServerSocketFactory extends Object implements RMIServerSocketFactory
This is the custom RMI server socket factory that uses the same keystore, truststore, certificate databases all the time. This factory will be used to create the server side sockets when rmi connector server is configured to use SSL. Please read the package.html. Note that this code depends upon the pluggability of the proper security infrastructure.
author
Kedar.Mhaswade@sun.com
since
Sun Java System Application Server 8.1

Fields Summary
private final com.sun.enterprise.config.serverbeans.Ssl
sslc
private static final String
DEFAULT_ADDRESS
private String
address
Constructors Summary
public AdminSslServerSocketFactory(com.sun.enterprise.config.serverbeans.Ssl sslc, String address)

    
          
        if (sslc == null)
            throw new IllegalArgumentException("Internal: null ssl configuration");
        this.sslc = sslc;
        this.address = address;
    
Methods Summary
public java.net.ServerSocketcreateServerSocket(int port)
Implementation of the only method in {@link RMIServerSocketFactory}. This method is called for creating the server socket.

return
instance of ServerSocket

        try {
            /* My belief is that one of the bootstrap classes for
            * initializing the SSL Context and the proper (pluggable)
            * Key and Trust Managers are in place. We just need to leverage that.
            */
            // first get the SSLContext - returned as a new one - http://java.sun.com/j2se/1.4.2/docs/guide/security/jsse/JSSERefGuide.html#AppA
            final SSLContext ctx = SSLContext.getInstance("TLSv1");
            // get the key and trust managers
            final KeyManager[] kms = SSLUtils.getKeyManagers();
            J2EEKeyManager[] jkms = new J2EEKeyManager[kms.length];
            for (int i = 0; i < kms.length; i++) {
                jkms[i] = new J2EEKeyManager((X509KeyManager)kms[i], sslc.getCertNickname());
            }
            final TrustManager[] tms = null; //not needed really untill we support client auth
            final SecureRandom sr = null; // need to handle better?
            // now initialize the SSLContext gotten above and return
            ctx.init(jkms, tms, sr);
            final SSLServerSocketFactory sf = ctx.getServerSocketFactory();
            
            InetAddress bindAddress = null;
            ServerSocket sss = null;
            if (address.equals(DEFAULT_ADDRESS))             
                sss = sf.createServerSocket(port);
            else {            
                bindAddress = InetAddress.getByName(address);             
                sss = sf.createServerSocket(port, 0, bindAddress);        
            }
            debug(sss);
            return ( sss );
        }
        catch (final Exception e) {
            throw new IOException(e.getMessage());
        }
    
private voiddebug(java.net.ServerSocket sss)

        // prints the debug information - suppress after beta
        final String prefix = "RMI/TLS Server Debug Message: " ;
        final boolean DEBUG = Boolean.getBoolean("Debug");
        if (sss != null) {
            if (DEBUG) {
                System.out.println(prefix + "ServerSocket local port = " + sss.getLocalPort());
                System.out.println(prefix + "ServerSocket host address = " + sss.getInetAddress().getHostAddress());
                System.out.println(prefix + "ServerSocket bound status = " + sss.isBound());
            }
        }
        else {
            System.out.println(prefix + " Catastrophe: no server socket");
        }