本文整理汇总了Java中org.springframework.ldap.core.support.LdapContextSource.setReferral方法的典型用法代码示例。如果您正苦于以下问题:Java LdapContextSource.setReferral方法的具体用法?Java LdapContextSource.setReferral怎么用?Java LdapContextSource.setReferral使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.ldap.core.support.LdapContextSource
的用法示例。
在下文中一共展示了LdapContextSource.setReferral方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
}