org.springframework.security.crypto.password.LdapShaPasswordEncoder Java Examples
The following examples show how to use
org.springframework.security.crypto.password.LdapShaPasswordEncoder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebSecurityConfig.java From Spring-5.0-Projects with MIT License | 6 votes |
@Override protected void configure(AuthenticationManagerBuilder authManagerBuilder) throws Exception { authManagerBuilder.ldapAuthentication() .userDnPatterns(ldapAuthStructure.getUserDnPattern()) .userSearchBase(ldapAuthStructure.getUserSearchBase()) .contextSource() .url(ldapAuthStructure.getLdapUrl()+"/"+ldapAuthStructure.getLdapBase()) .managerDn(ldapAuthStructure.getLdapManagerDn()) .managerPassword(ldapAuthStructure.getLdapManagerPwd()) .and() .passwordCompare() .passwordEncoder(new LdapShaPasswordEncoder()) .passwordAttribute("userPassword"); logger.info("configure method is called to build Authentication manager ..."); }
Example #2
Source File: SecurityConfiguration.java From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
/** * 模拟数据库查询,判断尝试登陆用户是否满足认证条件 * * @param auth AuthenticationManagerBuilder * @throws Exception 异常 */ @Override protected void configure(final AuthenticationManagerBuilder auth) throws Exception { auth.ldapAuthentication() .userDnPatterns("uid={0},ou=users") .groupSearchBase("ou=users") .contextSource() .url("ldap://172.22.6.12:10389/dc=dunwu,dc=github,dc=io") .and() .passwordCompare() .passwordEncoder(new LdapShaPasswordEncoder()) .passwordAttribute("userPassword"); }
Example #3
Source File: LdapAuthenticationApplication.java From Spring with Apache License 2.0 | 5 votes |
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.ldapAuthentication().userDnPatterns("uid={0},ou=people") .groupSearchBase("ou=groups").contextSource() .url("ldap://localhost:8389/dc=springframework,dc=org").and() .passwordCompare().passwordEncoder(new LdapShaPasswordEncoder()) .passwordAttribute("userPassword"); }
Example #4
Source File: WebSecurityConfig.java From metron with Apache License 2.0 | 4 votes |
@Autowired public void configureJdbc(AuthenticationManagerBuilder auth) throws Exception { // Note that we can switch profiles on the fly in Ambari. List<String> activeProfiles = Arrays.asList(environment.getActiveProfiles()); if (activeProfiles.contains(MetronRestConstants.LDAP_PROFILE)) { LOG.info("Setting up LDAP authentication; url={}.", providerUrl); LdapAuthenticationProviderConfigurer providerConf = auth .ldapAuthentication() .authoritiesMapper(authoritiesMapper) .userDnPatterns(userDnPatterns) .userSearchBase(userSearchBase) .userSearchFilter(userSearchFilter) .groupRoleAttribute(groupRoleAttribute) .groupSearchFilter(groupSearchFilter) .groupSearchBase(groupSearchBase) .contextSource() .url(providerUrl) .managerDn(providerUserDn) .managerPassword(providerPassword) .and(); if(StringUtils.isNotBlank(passwordAttribute)) { // if a password attribute is provided, use that for authentication providerConf .passwordCompare() .passwordEncoder(new LdapShaPasswordEncoder()) .passwordAttribute(passwordAttribute); } else { // if no password attribute, set encoder to null which forces bind authentication providerConf .passwordCompare() .passwordEncoder(null); } } else if (activeProfiles.contains(MetronRestConstants.DEV_PROFILE) || activeProfiles.contains(MetronRestConstants.TEST_PROFILE)) { LOG.info("Setting up JDBC authentication with dev/test profiles"); auth.jdbcAuthentication() .dataSource(dataSource) .withUser("user").password("password").roles(SECURITY_ROLE_USER).and() .withUser("user1").password("password").roles(SECURITY_ROLE_USER).and() .withUser("user2").password("password").roles(SECURITY_ROLE_USER).and() .withUser("admin").password("password").roles(SECURITY_ROLE_USER, SECURITY_ROLE_ADMIN); } else { LOG.debug("Setting up JDBC authentication"); auth.jdbcAuthentication().dataSource(dataSource); } }