本文整理汇总了Java中org.springframework.ldap.core.support.LdapContextSource.setPassword方法的典型用法代码示例。如果您正苦于以下问题:Java LdapContextSource.setPassword方法的具体用法?Java LdapContextSource.setPassword怎么用?Java LdapContextSource.setPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.ldap.core.support.LdapContextSource
的用法示例。
在下文中一共展示了LdapContextSource.setPassword方法的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: init
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
@PostConstruct
protected void init() {
if (webLdapConfig.getLdapEnabled()) {
ldapContextSource = new LdapContextSource();
checkRequiredConfigProperties(webLdapConfig);
ldapContextSource.setBase(webLdapConfig.getLdapBase());
List<String> ldapUrls = webLdapConfig.getLdapUrls();
ldapContextSource.setUrls(ldapUrls.toArray(new String[ldapUrls.size()]));
ldapContextSource.setUserDn(webLdapConfig.getLdapUser());
ldapContextSource.setPassword(webLdapConfig.getLdapPassword());
ldapContextSource.afterPropertiesSet();
ldapTemplate = new LdapTemplate(ldapContextSource);
ldapTemplate.setIgnorePartialResultException(true);
}
}
示例5: init
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
@Override
public void init(FilterConfig filterConfig) throws ServletException {
ldapContextSource = new LdapContextSource();
checkRequiredConfigProperties(webLdapConfig);
ldapContextSource.setBase(webLdapConfig.getLdapBase());
List<String> ldapUrls = webLdapConfig.getLdapUrls();
ldapContextSource.setUrls(ldapUrls.toArray(new String[ldapUrls.size()]));
ldapContextSource.setUserDn(webLdapConfig.getLdapUser());
ldapContextSource.setPassword(webLdapConfig.getLdapPassword());
ldapContextSource.afterPropertiesSet();
ldapTemplate = new LdapTemplate(ldapContextSource);
ldapTemplate.setIgnorePartialResultException(true);
}
示例6: 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();
}
示例7: LdapCredentialsAuthenticator
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
/**
* This constructor creates a LdapCredentialsAuthenticator that authenticates against an LDAP server
* that does not support 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
* @param userDn the distinguished name for the connection
* @param password the password for the connection
*/
public LdapCredentialsAuthenticator(final String ldapHost,
final int ldapPort,
final String usersOuPath,
final String userDn,
final String password) {
Assert.hasText(ldapHost, "Invalid ldapHost");
Assert.isTrue(ldapPort > 0);
Assert.hasText(usersOuPath, "Invalid usersOuPath");
Assert.hasText(userDn, "Invalid userDn");
Assert.hasText(password, "Invalid password");
final LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl("ldap://" + ldapHost + ":" + ldapPort);
contextSource.setBase(usersOuPath);
contextSource.setUserDn(userDn);
contextSource.setPassword(password);
contextSource.afterPropertiesSet();
ldapTemplate = new LdapTemplate(contextSource);
this.id = calculateId(ldapHost, ldapPort, usersOuPath);
}
示例8: 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 ();
}
示例9: init
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
public void init() throws Exception {
if (!useLdapAuth()) {
return;
}
LdapContextSource contextSource = new DefaultSpringSecurityContextSource(ldapHost);
contextSource.setUserDn(ldapUsername);
contextSource.setPassword(ldapPassword);
contextSource.afterPropertiesSet();
DefaultLdapAuthoritiesPopulator ldapAuthoritiesPopulator =
new DefaultLdapAuthoritiesPopulator(contextSource, ldapGroupSearchBase);
ldapAuthoritiesPopulator.setGroupRoleAttribute(ldapGroupRoleAttribute);
ldapAuthoritiesPopulator.setGroupSearchFilter(ldapGroupSearchFilter);
ldapBindAuthenticator = new SimpleBindAunthenticator(contextSource, gizmoGroup);
ldapBindAuthenticator.setUserDnPatterns(new String[]{userDnPattern});
}
示例10: 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;
}
示例11: 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;
}
示例12: 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;
}
示例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(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;
}
示例14: createLdapContextSource
import org.springframework.ldap.core.support.LdapContextSource; //导入方法依赖的package包/类
protected LdapContextSource createLdapContextSource(RestLdapConfig ldapConfig) {
LdapContextSource ldapContextSource = new LdapContextSource();
ldapContextSource.setBase(ldapConfig.getLdapBase());
List<String> ldapUrls = ldapConfig.getLdapUrls();
ldapContextSource.setUrls(ldapUrls.toArray(new String[ldapUrls.size()]));
ldapContextSource.setUserDn(ldapConfig.getLdapUser());
ldapContextSource.setPassword(ldapConfig.getLdapPassword());
ldapContextSource.afterPropertiesSet();
return ldapContextSource;
}
示例15: 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;
}