本文整理汇总了Java中org.springframework.ldap.core.support.LdapContextSource.setUrl方法的典型用法代码示例。如果您正苦于以下问题:Java LdapContextSource.setUrl方法的具体用法?Java LdapContextSource.setUrl怎么用?Java LdapContextSource.setUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.ldap.core.support.LdapContextSource
的用法示例。
在下文中一共展示了LdapContextSource.setUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: buildContextTemplate
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
private LdapTemplate buildContextTemplate ()
throws Exception {
LdapTemplate ldapSpringTemplate = new LdapTemplate();
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUserDn( ldapUser );
contextSource.setPassword( ldapPass );
contextSource.setUrl( ldapUrl );
// Critical: Spring beans must be initialized, and JavaConfig requires
// explicity calls
contextSource.afterPropertiesSet();
ldapSpringTemplate.setContextSource( contextSource );
ldapSpringTemplate.afterPropertiesSet();
return ldapSpringTemplate;
}
示例4: SimpleLDAPAuthenticationProvider
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
public SimpleLDAPAuthenticationProvider(EntityManager entityManager,
String ldapUrl, String ldapUserDn, String ldapPassword,
String ldapBase, String ldapUid) throws Exception {
this.entityManager = entityManager;
this.ldapBase = ldapBase;
this.ldapUid = ldapUid;
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(ldapUrl);
contextSource.setUserDn(ldapUserDn);
contextSource.setPassword(ldapPassword);
contextSource.afterPropertiesSet();
ldapTemplate = new LdapTemplate(contextSource);
ldapTemplate.afterPropertiesSet();
}
示例5: LdapCredentialsAuthenticator
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
/**
* This constructor creates a LdapCredentialsAuthenticator that authenticates against an LDAP server
* that supports anonymous requests
*
* @param ldapHost the LDAP server host
* @param ldapPort the LDAP server port
* @param usersOuPath the path for the organizational unit under which users are found
*/
public LdapCredentialsAuthenticator(final String ldapHost,
final int ldapPort,
final String usersOuPath) {
Assert.hasText(ldapHost, "Invalid ldapHost");
Assert.isTrue(ldapPort > 0);
Assert.hasText(usersOuPath, "Invalid usersOuPath");
final LdapContextSource contextSource = new LdapContextSource();
contextSource.setAnonymousReadOnly(true);
contextSource.setUrl("ldap://" + ldapHost + ":" + ldapPort);
contextSource.setBase(usersOuPath);
contextSource.afterPropertiesSet();
ldapTemplate = new LdapTemplate(contextSource);
this.id = calculateId(ldapHost, ldapPort, usersOuPath);
}
示例6: 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 ();
}
示例7: ldapTemplate
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
public static LdapTemplate ldapTemplate(String bindDn, String password, int port) {
LdapTemplate t = new LdapTemplate();
LdapContextSource s = new LdapContextSource();
s.setPassword(password);
s.setUserDn(bindDn);
s.setUrl(String.format("ldap://localhost:%d", port));
t.setContextSource(s);
try {
t.afterPropertiesSet();
} catch (Exception e) {
throw new RuntimeException(e);
}
s.afterPropertiesSet();
return t;
}
示例8: getUserLdapRepository
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
/**
* Build a user LDAP repository from the given node.
*
* @param node
* The node, also used as cache key.
* @return The {@link UserLdapRepository} instance. Cache is involved.
*/
@CacheResult(cacheName = "ldap-user-repository")
public UserLdapRepository getUserLdapRepository(@CacheKey final String node) {
log.info("Build ldap template for node {}", node);
final Map<String, String> parameters = pvResource.getNodeParameters(node);
final LdapContextSource contextSource = new LdapContextSource();
contextSource.setReferral(parameters.get(PARAMETER_REFERRAL));
contextSource.setPassword(parameters.get(PARAMETER_PASSWORD));
contextSource.setUrl(parameters.get(PARAMETER_URL));
contextSource.setUserDn(parameters.get(PARAMETER_USER));
contextSource.setBase(parameters.get(PARAMETER_BASE_BN));
contextSource.afterPropertiesSet();
final LdapTemplate template = new LdapTemplate();
template.setContextSource(contextSource);
template.setIgnorePartialResultException(true);
// A new repository instance
final UserLdapRepository repository = new UserLdapRepository();
repository.setTemplate(template);
repository.setPeopleBaseDn(StringUtils.trimToEmpty(parameters.get(PARAMETER_PEOPLE_DN)));
repository.setPeopleInternalBaseDn(parameters.get(PARAMETER_PEOPLE_INTERNAL_DN));
repository.setQuarantineBaseDn(StringUtils.trimToEmpty(parameters.get(PARAMETER_QUARANTINE_DN)));
repository.setDepartmentAttribute(parameters.get(PARAMETER_DEPARTMENT_ATTRIBUTE));
repository.setLocalIdAttribute(parameters.get(PARAMETER_LOCAL_ID_ATTRIBUTE));
repository.setUidAttribute(parameters.get(PARAMETER_UID_ATTRIBUTE));
repository.setLockedAttribute(parameters.get(PARAMETER_LOCKED_ATTRIBUTE));
repository.setLockedValue(parameters.get(PARAMETER_LOCKED_VALUE));
repository.setPeopleClass(parameters.get(PARAMETER_PEOPLE_CLASS));
repository.setCompanyPattern(StringUtils.trimToEmpty(parameters.get(PARAMETER_COMPANY_PATTERN)));
// Complete the bean
SpringUtils.getApplicationContext().getAutowireCapableBeanFactory().autowireBean(repository);
return repository;
}
示例9: contextSourceLdap
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
/**
* LdapContextSource
* @return le context ldap
*/
@Bean
public LdapContextSource contextSourceLdap() {
LdapContextSource ldapContextSource = new LdapContextSource();
ldapContextSource.setUrl(ldapUrl);
ldapContextSource.setBase(ldapBase);
ldapContextSource.setUserDn(ldapUser);
ldapContextSource.setPassword(ldapPwd);
return ldapContextSource;
}
示例10: getLdapContextSource
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
private LdapContextSource getLdapContextSource() throws Exception {
LdapContextSource cs = new LdapContextSource();
cs.setUrl(Config.getLdapUrl());
cs.setBase(Config.getLDAPBase());
cs.setUserDn(Config.getUserDN());
//cs.setAnonymousReadOnly(true);
Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.REFERRAL, "follow");
cs.setBaseEnvironmentProperties(env);
cs.setPassword(Config.getLdapPassword());
cs.afterPropertiesSet();
return cs;
}
示例11: contextSource
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
@Bean
public ContextSource contextSource() {
LdapContextSource ldapContextSource = new LdapContextSource();
ldapContextSource.setUrl("");
return ldapContextSource;
}
示例12: configureGlobal
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
public static void configureGlobal(AuthenticationManagerBuilder auth, LdapAuthServerConfig authCfg, PasswordEncoder passwordEncoder) throws Exception {
if (authCfg != null) {
LdapContextSource ldapCtx = new LdapContextSource();
ldapCtx.setUrl(authCfg.getLdapUrl());
ldapCtx.setUserDn(authCfg.getBindDn());
ldapCtx.setPassword(authCfg.getBindPassword());
Map<String, Object> baseEnv = new HashMap<String, Object>();
baseEnv.put(CONNECT_TIMEOUT_ENV, "" + authCfg.getConnectTimeout());
baseEnv.put(READ_TIMEOUT_ENV, "" + authCfg.getReadTimeout());
ldapCtx.setBaseEnvironmentProperties(baseEnv);
ldapCtx.afterPropertiesSet();
/** Have connections to LDAP be pooled */
LdapPoolingContextSourceAdapter pooling = new LdapPoolingContextSourceAdapter();
pooling.setDirContextValidator(new DefaultDirContextValidator());
pooling.setContextSource(ldapCtx);
pooling.setTestOnBorrow(true);
pooling.setTestWhileIdle(true);
auth
.ldapAuthentication()
.passwordEncoder(passwordEncoder)
.contextSource(pooling)
.userDnPatterns(authCfg.getUserDnPatterns())
.groupSearchBase(authCfg.getGroupSearchBase())
.groupSearchFilter(authCfg.getGroupFilter())
.and()
.eraseCredentials(false);
}
}
示例13: getLdapContextSource
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
private LdapContextSource getLdapContextSource() throws Exception {
LdapContextSource cs = new LdapContextSource();
cs.setUrl(Config.getLdapUrl());
cs.setBase("DC=nexus,DC=csiro,DC=au");
cs.setUserDn(Config.getUserDN());
Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.REFERRAL, "follow");
cs.setBaseEnvironmentProperties(env);
cs.setPassword(Config.getLdapPassword());
cs.afterPropertiesSet();
return cs;
}
示例14: 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;
}
示例15: ldapTemplate
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
@Bean
@ConditionalOnProperty("yona.ldap.enabled")
public LdapTemplate ldapTemplate()
{
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(yonaProperties.getLdap().getUrl());
contextSource.setBase(yonaProperties.getLdap().getBaseDn());
contextSource.setUserDn(yonaProperties.getLdap().getAccessUserDn());
contextSource.setPassword(yonaProperties.getLdap().getAccessUserPassword());
contextSource.afterPropertiesSet();
return new LdapTemplate(contextSource);
}