aicas logo Jamaica 3.4 release 8

com.sun.jndi.ldap.ext
Class StartTlsResponseImpl

java.lang.Object
  extended by javax.naming.ldap.StartTlsResponse
      extended by com.sun.jndi.ldap.ext.StartTlsResponseImpl
All Implemented Interfaces:
Serializable, ExtendedResponse

public final class StartTlsResponseImpl
extends StartTlsResponse

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.

See Also:
StartTlsRequest, Serialized Form

Field Summary
 
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.
 SSLSession negotiate()
          Negotiates a TLS session using the default SSL socket factory.
 SSLSession negotiate(SSLSocketFactory factory)
          Negotiates a TLS session using an SSL socket factory.
 void setConnection(Connection ldapConnection, String hostname)
          Sets the connection for TLS to use.
 void setEnabledCipherSuites(String[] suites)
          Overrides the default list of cipher suites enabled for use on the TLS connection.
 void setHostnameVerifier(HostnameVerifier verifier)
          Overrides the default hostname verifier used by negotiate() after the TLS handshake has completed.
 
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
 

Constructor Detail

StartTlsResponseImpl

public StartTlsResponseImpl()
Method Detail

setEnabledCipherSuites

public void setEnabledCipherSuites(String[] suites)
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.

Specified by:
setEnabledCipherSuites in class StartTlsResponse
Parameters:
suites - The non-null list of names of all the cipher suites to enable.
See Also:
negotiate()

setHostnameVerifier

public void setHostnameVerifier(HostnameVerifier verifier)
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.

Specified by:
setHostnameVerifier in class StartTlsResponse
Parameters:
verifier - The non-null hostname verifier callback.
See Also:
negotiate()

negotiate

public SSLSession negotiate()
                     throws IOException
Negotiates a TLS session using the default SSL socket factory.

This method is equivalent to negotiate(null).

Specified by:
negotiate in class StartTlsResponse
Returns:
The negotiated SSL session
Throws:
IOException - If an IO error was encountered while establishing the TLS session.
See Also:
setEnabledCipherSuites(java.lang.String[]), setHostnameVerifier(javax.net.ssl.HostnameVerifier)

negotiate

public SSLSession negotiate(SSLSocketFactory factory)
                     throws IOException
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.

Specified by:
negotiate in class StartTlsResponse
Parameters:
factory - The possibly null SSL socket factory to use. If null, the default SSL socket factory is used.
Returns:
The negotiated SSL session
Throws:
IOException - If an IO error was encountered while establishing the TLS session.
See Also:
setEnabledCipherSuites(java.lang.String[]), setHostnameVerifier(javax.net.ssl.HostnameVerifier)

close

public void close()
           throws IOException
Closes the TLS connection gracefully and reverts back to the underlying connection.

Specified by:
close in class StartTlsResponse
Throws:
IOException - If an IO error was encountered while closing the TLS connection

setConnection

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 - The non-null connection to use.
hostname - The server's hostname. If null, the hostname used to open the connection will be used instead.

aicas logo Jamaica 3.4 release 8

aicas GmbH, Karlsruhe - Germany    www.aicas.com
Copyright 2001-2009 aicas GmbH. All Rights Reserved.