public class SSLContext extends Object
SSLEngines. This class is initialized
 with an optional set of key and trust managers and source of
 secure random bytes.
  Every implementation of the Java platform is required to support the
 following standard SSLContext protocol:
 
| Modifier | Constructor and Description | 
|---|---|
| protected  | SSLContext(SSLContextSpi contextSpi,
          Provider provider,
          String protocol)Creates an SSLContext object. | 
| Modifier and Type | Method and Description | 
|---|---|
| SSLEngine | createSSLEngine()Creates a new  SSLEngineusing this context. | 
| SSLEngine | createSSLEngine(String peerHost,
               int peerPort)Creates a new  SSLEngineusing this context using
 advisory peer information. | 
| 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 | getDefault()Returns the default SSL context. | 
| SSLParameters | getDefaultSSLParameters()Returns a copy of the SSLParameters indicating the default
 settings for this SSL context. | 
| static SSLContext | getInstance(String protocol)Returns a  SSLContextobject that implements the
 specified secure socket protocol. | 
| static SSLContext | getInstance(String protocol,
           Provider provider)Returns a  SSLContextobject that implements the
 specified secure socket protocol. | 
| static SSLContext | getInstance(String protocol,
           String provider)Returns a  SSLContextobject that implements the
 specified secure socket protocol. | 
| String | getProtocol()Returns the protocol name of this  SSLContextobject. | 
| Provider | getProvider()Returns the provider of this  SSLContextobject. | 
| 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  ServerSocketFactoryobject for
 this context. | 
| SSLSocketFactory | getSocketFactory()Returns a  SocketFactoryobject for this
 context. | 
| SSLParameters | getSupportedSSLParameters()Returns a copy of the SSLParameters indicating the supported
 settings for this SSL context. | 
| void | init(KeyManager[] km,
    TrustManager[] tm,
    SecureRandom random)Initializes this context. | 
| static void | setDefault(SSLContext context)Sets the default SSL context. | 
protected SSLContext(SSLContextSpi contextSpi, Provider provider, String protocol)
contextSpi - the delegateprovider - the providerprotocol - the protocolpublic static SSLContext getDefault() throws NoSuchAlgorithmException
If a default context was set using the SSLContext.setDefault() method, it is returned. Otherwise, the first
 call of this method triggers the call
 SSLContext.getInstance("Default").
 If successful, that object is made the default SSL context and returned.
 
The default context is immediately usable and does not require initialization.
NoSuchAlgorithmException - if the
   SSLContext.getInstance() call failspublic static void setDefault(SSLContext context)
getDefault(). The default context must be immediately usable
 and not require initialization.NullPointerException - if context is nullSecurityException - if a security manager exists and its
          checkPermission method does not allow
          SSLPermission("setDefaultSSLContext")context - the SSLContextpublic static SSLContext getInstance(String protocol) throws NoSuchAlgorithmException
SSLContext object that implements the
 specified secure socket protocol.
 This method traverses the list of registered security Providers, starting with the most preferred Provider. A new SSLContext object encapsulating the SSLContextSpi implementation from the first Provider that supports the specified protocol is returned.
 Note that the list of registered providers may be retrieved via
 the Security.getProviders() method.
NoSuchAlgorithmException - if no Provider supports a
          SSLContextSpi implementation for the
          specified protocol.NullPointerException - if protocol is null.protocol - the standard name of the requested protocol.
          See the SSLContext section in the 
          Java Cryptography Architecture Standard Algorithm Name
          Documentation
          for information about standard protocol names.SSLContext object.Providerpublic static SSLContext getInstance(String protocol, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
SSLContext object that implements the
 specified secure socket protocol.
 A new SSLContext object encapsulating the SSLContextSpi implementation from the specified provider is returned. The specified provider must be registered in the security provider list.
 Note that the list of registered providers may be retrieved via
 the Security.getProviders() method.
NoSuchAlgorithmException - if a SSLContextSpi
          implementation for the specified protocol is not
          available from the specified provider.NoSuchProviderException - if the specified provider is not
          registered in the security provider list.IllegalArgumentException - if the provider name is null or empty.NullPointerException - if protocol is null.protocol - the standard name of the requested protocol.
          See the SSLContext section in the 
          Java Cryptography Architecture Standard Algorithm Name
          Documentation
          for information about standard protocol names.provider - the name of the provider.SSLContext object.Providerpublic static SSLContext getInstance(String protocol, Provider provider) throws NoSuchAlgorithmException
SSLContext object that implements the
 specified secure socket protocol.
 A new SSLContext object encapsulating the SSLContextSpi implementation from the specified Provider object is returned. Note that the specified Provider object does not have to be registered in the provider list.
NoSuchAlgorithmException - if a SSLContextSpi
          implementation for the specified protocol is not available
          from the specified Provider object.IllegalArgumentException - if the provider is null.NullPointerException - if protocol is null.protocol - the standard name of the requested protocol.
          See the SSLContext section in the 
          Java Cryptography Architecture Standard Algorithm Name
          Documentation
          for information about standard protocol names.provider - an instance of the provider.SSLContext object.Providerpublic final String getProtocol()
SSLContext object.
 This is the same name that was specified in one of the
 getInstance calls that created this
 SSLContext object.
SSLContext object.public final Provider getProvider()
SSLContext object.SSLContext objectpublic final void init(KeyManager[] km, TrustManager[] tm, SecureRandom random) throws KeyManagementException
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.)
KeyManagementException - if this operation failskm - the sources of authentication keys or nulltm - the sources of peer authentication trust decisions or nullrandom - the source of randomness for this generator or nullpublic final SSLSocketFactory getSocketFactory()
SocketFactory object for this
 context.IllegalStateException - if the SSLContextImpl requires
          initialization and the init() has not been calledSocketFactory objectpublic final SSLServerSocketFactory getServerSocketFactory()
ServerSocketFactory object for
 this context.IllegalStateException - if the SSLContextImpl requires
          initialization and the init() has not been calledServerSocketFactory objectpublic final SSLEngine createSSLEngine()
SSLEngine using this context.
 
 Applications using this factory method are providing no hints
 for an internal session reuse strategy. If hints are desired,
 createSSLEngine(String, int) should be used
 instead.
 
Some cipher suites (such as Kerberos) require remote hostname information, in which case this factory method should not be used.
UnsupportedOperationException - if the underlying provider
          does not implement the operation.IllegalStateException - if the SSLContextImpl requires
          initialization and the init() has not been calledSSLEngine objectpublic final SSLEngine createSSLEngine(String peerHost, int peerPort)
SSLEngine using this context using
 advisory peer information.
 Applications using this factory method are providing hints for an internal session reuse strategy.
Some cipher suites (such as Kerberos) require remote hostname information, in which case peerHost needs to be specified.
UnsupportedOperationException - if the underlying provider
          does not implement the operation.IllegalStateException - if the SSLContextImpl requires
          initialization and the init() has not been calledpeerHost - the non-authoritative name of the hostpeerPort - the non-authoritative portSSLEngine objectpublic final SSLSessionContext getServerSessionContext()
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.
public final SSLSessionContext getClientSessionContext()
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.
public final SSLParameters getDefaultSSLParameters()
The parameters will always have the ciphersuites and protocols arrays set to non-null values.
UnsupportedOperationException - if the default SSL parameters
   could not be obtained.public final SSLParameters getSupportedSSLParameters()
The parameters will always have the ciphersuites and protocols arrays set to non-null values.
UnsupportedOperationException - if the supported SSL parameters
   could not be obtained.aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2021 aicas GmbH. All Rights Reserved.