|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.naming.ldap.StartTlsResponse
com.sun.jndi.ldap.ext.StartTlsResponseImpl
public final class StartTlsResponseImpl
This class implements the LDAPv3 Extended Response for StartTLS as defined in Lightweight Directory Access Protocol (v3): Extension for Transport Layer Security The object identifier for StartTLS is 1.3.6.1.4.1.1466.20037 and no extended response value is defined.
The Start TLS extended request and response are used to establish a TLS connection over the existing LDAP connection associated with the JNDI context on which extendedOperation() is invoked.
StartTlsRequest
,
Serialized FormField Summary | |
---|---|
private javax.net.ssl.SSLSocketFactory |
currentFactory
|
private static boolean |
debug
|
private javax.net.ssl.SSLSocketFactory |
defaultFactory
|
private static int |
DNSNAME_TYPE
|
private java.lang.String |
hostname
|
private boolean |
isClosed
|
private com.sun.jndi.ldap.Connection |
ldapConnection
|
private java.io.InputStream |
originalInputStream
|
private java.io.OutputStream |
originalOutputStream
|
private static long |
serialVersionUID
|
private javax.net.ssl.SSLSocket |
sslSocket
|
private java.lang.String[] |
suites
|
private javax.net.ssl.HostnameVerifier |
verifier
|
Fields inherited from class javax.naming.ldap.StartTlsResponse |
---|
OID |
Constructor Summary | |
---|---|
StartTlsResponseImpl()
|
Method Summary | |
---|---|
void |
close()
Closes the TLS connection gracefully and reverts back to the underlying connection. |
private javax.net.ssl.SSLSocketFactory |
getDefaultFactory()
|
private static java.security.Principal |
getPeerPrincipal(javax.net.ssl.SSLSession session)
|
javax.net.ssl.SSLSession |
negotiate()
Negotiates a TLS session using the default SSL socket factory. |
javax.net.ssl.SSLSession |
negotiate(javax.net.ssl.SSLSocketFactory factory)
Negotiates a TLS session using an SSL socket factory. |
void |
setConnection(com.sun.jndi.ldap.Connection ldapConnection,
java.lang.String hostname)
Sets the connection for TLS to use. |
void |
setEnabledCipherSuites(java.lang.String[] suites)
Overrides the default list of cipher suites enabled for use on the TLS connection. |
void |
setHostnameVerifier(javax.net.ssl.HostnameVerifier verifier)
Overrides the default hostname verifier used by negotiate() after the TLS handshake has completed. |
private javax.net.ssl.SSLSocket |
startHandshake(javax.net.ssl.SSLSocketFactory factory)
|
private boolean |
verify(java.lang.String hostname,
javax.net.ssl.SSLSession session)
|
Methods inherited from class javax.naming.ldap.StartTlsResponse |
---|
getEncodedValue, getID |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final boolean debug
private static final int DNSNAME_TYPE
private transient java.lang.String hostname
private transient com.sun.jndi.ldap.Connection ldapConnection
private transient java.io.InputStream originalInputStream
private transient java.io.OutputStream originalOutputStream
private transient javax.net.ssl.SSLSocket sslSocket
private transient javax.net.ssl.SSLSocketFactory defaultFactory
private transient javax.net.ssl.SSLSocketFactory currentFactory
private transient java.lang.String[] suites
private transient javax.net.ssl.HostnameVerifier verifier
private transient boolean isClosed
private static final long serialVersionUID
Constructor Detail |
---|
public StartTlsResponseImpl()
Method Detail |
---|
public void setEnabledCipherSuites(java.lang.String[] suites)
setEnabledCipherSuites
in class javax.naming.ldap.StartTlsResponse
suites
- The non-null list of names of all the cipher suites to
enable.negotiate()
public void setHostnameVerifier(javax.net.ssl.HostnameVerifier verifier)
setHostnameVerifier
in class javax.naming.ldap.StartTlsResponse
verifier
- The non-null hostname verifier callback.negotiate()
public javax.net.ssl.SSLSession negotiate() throws java.io.IOException
This method is equivalent to negotiate(null).
negotiate
in class javax.naming.ldap.StartTlsResponse
java.io.IOException
setEnabledCipherSuites(java.lang.String[])
,
setHostnameVerifier(javax.net.ssl.HostnameVerifier)
public javax.net.ssl.SSLSession negotiate(javax.net.ssl.SSLSocketFactory factory) throws java.io.IOException
Creates an SSL socket using the supplied SSL socket factory and attaches it to the existing connection. Performs the TLS handshake and returns the negotiated session information.
If cipher suites have been set via setEnabledCipherSuites then they are enabled before the TLS handshake begins.
Hostname verification is performed after the TLS handshake completes. The default check performs a case insensitive match of the server's hostname against that in the server's certificate. The server's hostname is extracted from the subjectAltName in the server's certificate (if present). Otherwise the value of the common name attribute of the subject name is used. If a callback has been set via setHostnameVerifier then that verifier is used if the default check fails.
If an error occurs then the SSL socket is closed and an IOException is thrown. The underlying connection remains intact.
negotiate
in class javax.naming.ldap.StartTlsResponse
factory
- The possibly null SSL socket factory to use.
If null, the default SSL socket factory is used.
java.io.IOException
setEnabledCipherSuites(java.lang.String[])
,
setHostnameVerifier(javax.net.ssl.HostnameVerifier)
public void close() throws java.io.IOException
close
in class javax.naming.ldap.StartTlsResponse
java.io.IOException
public void setConnection(com.sun.jndi.ldap.Connection ldapConnection, java.lang.String hostname)
ldapConnection
- The non-null connection to use.hostname
- The server's hostname. If null, the hostname used to
open the connection will be used instead.private javax.net.ssl.SSLSocketFactory getDefaultFactory() throws java.io.IOException
java.io.IOException
private javax.net.ssl.SSLSocket startHandshake(javax.net.ssl.SSLSocketFactory factory) throws java.io.IOException
java.io.IOException
private boolean verify(java.lang.String hostname, javax.net.ssl.SSLSession session) throws javax.net.ssl.SSLPeerUnverifiedException
javax.net.ssl.SSLPeerUnverifiedException
private static java.security.Principal getPeerPrincipal(javax.net.ssl.SSLSession session) throws javax.net.ssl.SSLPeerUnverifiedException
javax.net.ssl.SSLPeerUnverifiedException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |