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


Java DefaultLdapAuthoritiesPopulator类代码示例

本文整理汇总了Java中org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator的典型用法代码示例。如果您正苦于以下问题:Java DefaultLdapAuthoritiesPopulator类的具体用法?Java DefaultLdapAuthoritiesPopulator怎么用?Java DefaultLdapAuthoritiesPopulator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DefaultLdapAuthoritiesPopulator类属于org.springframework.security.ldap.userdetails包,在下文中一共展示了DefaultLdapAuthoritiesPopulator类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: authoritiesPopulator

import org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator; //导入依赖的package包/类
@Bean
public LdapAuthoritiesPopulator authoritiesPopulator() {
    DefaultLdapAuthoritiesPopulator populator = new DefaultLdapAuthoritiesPopulator(
            contextSource(),
            configuration.getGroupSearchBase());
    populator.setGroupSearchFilter(configuration.getGroupSearchFilter());
    populator.setGroupRoleAttribute(configuration.getGroupRoleAttribute());
    populator.setSearchSubtree(true);
    populator.setRolePrefix("");
    return populator;
}
 
开发者ID:gravitee-io,项目名称:graviteeio-access-management,代码行数:12,代码来源:LdapAuthenticationProviderConfiguration.java

示例2: init

import org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator; //导入依赖的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});
}
 
开发者ID:Evolveum,项目名称:gizmo-v3,代码行数:18,代码来源:GizmoAuthProvider.java

示例3: ldapAuthoritiesPopulator

import org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator; //导入依赖的package包/类
@Bean
public LdapAuthoritiesPopulator ldapAuthoritiesPopulator() {
	DefaultLdapAuthoritiesPopulator populator = new DefaultLdapAuthoritiesPopulator(contextSource(), ldapValue.getGroupSearchBase());
	populator.setSearchSubtree(true);
	populator.setIgnorePartialResultException(true);
	return populator;
}
 
开发者ID:adessoAG,项目名称:JenkinsHue,代码行数:8,代码来源:LdapAuthentication.java

示例4: authoritiesPopulator

