APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.jndi.ldap.ext

public final Class StartTlsResponseImpl

extends StartTlsResponse
Class Inheritance
Imports
java.io.InputStream, .OutputStream, .IOException, java.security.cert.X509Certificate, .CertificateException, javax.net.ssl.SSLSession, .SSLSocket, .SSLSocketFactory, .SSLPeerUnverifiedException, .HostnameVerifier, sun.security.util.HostnameChecker, javax.naming.ldap.*, com.sun.jndi.ldap.Connection

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.

Author
Vincent Ryan
See Also
StartTlsRequest

Field Summary

Modifier and TypeField and Description
private transient boolean
private transient SSLSocketFactory
private static final boolean
private transient SSLSocketFactory
private transient String
private transient Connection
private transient InputStream
private transient OutputStream
private static final long
private transient SSLSocket
private transient String[]
private transient HostnameVerifier
Inherited from javax.naming.ldap.StartTlsResponse:
OID

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract javax.naming.ldap.StartTlsResponse.close.

Closes the TLS connection gracefully and reverts back to the underlying connection.

private SSLSocketFactory
public SSLSession

Returns:

The negotiated SSL session
negotiate
()

Implements abstract javax.naming.ldap.StartTlsResponse.negotiate.

Negotiates a TLS session using the default SSL socket factory.

public SSLSession

Returns:

The negotiated SSL session
negotiate
(SSLSocketFactory
The possibly null SSL socket factory to use. If null, the default SSL socket factory is used.
factory
)

Implements abstract javax.naming.ldap.StartTlsResponse.negotiate.

Negotiates a TLS session using an SSL socket factory.

public void
setConnection(Connection
The non-null connection to use.
ldapConnection
,
String
The server's hostname. If null, the hostname used to open the connection will be used instead.
hostname
)

Sets the connection for TLS to use.

public void
setEnabledCipherSuites(String[]
The non-null list of names of all the cipher suites to enable.
suites
)

Implements abstract javax.naming.ldap.StartTlsResponse.setEnabledCipherSuites.

Overrides the default list of cipher suites enabled for use on the TLS connection.

public void
setHostnameVerifier(HostnameVerifier
The non-null hostname verifier callback.
verifier
)

Implements abstract javax.naming.ldap.StartTlsResponse.setHostnameVerifier.

Overrides the default hostname verifier used by negotiate() after the TLS handshake has completed.

private SSLSocket
private boolean
verify(String hostname, SSLSession session)

Inherited from javax.naming.ldap.StartTlsResponse:
getEncodedValuegetID

Field Detail

closedback to summary
private transient boolean closed
currentFactoryback to summary
private transient SSLSocketFactory currentFactory
debugback to summary
private static final boolean debug
defaultFactoryback to summary
private transient SSLSocketFactory defaultFactory
hostnameback to summary
private transient String hostname
ldapConnectionback to summary
private transient Connection ldapConnection
originalInputStreamback to summary
private transient InputStream originalInputStream
originalOutputStreamback to summary
private transient OutputStream originalOutputStream
serialVersionUIDback to summary
private static final long serialVersionUID

Hides javax.naming.ldap.StartTlsResponse.serialVersionUID.

sslSocketback to summary
private transient SSLSocket sslSocket
suitesback to summary
private transient String[] suites
verifierback to summary
private transient HostnameVerifier verifier

Constructor Detail

StartTlsResponseImplback to summary
public StartTlsResponseImpl()

Method Detail

closeback to summary
public void close() throws IOException

Implements abstract javax.naming.ldap.StartTlsResponse.close.

Closes the TLS connection gracefully and reverts back to the underlying connection.

Annotations
@Override
Exceptions
IOException:
If an IO error was encountered while closing the TLS connection
getDefaultFactoryback to summary
private SSLSocketFactory getDefaultFactory()
negotiateback to summary
public SSLSession negotiate() throws IOException

Implements abstract javax.naming.ldap.StartTlsResponse.negotiate.

Negotiates a TLS session using the default SSL socket factory.

This method is equivalent to negotiate(null).

Returns:SSLSession

The negotiated SSL session

Annotations
@Override
Exceptions
IOException:
If an IO error was encountered while establishing the TLS session.
See Also
setEnabledCipherSuites, setHostnameVerifier
negotiateback to summary
public SSLSession negotiate(SSLSocketFactory factory) throws IOException

Implements abstract javax.naming.ldap.StartTlsResponse.negotiate.

Negotiates a TLS session using an SSL socket factory.

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.

Parameters
factory:SSLSocketFactory

The possibly null SSL socket factory to use. If null, the default SSL socket factory is used.

Returns:SSLSession

The negotiated SSL session

Annotations
@Override
Exceptions
IOException:
If an IO error was encountered while establishing the TLS session.
See Also
setEnabledCipherSuites, setHostnameVerifier
setConnectionback to summary
public void setConnection(Connection ldapConnection, String hostname)

Sets the connection for TLS to use. The TLS connection will be attached to this connection.

Parameters
ldapConnection:Connection

The non-null connection to use.

hostname:String

The server's hostname. If null, the hostname used to open the connection will be used instead.

setEnabledCipherSuitesback to summary
public void setEnabledCipherSuites(String[] suites)

Implements abstract javax.naming.ldap.StartTlsResponse.setEnabledCipherSuites.

Overrides the default list of cipher suites enabled for use on the TLS connection. The cipher suites must have already been listed by SSLSocketFactory.getSupportedCipherSuites() as being supported. Even if a suite has been enabled, it still might not be used because the peer does not support it, or because the requisite certificates (and private keys) are not available.

Parameters
suites:String[]

The non-null list of names of all the cipher suites to enable.

Annotations
@Override
See Also
negotiate
setHostnameVerifierback to summary
public void setHostnameVerifier(HostnameVerifier verifier)

Implements abstract javax.naming.ldap.StartTlsResponse.setHostnameVerifier.

Overrides the default hostname verifier used by negotiate() after the TLS handshake has completed. If setHostnameVerifier() has not been called before negotiate() is invoked, negotiate() will perform a simple case ignore match. If called after negotiate(), this method does not do anything.

Parameters
verifier:HostnameVerifier

The non-null hostname verifier callback.

Annotations
@Override
See Also
negotiate
startHandshakeback to summary
private SSLSocket startHandshake(SSLSocketFactory factory) throws IOException
verifyback to summary
private boolean verify(String hostname, SSLSession session) throws SSLPeerUnverifiedException