JavaTM 2 Platform
Std. Ed. v1.4.2

javax.net.ssl
Class SSLContext

java.lang.Object
  extended byjavax.net.ssl.SSLContext

public class SSLContext
extends 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.

Since:
1.4

Constructor Summary
protected SSLContext(SSLContextSpi contextSpi, Provider provider, String protocol)
          Creates an SSLContext object.
 
Method Summary
 SSLSessionContext getClientSessionContext()
          Returns the client session context, which represents the set of SSL sessions available for use during the handshake phase of client-side SSL sockets.
static SSLContext getInstance(String protocol)
          Generates a SSLContext object that implements the specified secure socket protocol.
static SSLContext getInstance(String protocol, Provider provider)
          Generates a SSLContext object that implements the specified secure socket protocol from the specified provider.
static SSLContext getInstance(String protocol, String provider)
          Generates a SSLContext object that implements the specified secure socket protocol from the specified provider.
 String getProtocol()
          Returns the protocol name of this SSLContext object.
 Provider getProvider()
          Returns the provider of this SSLContext object.
 SSLSessionContext getServerSessionContext()
          Returns the server session context, which represents the set of SSL sessions available for use during the handshake phase of server-side SSL sockets.
 SSLServerSocketFactory getServerSocketFactory()
          Returns a ServerSocketFactory object for this context.
 SSLSocketFactory getSocketFactory()
          Returns a SocketFactory object for this context.
 void init(KeyManager[] km, TrustManager[] tm, 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,
                     Provider provider,
                     String protocol)
Creates an SSLContext object.

Parameters:
contextSpi - the delegate
provider - the provider
protocol - the protocol
Method Detail

getInstance

public static SSLContext getInstance(String protocol)
                              throws NoSuchAlgorithmException
Generates a SSLContext object that implements the specified secure socket protocol.

If the default provider package provides an implementation of the requested key management algorithm, an instance of SSLContext containing that implementation is returned. If the algorithm is not available in the default provider package, other provider packages are searched.

Parameters:
protocol - the standard name of the requested protocol.
Returns:
the new SSLContext object
Throws:
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(String protocol,
                                     String provider)
                              throws NoSuchAlgorithmException,
                                     NoSuchProviderException
Generates a SSLContext object that implements the specified secure socket protocol from the specified provider.

Parameters:
protocol - the standard name of the requested protocol.
provider - the name of the provider
Returns:
the new SSLContext object
Throws:
NoSuchAlgorithmException - if the specified protocol is not available from the specified provider.
NoSuchProviderException - if the specified provider has not been configured.
IllegalArgumentException - if provider is not specified

getInstance

public static SSLContext getInstance(String protocol,
                                     Provider provider)
                              throws NoSuchAlgorithmException
Generates a SSLContext object that implements the specified secure socket protocol from the specified provider.

Parameters:
protocol - the standard name of the requested protocol.
provider - an instance of the provider
Returns:
the new SSLContext object
Throws:
NoSuchAlgorithmException - if the specified protocol is not available from the specified provider.
IllegalArgumentException - if provider is not specified

getProtocol

public final 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 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,
                       SecureRandom random)
                throws 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.

Only the first instance of a particular key and/or trust manager implementation type in the array is used. (For example, only the first javax.net.ssl.X509KeyManager in the array 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
Throws:
KeyManagementException - if this operation fails

getSocketFactory

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

Returns:
the SocketFactory object

getServerSocketFactory

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

Returns:
the ServerSocketFactory object

getServerSessionContext

public final SSLSessionContext getServerSessionContext()
Returns the server session context, which represents the set of SSL sessions available for use during the handshake phase of server-side SSL sockets.

This context may be unavailable in some environments, in which case this method returns null. For example, when the underlying SSL provider does not provide an implementation of SSLSessionContext interface, this method returns null. A non-null session context is returned otherwise.

Returns:
server session context bound to this SSL context

getClientSessionContext

public final SSLSessionContext getClientSessionContext()
Returns the client session context, which represents the set of SSL sessions available for use during the handshake phase of client-side SSL sockets.

This context may be unavailable in some environments, in which case this method returns null. For example, when the underlying SSL provider does not provide an implementation of SSLSessionContext interface, this method returns null. A non-null session context is returned otherwise.

Returns:
client session context bound to this SSL context

JavaTM 2 Platform
Std. Ed. v1.4.2

Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.


Spec-Zone.ru - all specs in one place



free hit counter