Examples of LDAPAuthenticationProvider


Examples of org.acegisecurity.providers.ldap.LdapAuthenticationProvider

                groupSearchBase);
          String groupRoleAttribute = "ou";
          authoritiesPopulator.setGroupRoleAttribute(groupRoleAttribute);
           
            System.out.println("***********************************");
          LdapAuthenticationProvider ldapAuthenticationProvider =
            new LdapAuthenticationProvider(authenticator, authoritiesPopulator);
          LdapUserInfo user = authenticator.authenticate(userDetails.getUsername(),
              (String)authentication.getCredentials());
          if (user != null) {
              UserDetails u = ldapAuthenticationProvider.retrieveUser(userDetails.getUsername(),
                  authentication);         
              System.out.println("user " + u);
          }
          else {         
              throw new BadCredentialsException(messages.getMessage(
View Full Code Here

Examples of org.geoserver.security.ldap.LDAPAuthenticationProvider

                            error("Neither user dn pattern or user filter specified");
                            return;
                        }
                       
                        LDAPSecurityProvider provider = new LDAPSecurityProvider(getSecurityManager());
                        LDAPAuthenticationProvider authProvider = (LDAPAuthenticationProvider) provider
                                .createAuthenticationProvider(ldapConfig);
                        Authentication authentication = authProvider
                                .authenticate(new UsernamePasswordAuthenticationToken(
                                        username, password));
                        if(authentication == null || !authentication.isAuthenticated()) {
                            throw new AuthenticationException("Cannot authenticate " + username);
                        }
View Full Code Here

Examples of org.springframework.security.ldap.authentication.LdapAuthenticationProvider

        BaseLdapPathContextSource contextSource = getContextSource();
        LdapAuthenticator ldapAuthenticator = createLdapAuthenticator(contextSource);

        LdapAuthoritiesPopulator authoritiesPopulator = getLdapAuthoritiesPopulator();

        LdapAuthenticationProvider ldapAuthenticationProvider = new LdapAuthenticationProvider(
                ldapAuthenticator, authoritiesPopulator);
        SimpleAuthorityMapper simpleAuthorityMapper = new SimpleAuthorityMapper();
        simpleAuthorityMapper.setPrefix(rolePrefix);
        simpleAuthorityMapper.afterPropertiesSet();
        ldapAuthenticationProvider.setAuthoritiesMapper(simpleAuthorityMapper);
        if(userDetailsContextMapper != null) {
            ldapAuthenticationProvider.setUserDetailsContextMapper(userDetailsContextMapper);
        }
        return ldapAuthenticationProvider;
    }
View Full Code Here

Examples of org.springframework.security.ldap.authentication.LdapAuthenticationProvider

        return this;
    }

    @Override
    public void configure(B builder) throws Exception {
        LdapAuthenticationProvider provider = postProcess(build());
        builder.authenticationProvider(provider);
    }
View Full Code Here

Examples of org.springframework.security.ldap.authentication.LdapAuthenticationProvider

      FilterBasedLdapUserSearch userSearch = new FilterBasedLdapUserSearch(userSearchBase, userSearchFilter, springSecurityContextSource);

      BindAuthenticator bindAuthenticator = new BindAuthenticator(springSecurityContextSource);
      bindAuthenticator.setUserSearch(userSearch);

      LdapAuthenticationProvider authenticationProvider = new LdapAuthenticationProvider(bindAuthenticator, authoritiesPopulator);

      providerThreadLocal.set(authenticationProvider);
    }

    return providerThreadLocal.get();
View Full Code Here

Examples of org.springframework.security.ldap.authentication.LdapAuthenticationProvider

      FilterBasedLdapUserSearch userSearch = new FilterBasedLdapUserSearch(userSearchBase, userSearchFilter, springSecurityContextSource);

      AmbariLdapBindAuthenticator bindAuthenticator = new AmbariLdapBindAuthenticator(springSecurityContextSource, configuration);
      bindAuthenticator.setUserSearch(userSearch);

      LdapAuthenticationProvider authenticationProvider = new LdapAuthenticationProvider(bindAuthenticator, authoritiesPopulator);

      providerThreadLocal.set(authenticationProvider);
    }

    return providerThreadLocal.get();
View Full Code Here

