This class is an SSL-enabled subclass of java.net.ServerSocket that is used to listen for and accept connections from clients and to create SSLSocket objects for communicating with those clients. Create an SSLServerSocket and bind it to a local port by calling one of the inherited getServerSocket( ) methods of an SSLServerSocketFactory . Once a SSLServerSocket is created, use it as you would a regular ServerSocket : call the inherited accept( ) method to wait for and accept a connection from a client, returning a Socket object. With SSLServerSocket , the Socket returned by accept( ) can always be cast to an instance of SSLSocket . SSLServerSocket defines methods for setting the enabled protocols and cipher suites, and for querying the full set of supported protocols and suites. See SSLSocket , which has methods with the same names , for details. If your server desires or requires authentication by its clients, call setWantClientAuth( ) or setNeedClientAuth( ) . These methods cause the SSLSocket objects returned by accept( ) to be configured to request or require client authentication. In typical SSL networking scenarios, the client requires the server to provide authentication information. When you create an SSLServerSocket using the default SSLServerSocketFactory , the authentication information required is an X.509 public key certificate and the corresponding private key. The default SSLServerSocketFactory uses an X509KeyManager to obtain this information. The default X509KeyManager attempts to read this information from the java.security.KeyStore file specified by the system property javax.net.ssl.keyStore . It uses the value of the the javax.net.ssl.keyStorePassword as the keystore password, and uses the value of the javax.net.ssl.keyStoreType system property to specify the keystore type. The key store should only contain valid keys and certificate chains that identify the server; the X509KeyManager automatically chooses a key and certificat chain that are appropriate for the client. Figure 18-12. javax.net.ssl.SSLServerSocketpublic abstract class SSLServerSocket extends java.net.ServerSocket { // Protected Constructors protected SSLServerSocket ( ) throws java.io.IOException; protected SSLServerSocket (int port ) throws java.io.IOException; protected SSLServerSocket (int port , int backlog ) throws java.io.IOException; protected SSLServerSocket (int port , int backlog , java.net.InetAddress address ) throws java.io.IOException; // Public Instance Methods public abstract String[ ] getEnabledCipherSuites ( ); public abstract String[ ] getEnabledProtocols ( ); public abstract boolean getEnableSessionCreation ( ); public abstract boolean getNeedClientAuth ( ); public abstract String[ ] getSupportedCipherSuites ( ); public abstract String[ ] getSupportedProtocols ( ); public abstract boolean getUseClientMode ( ); public abstract boolean getWantClientAuth ( ); public abstract void setEnabledCipherSuites (String[ ] suites ); public abstract void setEnabledProtocols (String[ ] protocols ); public abstract void setEnableSessionCreation (boolean flag ); public abstract void setNeedClientAuth (boolean need ); public abstract void setUseClientMode (boolean mode ); public abstract void setWantClientAuth (boolean want ); } |