import org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator; //导入依赖的package包/类
@Bean
public LdapAuthoritiesPopulator authoritiesPopulator(){
    return new DefaultLdapAuthoritiesPopulator(contextSource(),
            "ou=Groups"){{
                setGroupSearchFilter("(uniqueMember={0})");
    }};
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:8,代码来源:SecurityConfig.java

示例5: osiamLdapAuthenticationProvider

import org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator; //导入依赖的package包/类
@Bean
public OsiamLdapAuthenticationProvider osiamLdapAuthenticationProvider() {
    return new OsiamLdapAuthenticationProvider(
            bindAuthenticator(),
            new DefaultLdapAuthoritiesPopulator(contextSource(), groupSearchBase),
            new OsiamLdapUserContextMapper(ldapToScimAttributeMapping()));
}
 
开发者ID:osiam,项目名称:auth-server,代码行数:8,代码来源:LdapAuthentication.java

示例6: getDefaultLdapAuthoritiesPopulator

import org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator; //导入依赖的package包/类
private DefaultLdapAuthoritiesPopulator getDefaultLdapAuthoritiesPopulator(
        LdapContextSource ldapContextSource) {
    DefaultLdapAuthoritiesPopulator defaultLdapAuthoritiesPopulator = new DefaultLdapAuthoritiesPopulator(
            ldapContextSource, ldapGroupSearchBase);
    defaultLdapAuthoritiesPopulator
            .setGroupRoleAttribute(ldapGroupRoleAttribute);
    defaultLdapAuthoritiesPopulator
            .setGroupSearchFilter(ldapGroupSearchFilter);
    defaultLdapAuthoritiesPopulator.setIgnorePartialResultException(true);
    return defaultLdapAuthoritiesPopulator;
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:12,代码来源:AtlasLdapAuthenticationProvider.java

示例7: osiamLdapAuthenticationProvider

import org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator; //导入依赖的package包/类
@Bean
@Autowired
public OsiamLdapAuthenticationProvider osiamLdapAuthenticationProvider(SCIMUserProvisioning userProvisioning,
                                                                       @Value("${osiam.ldap.sync-user-data:true}") boolean syncUserData) {
    return new OsiamLdapAuthenticationProvider(
            bindAuthenticator(),
            new DefaultLdapAuthoritiesPopulator(contextSource(), ""),
            new OsiamLdapUserContextMapper(ldapToScimAttributeMapping()),
            userProvisioning,
            syncUserData);
}
 
开发者ID:osiam,项目名称:osiam,代码行数:12,代码来源:LdapAuthentication.java

示例8: configure

import org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator; //导入依赖的package包/类
@Override
public SecurityConfigurer configure() throws Exception {
    LOGGER.info("Configuring an LDAP Identity Provider");

    LdapAuthenticationProviderConfigurer<AuthenticationManagerBuilder> ldapAuthenticationProviderConfigurer =
            new LdapAuthenticationProviderConfigurer<>();

    // Create LDAP context
    DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(
            environment.getProperty("context-source-url"));
    contextSource.setBase(environment.getProperty("context-source-base"));
    contextSource.setUserDn(environment.getProperty("context-source-username"));
    contextSource.setPassword(environment.getProperty("context-source-password"));
    contextSource.afterPropertiesSet();

    String userDNPattern = environment.getProperty("user-dn-pattern");
    if (userDNPattern == null || userDNPattern.isEmpty()) {
        ldapAuthenticationProviderConfigurer
                .userSearchBase(environment.getProperty("user-search-base"))
                .userSearchFilter(environment.getProperty("user-search-filter"));
    } else {
        ldapAuthenticationProviderConfigurer.userDnPatterns(userDNPattern);
    }

    ldapAuthenticationProviderConfigurer
            .groupSearchBase(environment.getProperty("group-search-base", ""))
            .groupSearchFilter(environment.getProperty("group-search-filter", "(uniqueMember={0})"))
            .groupRoleAttribute(environment.getProperty("group-role-attribute", "cn"))
            .rolePrefix("");

    DefaultLdapAuthoritiesPopulator populator = new DefaultLdapAuthoritiesPopulator(contextSource,
            environment.getProperty("group-search-base", ""));
    populator.setRolePrefix("");

    ldapAuthenticationProviderConfigurer.ldapAuthoritiesPopulator(populator).contextSource(contextSource);

    // set up LDAP mapper
    UserDetailsContextPropertiesMapper userDetailsContextPropertiesMapper = new UserDetailsContextPropertiesMapper();
    userDetailsContextPropertiesMapper.setEnvironment(environment);
    userDetailsContextPropertiesMapper.afterPropertiesSet();
    ldapAuthenticationProviderConfigurer.userDetailsContextMapper(userDetailsContextPropertiesMapper);

    return ldapAuthenticationProviderConfigurer;
}
 
开发者ID:gravitee-io,项目名称:gravitee-management-rest-api,代码行数:45,代码来源:LdapAuthenticationProvider.java

示例9: getLdapBindAuthentication

import org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator; //导入依赖的package包/类
private Authentication getLdapBindAuthentication(
        Authentication authentication) {
    try {
        if (isDebugEnabled) {
            LOG.debug("==> AtlasLdapAuthenticationProvider getLdapBindAuthentication");
        }
        String userName = authentication.getName();
        String userPassword = "";
        if (authentication.getCredentials() != null) {
            userPassword = authentication.getCredentials().toString();
        }

        LdapContextSource ldapContextSource = getLdapContextSource();

        DefaultLdapAuthoritiesPopulator defaultLdapAuthoritiesPopulator = getDefaultLdapAuthoritiesPopulator(ldapContextSource);

        if (ldapUserSearchFilter == null
                || ldapUserSearchFilter.trim().isEmpty()) {
            ldapUserSearchFilter = "(uid={0})";
        }

        FilterBasedLdapUserSearch userSearch = new FilterBasedLdapUserSearch(
                ldapBase, ldapUserSearchFilter, ldapContextSource);
        userSearch.setSearchSubtree(true);

        BindAuthenticator bindAuthenticator = getBindAuthenticator(
                userSearch, ldapContextSource);

        LdapAuthenticationProvider ldapAuthenticationProvider = new LdapAuthenticationProvider(
                bindAuthenticator, defaultLdapAuthoritiesPopulator);

        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("LDAP Authentication::userName or userPassword is null or empty for userName "
                    + userName);
        }
    } catch (Exception e) {
        LOG.error(" getLdapBindAuthentication LDAP Authentication Failed:", e);
    }
    if (isDebugEnabled) {
        LOG.debug("<== AtlasLdapAuthenticationProvider getLdapBindAuthentication");
    }
    return authentication;
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:57,代码来源:AtlasLdapAuthenticationProvider.java


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