Examples of org.springframework.security.ldap.authentication.LdapAuthenticationProvider

      FilterBasedLdapUserSearch userSearch = new FilterBasedLdapUserSearch(userSearchBase, userSearchFilter, springSecurityContextSource);

      AmbariLdapBindAuthenticator bindAuthenticator = new AmbariLdapBindAuthenticator(springSecurityContextSource, configuration);
      bindAuthenticator.setUserSearch(userSearch);

      LdapAuthenticationProvider authenticationProvider = new LdapAuthenticationProvider(bindAuthenticator, authoritiesPopulator);

      providerThreadLocal.set(authenticationProvider);
    }

    return providerThreadLocal.get();
View Full Code Here

Examples of org.springframework.security.ldap.authentication.LdapAuthenticationProvider

        DefaultLdapAuthoritiesPopulator authoritiesPopulator = new DefaultLdapAuthoritiesPopulator(
                contextSource, groupSearchBase);
        authoritiesPopulator.setGroupRoleAttribute(groupRoleAttribute);
        authoritiesPopulator.setGroupSearchFilter(groupSearchFilter);

        LdapAuthenticationProvider ldapAuthenticationProvider = new LdapAuthenticationProvider(
                ldapAuthenticator, authoritiesPopulator);
        SimpleAuthorityMapper simpleAuthorityMapper = new SimpleAuthorityMapper();
        simpleAuthorityMapper.setPrefix(rolePrefix);
        simpleAuthorityMapper.afterPropertiesSet();
        ldapAuthenticationProvider.setAuthoritiesMapper(simpleAuthorityMapper);
        if(userDetailsContextMapper != null) {
            ldapAuthenticationProvider.setUserDetailsContextMapper(userDetailsContextMapper);
        }
        return ldapAuthenticationProvider;
    }
View Full Code Here

Examples of org.springframework.security.ldap.authentication.LdapAuthenticationProvider

        return this;
    }

    @Override
    public void configure(B builder) throws Exception {
        LdapAuthenticationProvider provider = postProcess(build());
        builder.authenticationProvider(provider);
    }
View Full Code Here

Examples of org.springframework.security.ldap.authentication.LdapAuthenticationProvider

            authenticator.setUserDnPatterns(new String[] { ldapConfig
                    .getUserDnPattern() });
        }

        LdapAuthoritiesPopulator authPopulator = null;
        LdapAuthenticationProvider provider = null;
        String ugServiceName = ldapConfig.getUserGroupServiceName();
        if (ugServiceName != null) {
            // use local user group service for loading authorities
            GeoServerUserGroupService ugService;
            try {
                ugService = securityManager.loadUserGroupService(ugServiceName);
                authPopulator = new UserDetailsServiceLdapAuthoritiesPopulator(
                        ugService);
                provider = new LdapAuthenticationProvider(authenticator,
                        authPopulator);
            } catch (IOException e) {
                LOGGER.log(Level.SEVERE, String.format(
                        "Unable to load user group service '%s', "
                                + "will use LDAP server for calculating roles",
                        ugServiceName), e);
            }
        }

        if (authPopulator == null) {
            // fall back to looking up roles via LDAP server, choosing
            // between default and binding populator
            if (ldapConfig.isBindBeforeGroupSearch()) {
                authPopulator = new BindingLdapAuthoritiesPopulator(
                        ldapContext, ldapConfig.getGroupSearchBase());
                if (ldapConfig.getGroupSearchFilter() != null) {
                    ((BindingLdapAuthoritiesPopulator) authPopulator)
                            .setGroupSearchFilter(ldapConfig
                                    .getGroupSearchFilter());
                }
                provider = new LdapAuthenticationProvider(authenticator,
                        authPopulator) {
                    /**
                     * We need to give authoritiesPopulator both username and
                     * password, so it can bind to the LDAP server. We encode
                     * them in the username:password format.
                     */
                    @Override
                    protected Collection<? extends GrantedAuthority> loadUserAuthorities(
                            DirContextOperations userData, String username,
                            String password) {
                        return getAuthoritiesPopulator().getGrantedAuthorities(
                                userData, username + ":" + password);
                    }
                };
            } else {
                authPopulator = new DefaultLdapAuthoritiesPopulator(
                        ldapContext, ldapConfig.getGroupSearchBase());

                if (ldapConfig.getGroupSearchFilter() != null) {
                    ((DefaultLdapAuthoritiesPopulator) authPopulator)
                            .setGroupSearchFilter(ldapConfig
                                    .getGroupSearchFilter());
                }
                provider = new LdapAuthenticationProvider(authenticator,
                        authPopulator);
            }

        }

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.