当前位置: 首页>>代码示例>>Java>>正文


Java LdapUtils.closeContext方法代码示例

本文整理汇总了Java中org.springframework.ldap.support.LdapUtils.closeContext方法的典型用法代码示例。如果您正苦于以下问题:Java LdapUtils.closeContext方法的具体用法?Java LdapUtils.closeContext怎么用?Java LdapUtils.closeContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.ldap.support.LdapUtils的用法示例。


在下文中一共展示了LdapUtils.closeContext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doAuthentication

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Override
protected DirContextOperations doAuthentication(
		UsernamePasswordAuthenticationToken auth) {
	String username = auth.getName();
	String password = (String) auth.getCredentials();

	DirContext ctx = bindAsUser(username, password);

	try {
		return searchForUser(ctx, username);
	}
	catch (NamingException e) {
		logger.error("Failed to locate directory entry for authenticated user: "
				+ username, e);
		throw badCredentials(e);
	}
	finally {
		LdapUtils.closeContext(ctx);
	}
}
 
开发者ID:gustajz,项目名称:parking-api,代码行数:21,代码来源:ActiveDirectoryAliasLdapAuthenticationProvider.java

示例2: verifyAuthenticate

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
   @Category(NoAdTest.class)
public void verifyAuthenticate() {
	EqualsFilter filter = new EqualsFilter("cn", "Some Person2");
	List<String> results = ldapTemplate.search("", filter.toString(), new DnContextMapper());
	if (results.size() != 1) {
		throw new IncorrectResultSizeDataAccessException(1, results.size());
	}

	DirContext ctx = null;
	try {
		ctx = tested.getContext(results.get(0), "password");
		assertThat(true).isTrue();
	}
	catch (Exception e) {
		fail("Authentication failed");
	}
	finally {
		LdapUtils.closeContext(ctx);
	}
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:23,代码来源:LdapContextSourceIntegrationTest.java

示例3: processContextAfterCreation

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的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

示例4: testCloseContext

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testCloseContext() throws NamingException {
    LdapUtils.closeContext(dirContextMock);
    verify(dirContextMock).close();
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:6,代码来源:LdapTransactionUtilsTest.java

示例5: testCloseContext_NullContext

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testCloseContext_NullContext() throws NamingException {
    LdapUtils.closeContext(null);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:5,代码来源:LdapTransactionUtilsTest.java


注:本文中的org.springframework.ldap.support.LdapUtils.closeContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。