本文整理汇总了Java中org.springframework.ldap.core.support.LdapContextSource.setPooled方法的典型用法代码示例。如果您正苦于以下问题:Java LdapContextSource.setPooled方法的具体用法?Java LdapContextSource.setPooled怎么用?Java LdapContextSource.setPooled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.ldap.core.support.LdapContextSource
的用法示例。
在下文中一共展示了LdapContextSource.setPooled方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startLDAPServer
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
@BeforeClass
public static void startLDAPServer() throws Exception {
LdapTestUtils.startApacheDirectoryServer(PORT, baseName.toString(), "test", PRINCIPAL, CREDENTIALS, null);
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl("ldap://127.0.0.1:" + PORT);
contextSource.setUserDn("");
contextSource.setPassword("");
contextSource.setPooled(false);
contextSource.afterPropertiesSet();
// Create the Sprint LDAP template
LdapTemplate template = new LdapTemplate(contextSource);
// Clear out any old data - and load the test data
LdapTestUtils.cleanAndSetup(template.getContextSource(), baseName, new ClassPathResource("ldap/testdata.ldif"));
System.out.println("____________Started LDAP_________");
}
示例2: loadData
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
protected static void loadData() throws Exception
{
// Bind to the directory
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl("ldap://127.0.0.1:10389");
contextSource.setUserDn("uid=admin,ou=system");
contextSource.setPassword("secret");
contextSource.setPooled(false);
//contextSource.setDirObjectFactory(null);
contextSource.afterPropertiesSet();
// Create the Sprint LDAP template
LdapTemplate template = new LdapTemplate(contextSource);
// Clear out any old data - and load the test data
LdapTestUtils.clearSubContexts(contextSource, LdapUtils.newLdapName("dc=example,dc=com"));
LdapTestUtils.loadLdif(contextSource, new ClassPathResource("data.ldif"));
}
示例3: buildDB
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
@Before @Override
public void buildDB() throws Exception {
super.buildDB ();
// Bind to the LDAP directory:
final LdapContextSource contextSource = new LdapContextSource ();
contextSource.setUrl ("ldap://127.0.0.1:" + PORT + "/dc=inspire,dc=idgis,dc=eu");
contextSource.setUserDn (PRINCIPAL);
contextSource.setPassword (CREDENTIALS);
contextSource.setPooled (false);
contextSource.afterPropertiesSet ();
// Create an LDAP template:
ldapTemplate = new LdapTemplate (contextSource);
LdapTestUtils.cleanAndSetup (ldapTemplate.getContextSource (), new DistinguishedName (), new ClassPathResource ("nl/ipo/cds/dao/testdata.ldif"));
((ManagerDaoImpl)managerDao).setLdapTemplate (ldapTemplate);
entityManager.flush ();
}
示例4: getLdapContextSource
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
private LdapContextSource getLdapContextSource() throws Exception {
LdapContextSource ldapContextSource = new DefaultSpringSecurityContextSource(
ldapURL);
ldapContextSource.setUserDn(ldapBindDN);
ldapContextSource.setPassword(ldapBindPassword);
ldapContextSource.setReferral(ldapReferral);
ldapContextSource.setCacheEnvironmentProperties(false);
ldapContextSource.setAnonymousReadOnly(false);
ldapContextSource.setPooled(true);
ldapContextSource.afterPropertiesSet();
return ldapContextSource;
}
示例5: sdContextSourceTarget
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
@Bean
public LdapContextSource sdContextSourceTarget() {
LdapContextSource ldapContextSource = new LdapContextSource();
ldapContextSource.setUrl(ldapUrl);
ldapContextSource.setUserDn(managerUserDn);
ldapContextSource.setPassword(managerPasword);
ldapContextSource.setPooled(false);
ldapContextSource.afterPropertiesSet();
return ldapContextSource;
}
示例6: setUp
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
// Create some basic converters and a converter manager
converterManager = new ConverterManagerImpl();
Converter ptc = new FromStringConverter();
converterManager.addConverter(String.class, "", Byte.class, ptc);
converterManager.addConverter(String.class, "", Short.class, ptc);
converterManager.addConverter(String.class, "", Integer.class, ptc);
converterManager.addConverter(String.class, "", Long.class, ptc);
converterManager.addConverter(String.class, "", Double.class, ptc);
converterManager.addConverter(String.class, "", Float.class, ptc);
converterManager.addConverter(String.class, "", Boolean.class, ptc);
Converter tsc = new ToStringConverter();
converterManager.addConverter(Byte.class, "", String.class, tsc);
converterManager.addConverter(Short.class, "", String.class, tsc);
converterManager.addConverter(Integer.class, "", String.class, tsc);
converterManager.addConverter(Long.class, "", String.class, tsc);
converterManager.addConverter(Double.class, "", String.class, tsc);
converterManager.addConverter(Float.class, "", String.class, tsc);
converterManager.addConverter(Boolean.class, "", String.class, tsc);
// Bind to the directory
contextSource = new LdapContextSource();
contextSource.setUrl("ldap://127.0.0.1:" + port);
contextSource.setUserDn("");
contextSource.setPassword("");
contextSource.setPooled(false);
contextSource.afterPropertiesSet();
// Clear out any old data - and load the test data
LdapTestUtils.cleanAndSetup(contextSource, baseName, new ClassPathResource("testdata.ldif"));
}
示例7: getContextSource
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
private static ContextSource getContextSource(String url, String username, String password) throws Exception {
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(url);
contextSource.setUserDn(username);
contextSource.setPassword(password);
contextSource.setPooled(false);
contextSource.afterPropertiesSet();
return contextSource;
}
示例8: createInstance
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
protected ContextSource createInstance() throws Exception {
LdapTestUtils.startEmbeddedServer(port,
defaultPartitionSuffix, defaultPartitionName);
if (contextSource == null) {
// If not explicitly configured, create a new instance.
LdapContextSource targetContextSource = new LdapContextSource();
if (baseOnTarget) {
targetContextSource.setBase(defaultPartitionSuffix);
}
targetContextSource.setUrl("ldap://localhost:" + port);
targetContextSource.setUserDn(principal);
targetContextSource.setPassword(password);
targetContextSource.setDirObjectFactory(dirObjectFactory);
targetContextSource.setPooled(pooled);
if (authenticationSource != null) {
targetContextSource.setAuthenticationSource(authenticationSource);
}
targetContextSource.afterPropertiesSet();
contextSource = targetContextSource;
}
Thread.sleep(1000);
if (baseOnTarget) {
LdapTestUtils.clearSubContexts(contextSource, LdapUtils.emptyLdapName());
}
else {
LdapTestUtils.clearSubContexts(contextSource, LdapUtils.newLdapName(defaultPartitionSuffix));
}
if (ldifFile != null) {
LdapTestUtils.loadLdif(contextSource, ldifFile);
}
return contextSource;
}
示例9: setAdditionalContextSourceProperties
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
protected void setAdditionalContextSourceProperties(LdapContextSource ctx, final String dnsName) {
DigestMd5DirContextAuthenticationStrategy authenticationStrategy = new DigestMd5DirContextAuthenticationStrategy();
// authenticationStrategy.setHostnameVerifier(new HostnameVerifier() {
// public boolean verify(String hostname, SSLSession session) {
// return hostname.equals(dnsName);
// }
// });
ctx.setAuthenticationStrategy(authenticationStrategy);
ctx.setPooled(false);
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:13,代码来源:DigestMd5ContextSourceEc2InstanceLaunchingFactoryBean.java
示例10: setAdditionalContextSourceProperties
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
protected void setAdditionalContextSourceProperties(LdapContextSource ctx, final String dnsName) {
DefaultTlsDirContextAuthenticationStrategy authenticationStrategy = new DefaultTlsDirContextAuthenticationStrategy();
authenticationStrategy.setHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return hostname.equals(dnsName);
}
});
ctx.setAuthenticationStrategy(authenticationStrategy);
ctx.setPooled(false);
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:13,代码来源:TlsContextSourceEc2InstanceLaunchingFactoryBean.java
示例11: createInstance
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
protected Object createInstance() throws Exception {
LdapTestUtils.startEmbeddedServer(port, defaultPartitionSuffix, defaultPartitionName);
if (contextSource == null) {
// If not explicitly configured, create a new instance.
LdapContextSource targetContextSource = new LdapContextSource();
if (baseOnTarget) {
targetContextSource.setBase(defaultPartitionSuffix);
}
targetContextSource.setUrl("ldap://localhost:" + port);
targetContextSource.setUserDn(principal);
targetContextSource.setPassword(password);
targetContextSource.setDirObjectFactory(dirObjectFactory);
targetContextSource.setPooled(pooled);
if (authenticationSource != null) {
targetContextSource.setAuthenticationSource(authenticationSource);
}
targetContextSource.afterPropertiesSet();
contextSource = targetContextSource;
}
Thread.sleep(1000);
if (baseOnTarget) {
LdapTestUtils.clearSubContexts(contextSource, LdapUtils.emptyLdapName());
}
else {
LdapTestUtils.clearSubContexts(contextSource, LdapUtils.newLdapName(defaultPartitionSuffix));
}
if (ldifFile != null) {
LdapTestUtils.loadLdif(contextSource, ldifFile);
}
return contextSource;
}
示例12: doCreateInstance
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
@Override
protected final Object doCreateInstance(final String dnsName) throws Exception {
Assert.hasText(userDn);
LdapContextSource instance = new LdapContextSource();
instance.setUrl("ldap://" + dnsName);
instance.setUserDn(userDn);
instance.setPassword(password);
instance.setBase(base);
instance.setPooled(pooled);
setAdditionalContextSourceProperties(instance, dnsName);
instance.afterPropertiesSet();
return instance;
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:15,代码来源:ContextSourceEc2InstanceLaunchingFactoryBean.java
示例13: getADBindAuthentication
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
private Authentication getADBindAuthentication (Authentication authentication) {
try {
String userName = authentication.getName();
String userPassword = "";
if (authentication.getCredentials() != null) {
userPassword = authentication.getCredentials().toString();
}
LdapContextSource ldapContextSource = new DefaultSpringSecurityContextSource(adURL);
ldapContextSource.setUserDn(adBindDN);
ldapContextSource.setPassword(adBindPassword);
ldapContextSource.setReferral(adReferral);
ldapContextSource.setCacheEnvironmentProperties(true);
ldapContextSource.setAnonymousReadOnly(false);
ldapContextSource.setPooled(true);
ldapContextSource.afterPropertiesSet();
if (adUserSearchFilter==null || adUserSearchFilter.trim().isEmpty()) {
adUserSearchFilter="(sAMAccountName={0})";
}
FilterBasedLdapUserSearch userSearch=new FilterBasedLdapUserSearch(adBase, adUserSearchFilter,ldapContextSource);
userSearch.setSearchSubtree(true);
BindAuthenticator bindAuthenticator = new BindAuthenticator(ldapContextSource);
bindAuthenticator.setUserSearch(userSearch);
bindAuthenticator.afterPropertiesSet();
LdapAuthenticationProvider ldapAuthenticationProvider = new LdapAuthenticationProvider(bindAuthenticator);
if (userName != null && userPassword != null
&& !userName.trim().isEmpty()
&& !userPassword.trim().isEmpty()) {
final List<GrantedAuthority> grantedAuths = getAuthorities(userName);
final UserDetails principal = new User(userName, userPassword,
grantedAuths);
final Authentication finalAuthentication = new UsernamePasswordAuthenticationToken(
principal, userPassword, grantedAuths);
authentication = ldapAuthenticationProvider.authenticate(finalAuthentication);
if (groupsFromUGI) {
authentication = getAuthenticationWithGrantedAuthorityFromUGI(authentication);
}
return authentication;
} else {
LOG.error("AD Authentication Failed userName or userPassword is null or empty");
return null;
}
} catch (Exception e) {
LOG.error("AD Authentication Failed:", e);
return null;
}
}
示例14: setUp
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
// Create some basic converters and a converter manager
converterManager = new ConverterManagerImpl();
Converter ptc = new FromStringConverter();
converterManager.addConverter(String.class, "", Byte.class, ptc);
converterManager.addConverter(String.class, "", Short.class, ptc);
converterManager.addConverter(String.class, "", Integer.class, ptc);
converterManager.addConverter(String.class, "", Long.class, ptc);
converterManager.addConverter(String.class, "", Double.class, ptc);
converterManager.addConverter(String.class, "", Float.class, ptc);
converterManager.addConverter(String.class, "", Boolean.class, ptc);
Converter tsc = new ToStringConverter();
converterManager.addConverter(Byte.class, "", String.class, tsc);
converterManager.addConverter(Short.class, "", String.class, tsc);
converterManager.addConverter(Integer.class, "", String.class, tsc);
converterManager.addConverter(Long.class, "", String.class, tsc);
converterManager.addConverter(Double.class, "", String.class, tsc);
converterManager.addConverter(Float.class, "", String.class, tsc);
converterManager.addConverter(Boolean.class, "", String.class, tsc);
// Bind to the directory
contextSource = new LdapContextSource();
contextSource.setUrl("ldaps://127.0.0.1:" + port);
contextSource.setUserDn(USER_DN);
contextSource.setPassword(PASSWORD);
contextSource.setPooled(false);
contextSource.setBase("dc=261consulting,dc=local");
HashMap<String, Object> baseEnvironment = new HashMap<String, Object>() {{
put("java.naming.ldap.attributes.binary", "thumbnailLogo replPropertyMetaData partialAttributeSet registeredAddress userPassword telexNumber partialAttributeDeletionList mS-DS-ConsistencyGuid attributeCertificateAttribute thumbnailPhoto teletexTerminalIdentifier replUpToDateVector dSASignature objectGUID");
}};
contextSource.setBaseEnvironmentProperties(baseEnvironment);
contextSource.afterPropertiesSet();
ldapTemplate = new LdapTemplate(contextSource);
cleanup();
DirContextAdapter ctx = new DirContextAdapter("cn=William Hartnell,cn=Users");
ctx.setAttributeValues("objectclass", new String[]{"person","inetorgperson","organizationalperson","top"});
ctx.setAttributeValue("cn", "William Hartnell");
ctx.addAttributeValue("description", "First Doctor");
ctx.addAttributeValue("description", "Grumpy");
ctx.addAttributeValue("sn", "Hartnell");
ctx.addAttributeValue("telephonenumber", "1");
ldapTemplate.bind(ctx);
}