本文整理汇总了Java中javax.naming.ldap.StartTlsResponse.negotiate方法的典型用法代码示例。如果您正苦于以下问题:Java StartTlsResponse.negotiate方法的具体用法?Java StartTlsResponse.negotiate怎么用?Java StartTlsResponse.negotiate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.naming.ldap.StartTlsResponse
的用法示例。
在下文中一共展示了StartTlsResponse.negotiate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processContextAfterCreation
import javax.naming.ldap.StartTlsResponse; //导入方法依赖的package包/类
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");
}
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:37,代码来源:AbstractTlsDirContextAuthenticationStrategy.java