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.
Typically, a JNDI program uses the StartTLS extended request and response
classes as follows.
import javax.naming.ldap.*; // Open an LDAP association LdapContext ctx = new InitialLdapContext(); // Perform a StartTLS extended operation StartTlsResponse tls = (StartTlsResponse) ctx.extendedOperation(new StartTlsRequest()); // Open a TLS connection (over the existing LDAP association) and get details // of the negotiated TLS session: cipher suite, peer certificate, ... SSLSession session = tls.negotiate(); // ... use ctx to perform protected LDAP operations // Close the TLS connection (revert back to the underlying LDAP association) tls.close(); // ... use ctx to perform unprotected LDAP operations // Close the LDAP association ctx.close;
StartTlsRequest
Modifier and Type | Field and Description |
---|---|
public static final String | OID
The StartTLS extended response's assigned object identifier is 1.3.6.1.4.1.1466.20037. |
private static final long |
Access | Constructor and Description |
---|---|
protected |
Modifier and Type | Method and Description |
---|---|
public abstract void | |
public byte[] | Returns: The null value.Implements javax. Retrieves the StartTLS response's ASN.1 BER encoded value. |
public String | Returns: The object identifier string, "1.3.6.1.4.1.1466.20037".Implements javax. Retrieves the StartTLS response's object identifier string. |
public abstract SSLSession | Returns: The negotiated SSL sessionNegotiates a TLS session using the default SSL socket factory. |
public abstract SSLSession | Returns: The negotiated SSL sessionThe possibly null SSL socket factory to use.
If null, the default SSL socket factory is used. factory)Negotiates a TLS session using an SSL socket factory. |
public abstract void | setEnabledCipherSuites(String[]
The non-null list of names of all the cipher suites to
enable. suites)Overrides the default list of cipher suites enabled for use on the TLS connection. |
public abstract void | setHostnameVerifier(HostnameVerifier
The non-null hostname verifier callback. verifier)Sets the hostname verifier used by |
OID | back to summary |
---|---|
public static final String OID The StartTLS extended response's assigned object identifier is 1.3.6.1.4.1.1466.20037. |
serialVersionUID | back to summary |
---|---|
private static final long serialVersionUID |
StartTlsResponse | back to summary |
---|---|
protected StartTlsResponse() Constructs a StartTLS extended response. A concrete subclass must have a public no-arg constructor. |
close | back to summary |
---|---|
public abstract void close() throws IOException Closes the TLS connection gracefully and reverts back to the underlying connection.
|
getEncodedValue | back to summary |
---|---|
public byte[] getEncodedValue() Implements javax. Retrieves the StartTLS response's ASN.1 BER encoded value. Since the response has no defined value, null is always returned.
|
getID | back to summary |
---|---|
public String getID() Implements javax. Retrieves the StartTLS response's object identifier string.
|
negotiate | back to summary |
---|---|
public abstract SSLSession negotiate() throws IOException Negotiates a TLS session using the default SSL socket factory.
This method is equivalent to
|
negotiate | back to summary |
---|---|
public abstract 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
Hostname verification is performed after the TLS handshake completes.
The default hostname verification performs a match of the server's
hostname against the hostname information found in the server's certificate.
If this verification fails and no callback has been set via
If an error occurs then the SSL socket is closed and an IOException is thrown. The underlying connection remains intact.
|
setEnabledCipherSuites | back to summary |
---|---|
public abstract 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
|
setHostnameVerifier | back to summary |
---|---|
public abstract void setHostnameVerifier(HostnameVerifier verifier) Sets the hostname verifier used by
|