code: public final DirContext processContextAfterCreation(DirContext ctx, String userDn, String password)
  			throws NamingException {
  
  		if (ctx instanceof LdapContext) {
  			final LdapContext ldapCtx = (LdapContext) ctx;
  			final StartTlsResponse tlsResponse = (StartTlsResponse) ldapCtx.extendedOperation(new StartTlsRequest());
  			try {
  				if (hostnameVerifier != null) {
  					tlsResponse.setHostnameVerifier(hostnameVerifier);
  				}
  				tlsResponse.negotiate(sslSocketFactory); // If null, the default SSL socket factory is used
  				applyAuthentication(ldapCtx, userDn, password);
  
  				if (shutdownTlsGracefully) {
  					// Wrap the target context in a proxy to intercept any calls
  					// to 'close', so that we can shut down the TLS connection
  					// gracefully first.
  					return (DirContext) Proxy.newProxyInstance(DirContextProxy.class.getClassLoader(), new Class<?>[] {
  							LdapContext.class, DirContextProxy.class }, new TlsAwareDirContextProxy(ldapCtx,
  							tlsResponse));
  				}
  				else {
  					return ctx;
  				}
  			}
  			catch (IOException e) {
  				LdapUtils.closeContext(ctx);
  				throw new UncategorizedLdapException("Failed to negotiate TLS session", e);
  			}
  		}
  		else {
  			throw new IllegalArgumentException(
  					"Processed Context must be an LDAPv3 context, i.e. an LdapContext implementation");
  		}
  
  	}
docs: /* (non-Javadoc)
  @see org.springframework.ldap.core.support.DirContextAuthenticationStrategy#processContextAfterCreation(javax.naming.directory.DirContext, java.lang.String, java.lang.String)