com.sun.net.ssl
Class SSLContext

java.lang.Object
  |
  +--com.sun.net.ssl.SSLContext

public class SSLContext
extends java.lang.Object

Instances of this class represent a secure socket protocol implementation which acts as a factory for secure socket factories. This class is initialized with an optional set of key and trust managers and source of secure random bytes.


Constructor Summary
protected SSLContext(SSLContextSpi contextSpi, java.security.Provider provider, java.lang.String protocol)
          Creates an SSLContext object.
 
Method Summary
static SSLContext getInstance(java.lang.String protocol)
          Generates a SSLContext object that implements the specified secure socket protocol.
static SSLContext getInstance(java.lang.String protocol, java.security.Provider provider)
          Generates a SSLContext object that implements the specified secure socket protocol.
static SSLContext getInstance(java.lang.String protocol, java.lang.String provider)
          Generates a SSLContext object that implements the specified secure socket protocol.
 java.lang.String getProtocol()
          Returns the protocol name of this SSLContext object.
 java.security.Provider getProvider()
          Returns the provider of this SSLContext object.
 SSLServerSocketFactory getServerSocketFactory()
          Returns a ServerSocketFactory object for this context.
 SSLSocketFactory getSocketFactory()
          Returns a SocketFactory object for this context.
 void init(KeyManager[] km, TrustManager[] tm, java.security.SecureRandom random)
          Initializes this context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SSLContext

protected SSLContext(SSLContextSpi contextSpi,
                     java.security.Provider provider,
                     java.lang.String protocol)
Creates an SSLContext object.
Parameters:
contextSpi - the delegate
provider - the provider
algorithm - the algorithm
Method Detail

getInstance

public static SSLContext getInstance(java.lang.String protocol)
                              throws java.security.NoSuchAlgorithmException
Generates a SSLContext object that implements the specified secure socket protocol.
Parameters:
protocol - the standard name of the requested protocol.
Returns:
the new SSLContext object
Throws:
java.security.NoSuchAlgorithmException - if the specified protocol is not available in the default provider package or any of the other provider packages that were searched.

getInstance

public static SSLContext getInstance(java.lang.String protocol,
                                     java.lang.String provider)
                              throws java.security.NoSuchAlgorithmException,
                                     java.security.NoSuchProviderException
Generates a SSLContext object that implements the specified secure socket protocol.
Parameters:
protocol - the standard name of the requested protocol.
provider - the name of the provider
Returns:
the new SSLContext object
Throws:
java.security.NoSuchAlgorithmException - if the specified protocol is not available from the specified provider.
java.security.NoSuchProviderException - if the specified provider has not been configured.

getInstance

public static SSLContext getInstance(java.lang.String protocol,
                                     java.security.Provider provider)
                              throws java.security.NoSuchAlgorithmException
Generates a SSLContext object that implements the specified secure socket protocol.
Parameters:
protocol - the standard name of the requested protocol.
provider - an instance of the provider
Returns:
the new SSLContext object
Throws:
java.security.NoSuchAlgorithmException - if the specified protocol is not available from the specified provider.

getProtocol

public final java.lang.String getProtocol()
Returns the protocol name of this SSLContext object.

This is the same name that was specified in one of the getInstance calls that created this SSLContext object.

Returns:
the protocol name of this SSLContext object.

getProvider

public final java.security.Provider getProvider()
Returns the provider of this SSLContext object.
Returns:
the provider of this SSLContext object

init

public final void init(KeyManager[] km,
                       TrustManager[] tm,
                       java.security.SecureRandom random)
                throws java.security.KeyManagementException
Initializes this context. Either of the first two parameters may be null in which case the installed security providers will be searched for the highest priority implementation of the appropriate factory. Likewise, the secure random parameter may be null in which case the default implementation will be used.
Parameters:
km - the sources of authentication keys or null
tm - the sources of peer authentication trust decisions or null
random - the source of randomness for this generator or null

getSocketFactory

public final SSLSocketFactory getSocketFactory()
Returns a SocketFactory object for this context.
Returns:
the factory

getServerSocketFactory

public final SSLServerSocketFactory getServerSocketFactory()
Returns a ServerSocketFactory object for this context.
Returns:
the factory