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


Java LdapContextSource.setReferral方法代码示例

本文整理汇总了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;
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:42,代码来源:LdapPluginResource.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:13,代码来源:AtlasLdapAuthenticationProvider.java

示例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;
     }
 }
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:52,代码来源:AtlasADAuthenticationProvider.java


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