javax.naming.ldap
Class StartTlsRequest

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.naming.ldap.StartTlsRequest
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , ExtendedRequest sample code for javax.naming.ldap.ExtendedRequest definition code for javax.naming.ldap.ExtendedRequest

public class StartTlsRequest
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements ExtendedRequest sample code for javax.naming.ldap.ExtendedRequest definition code for javax.naming.ldap.ExtendedRequest

This class implements the LDAPv3 Extended Request 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 request value is defined.

StartTlsRequest/StartTlsResponse 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 these 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, etc.
 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;
 

Since:
1.4
See Also:
StartTlsResponse sample code for javax.naming.ldap.StartTlsResponse definition code for javax.naming.ldap.StartTlsResponse , Serialized Form

Field Summary
static String sample code for java.lang.String definition code for java.lang.String OID sample code for javax.naming.ldap.StartTlsRequest.OID definition code for javax.naming.ldap.StartTlsRequest.OID
          The StartTLS extended request's assigned object identifier is 1.3.6.1.4.1.1466.20037.
 
Constructor Summary
StartTlsRequest sample code for javax.naming.ldap.StartTlsRequest.StartTlsRequest() definition code for javax.naming.ldap.StartTlsRequest.StartTlsRequest() ()
          Constructs a StartTLS extended request.
 
Method Summary
 ExtendedResponse sample code for javax.naming.ldap.ExtendedResponse definition code for javax.naming.ldap.ExtendedResponse createExtendedResponse sample code for javax.naming.ldap.StartTlsRequest.createExtendedResponse(java.lang.String, byte[], int, int) definition code for javax.naming.ldap.StartTlsRequest.createExtendedResponse(java.lang.String, byte[], int, int) (String sample code for java.lang.String definition code for java.lang.String  id, byte[] berValue, int offset, int length)
          Creates an extended response object that corresponds to the LDAP StartTLS extended request.
 byte[] getEncodedValue sample code for javax.naming.ldap.StartTlsRequest.getEncodedValue() definition code for javax.naming.ldap.StartTlsRequest.getEncodedValue() ()
          Retrieves the StartTLS request's ASN.1 BER encoded value.
 String sample code for java.lang.String definition code for java.lang.String getID sample code for javax.naming.ldap.StartTlsRequest.getID() definition code for javax.naming.ldap.StartTlsRequest.getID() ()
          Retrieves the StartTLS request's object identifier string.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

OID sample code for javax.naming.ldap.StartTlsRequest.OID

public static final String sample code for java.lang.String definition code for java.lang.String  OID
The StartTLS extended request's assigned object identifier is 1.3.6.1.4.1.1466.20037.

See Also:
Constant Field Values
Constructor Detail

StartTlsRequest sample code for javax.naming.ldap.StartTlsRequest() definition code for javax.naming.ldap.StartTlsRequest()

public StartTlsRequest()
Constructs a StartTLS extended request.

Method Detail

getID sample code for javax.naming.ldap.StartTlsRequest.getID() definition code for javax.naming.ldap.StartTlsRequest.getID()

public String sample code for java.lang.String definition code for java.lang.String  getID()
Retrieves the StartTLS request's object identifier string.

Specified by:
getID sample code for javax.naming.ldap.ExtendedRequest.getID() definition code for javax.naming.ldap.ExtendedRequest.getID() in interface ExtendedRequest sample code for javax.naming.ldap.ExtendedRequest definition code for javax.naming.ldap.ExtendedRequest
Returns:
The object identifier string, "1.3.6.1.4.1.1466.20037".

getEncodedValue sample code for javax.naming.ldap.StartTlsRequest.getEncodedValue() definition code for javax.naming.ldap.StartTlsRequest.getEncodedValue()

public byte[] getEncodedValue()
Retrieves the StartTLS request's ASN.1 BER encoded value. Since the request has no defined value, null is always returned.

Specified by:
getEncodedValue sample code for javax.naming.ldap.ExtendedRequest.getEncodedValue() definition code for javax.naming.ldap.ExtendedRequest.getEncodedValue() in interface ExtendedRequest sample code for javax.naming.ldap.ExtendedRequest definition code for javax.naming.ldap.ExtendedRequest
Returns:
The null value.

createExtendedResponse sample code for javax.naming.ldap.StartTlsRequest.createExtendedResponse(java.lang.String, byte[], int, int) definition code for javax.naming.ldap.StartTlsRequest.createExtendedResponse(java.lang.String, byte[], int, int)

public ExtendedResponse sample code for javax.naming.ldap.ExtendedResponse definition code for javax.naming.ldap.ExtendedResponse  createExtendedResponse(String sample code for java.lang.String definition code for java.lang.String  id,
                                               byte[] berValue,
                                               int offset,
                                               int length)
                                        throws NamingException sample code for javax.naming.NamingException definition code for javax.naming.NamingException 
Creates an extended response object that corresponds to the LDAP StartTLS extended request.

The result must be a concrete subclass of StartTlsResponse and must have a public zero-argument constructor.

This method locates the implementation class by locating configuration files that have the name:

META-INF/services/javax.naming.ldap.StartTlsResponse
The configuration files and their corresponding implementation classes must be accessible to the calling thread's context class loader.

Each configuration file should contain a list of fully-qualified class names, one per line. Space and tab characters surrounding each name, as well as blank lines, are ignored. The comment character is '#' (0x23); on each line all characters following the first comment character are ignored. The file must be encoded in UTF-8.

This method will return an instance of the first implementation class that it is able to load and instantiate successfully from the list of class names collected from the configuration files. This method uses the calling thread's context classloader to find the configuration files and to load the implementation class.

If no class can be found in this way, this method will use an implementation-specific way to locate an implementation. If none is found, a NamingException is thrown.

Specified by:
createExtendedResponse sample code for javax.naming.ldap.ExtendedRequest.createExtendedResponse(java.lang.String, byte[], int, int) definition code for javax.naming.ldap.ExtendedRequest.createExtendedResponse(java.lang.String, byte[], int, int) in interface ExtendedRequest sample code for javax.naming.ldap.ExtendedRequest definition code for javax.naming.ldap.ExtendedRequest
Parameters:
id - The object identifier of the extended response. Its value must be "1.3.6.1.4.1.1466.20037" or null. Both values are equivalent.
berValue - The possibly null ASN.1 BER encoded value of the extended response. This is the raw BER bytes including the tag and length of the response value. It does not include the response OID. Its value is ignored because a Start TLS response is not expected to contain any response value.
offset - The starting position in berValue of the bytes to use. Its value is ignored because a Start TLS response is not expected to contain any response value.
length - The number of bytes in berValue to use. Its value is ignored because a Start TLS response is not expected to contain any response value.
Returns:
The StartTLS extended response object.
Throws:
NamingException sample code for javax.naming.NamingException definition code for javax.naming.NamingException - If a naming exception was encountered while creating the StartTLS extended response object.
See Also:
ExtendedResponse sample code for javax.naming.ldap.ExtendedResponse definition code for javax.naming.ldap.ExtendedResponse