• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java LdapShaPasswordEncoder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: configureGlobal

import org.springframework.security.authentication.encoding.LdapShaPasswordEncoder; //导入依赖的package包/类
/**
 * Configures the {@link org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder} for LDAP authentication.
 * @param auth the {@link org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder} used to configure LDAP authenticaton.
 * @throws Exception if an error occurs when adding the LDAP authentication.
 */
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception{
    auth
            .ldapAuthentication()
                .userDnPatterns("uid={0},ou=managers")
                .groupSearchBase("ou=managers")
                .contextSource(contextSource())
                .passwordCompare()
                    .passwordEncoder(new LdapShaPasswordEncoder())
                    .passwordAttribute("userPassword");
 }
 
开发者ID:Chrams,项目名称:openfleet,代码行数:17,代码来源:WebSecurityConfig.java


示例2: configure

import org.springframework.security.authentication.encoding.LdapShaPasswordEncoder; //导入依赖的package包/类
/**
     * Configure AuthenticationManager with inMemory credentials.
     *
     * NOTE:
     * Due to a known limitation with JavaConfig:
     * <a href="https://jira.spring.io/browse/SPR-13779">
     *     https://jira.spring.io/browse/SPR-13779</a>
     *
     * We cannot use the following to expose a {@link UserDetailsManager}
     * <pre>
     *     http.authorizeRequests()
     * </pre>
     *
     * In order to expose {@link UserDetailsManager} as a bean, we must create  @Bean
     *
     * @see {@link super.userDetailsService()}
     * @see {@link com.packtpub.springsecurity.service.DefaultCalendarService}
     *
     * @param auth       AuthenticationManagerBuilder
     * @throws Exception Authentication exception
     */
    @Override
    public void configure(final AuthenticationManagerBuilder auth) throws Exception {
        auth
                .ldapAuthentication()
                .userSearchBase("")
                .userSearchFilter("(uid={0})")
                .groupSearchBase("ou=Groups")
                .groupSearchFilter("(uniqueMember={0})")
                .userDetailsContextMapper(new InetOrgPersonContextMapper())
                .contextSource(contextSource())
//                .contextSource()
//                    .managerDn("uid=admin,ou=system")
//                    .managerPassword("secret")
//                    .url("ldap://localhost:33389/dc=jbcpcalendar,dc=com")
//                    .root("dc=jbcpcalendar,dc=com")
//                    .ldif("classpath:/ldif/calendar.ldif")
//                .and()
                    .passwordCompare()
                    // Supports {SHA} and {SSHA}
                    .passwordEncoder(new LdapShaPasswordEncoder())
                    .passwordAttribute("userPassword")
        ;
    }
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:45,代码来源:SecurityConfig.java


示例3: testSsha

import org.springframework.security.authentication.encoding.LdapShaPasswordEncoder; //导入依赖的package包/类
@Test
public void testSsha(){
	LdapShaPasswordEncoder encoder = new LdapShaPasswordEncoder();
	
	String rawPass = "test";
	String salt = "@#%AS%&DF_=PJ}{EB23+42342*()*^%$)_(*%^)";
	String res = encoder.encodePassword(rawPass, salt.getBytes());
	System.out.println("res:"+res);
	boolean valid = encoder.isPasswordValid(res, rawPass, "[email protected]#[email protected]");
	Assert.assertTrue(valid);
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:12,代码来源:PasswordEncoderTest.java


示例4: LDAPAuthenticator

import org.springframework.security.authentication.encoding.LdapShaPasswordEncoder; //导入依赖的package包/类
/**
 * Default constructor.
 * @param ldapSettings LDAP config map for an app
 */
public LDAPAuthenticator(Map<String, String> ldapSettings) {
	if (ldapSettings != null && ldapSettings.containsKey("security.ldap.server_url")) {
		String serverUrl = ldapSettings.get("security.ldap.server_url");
		String baseDN = ldapSettings.get("security.ldap.base_dn");
		String bindDN = ldapSettings.get("security.ldap.bind_dn");
		String basePass = ldapSettings.get("security.ldap.bind_pass");
		String searchBase = ldapSettings.get("security.ldap.user_search_base");
		String searchFilter = ldapSettings.get("security.ldap.user_search_filter");
		String dnPattern = ldapSettings.get("security.ldap.user_dn_pattern");
		String passAttribute = ldapSettings.get("security.ldap.password_attribute");
		boolean usePasswordComparison = ldapSettings.containsKey("security.ldap.compare_passwords");

		DefaultSpringSecurityContextSource contextSource =
				new DefaultSpringSecurityContextSource(Arrays.asList(serverUrl), baseDN);
		contextSource.setAuthenticationSource(new SpringSecurityAuthenticationSource());
		contextSource.setCacheEnvironmentProperties(false);
		if (!bindDN.isEmpty()) {
			contextSource.setUserDn(bindDN);
		}
		if (!basePass.isEmpty()) {
			contextSource.setPassword(basePass);
		}
		LdapUserSearch userSearch = new FilterBasedLdapUserSearch(searchBase, searchFilter, contextSource);

		if (usePasswordComparison) {
			PasswordComparisonAuthenticator p = new PasswordComparisonAuthenticator(contextSource);
			p.setPasswordAttributeName(passAttribute);
			p.setPasswordEncoder(new LdapShaPasswordEncoder());
			p.setUserDnPatterns(new String[]{dnPattern});
			p.setUserSearch(userSearch);
			authenticator = p;
		} else {
			BindAuthenticator b = new BindAuthenticator(contextSource);
			b.setUserDnPatterns(new String[]{dnPattern});
			b.setUserSearch(userSearch);
			authenticator = b;
		}
	}
}
 
开发者ID:Erudika,项目名称:para,代码行数:44,代码来源:LDAPAuthenticator.java


示例5: configure

import org.springframework.security.authentication.encoding.LdapShaPasswordEncoder; //导入依赖的package包/类
/**
     * Configure AuthenticationManager with inMemory credentials.
     *
     * NOTE:
     * Due to a known limitation with JavaConfig:
     * <a href="https://jira.spring.io/browse/SPR-13779">
     *     https://jira.spring.io/browse/SPR-13779</a>
     *
     * We cannot use the following to expose a {@link UserDetailsManager}
     * <pre>
     *     http.authorizeRequests()
     * </pre>
     *
     * In order to expose {@link UserDetailsManager} as a bean, we must create  @Bean
     *
     * @see {@link super.userDetailsService()}
     * @see {@link com.packtpub.springsecurity.service.DefaultCalendarService}
     *
     * @param auth       AuthenticationManagerBuilder
     * @throws Exception Authentication exception
     */
    @Override
    public void configure(final AuthenticationManagerBuilder auth) throws Exception {
        auth
                .ldapAuthentication()
//                .ldapAuthoritiesPopulator(ldapAuthoritiesPopulator())
                .userSearchBase("")
                .userSearchFilter("(uid={0})")
                .groupSearchBase("ou=Groups")
                .groupSearchFilter("(uniqueMember={0})")
//                .userDetailsContextMapper(new InetOrgPersonContextMapper())
                .contextSource(contextSource())
                .passwordCompare()
                    // Supports {SHA} and {SSHA}
                    .passwordEncoder(new LdapShaPasswordEncoder())
                    .passwordAttribute("userPassword")
        ;
        /*
        <ldap-authentication-provider server-ref="ldapServer"
        user-search-filter="(uid={0})"
        group-search-base="ou=Groups"
        user-details-class="inetOrgPerson">


    <bean id="ldapAuthenticationProvider"
            class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
        <constructor-arg ref="ldapBindAuthenticator"/>
        <constructor-arg ref="ldapAuthoritiesPopulator"/>
        <property name="userDetailsContextMapper" ref="ldapUserDetailsContextMapper"/>
    </bean>

    <bean id="ldapBindAuthenticator"
            class="org.springframework.security.ldap.authentication.BindAuthenticator">
        <constructor-arg ref="ldapServer"/>
        <property name="userSearch" ref="ldapSearch"/>
    </bean>

//    <bean id="ldapSearch"
//            class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
//        <constructor-arg value=""/> <!-- use-search-base -->
//        <constructor-arg value="(uid={0})"/> <!-- user-search-filter -->
//        <constructor-arg ref="ldapServer"/>
//    </bean>

//    <bean id="ldapAuthoritiesPopulator"
//            class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator">
//        <constructor-arg ref="ldapServer"/>
//        <constructor-arg value="ou=Groups"/>
//        <property name="groupSearchFilter" value="(uniqueMember={0})"/>
//    </bean>

         */
    }
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:74,代码来源:SecurityConfig.java


示例6: configure

import org.springframework.security.authentication.encoding.LdapShaPasswordEncoder; //导入依赖的package包/类
/**
 * Configure AuthenticationManager with inMemory credentials.
 *
 * NOTE:
 * Due to a known limitation with JavaConfig:
 * <a href="https://jira.spring.io/browse/SPR-13779">
 *     https://jira.spring.io/browse/SPR-13779</a>
 *
 * We cannot use the following to expose a {@link UserDetailsManager}
 * <pre>
 *     http.authorizeRequests()
 * </pre>
 *
 * In order to expose {@link UserDetailsManager} as a bean, we must create  @Bean
 *
 * @see {@link super.userDetailsService()}
 * @see {@link com.packtpub.springsecurity.service.DefaultCalendarService}
 *
 * @param auth       AuthenticationManagerBuilder
 * @throws Exception Authentication exception
 */
@Override
public void configure(final AuthenticationManagerBuilder auth) throws Exception {
    auth
            .ldapAuthentication()
            .userSearchBase("")
            .userSearchFilter("(uid={0})")
            .groupSearchBase("ou=Groups")
            .groupSearchFilter("(uniqueMember={0})")
            .userDetailsContextMapper(new InetOrgPersonContextMapper())
            .contextSource(contextSource())
            .passwordCompare()
                // Supports {SHA} and {SSHA}
                .passwordEncoder(new LdapShaPasswordEncoder())
                .passwordAttribute("userPassword")
    ;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:38,代码来源:SecurityConfig.java


示例7: generateSaltedPassword

import org.springframework.security.authentication.encoding.LdapShaPasswordEncoder; //导入依赖的package包/类
private static String generateSaltedPassword(String vpnPassword)
{
	LdapShaPasswordEncoder ldapShaPasswordEncoder = new LdapShaPasswordEncoder();
	return ldapShaPasswordEncoder.encodePassword(vpnPassword, CryptoUtil.getRandomBytes(64));
}
 
开发者ID:yonadev,项目名称:yona-server,代码行数:6,代码来源:LDAPUserService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PSVIDocumentImpl类代码示例发布时间:2022-05-23
下一篇:
Java HeaderList类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap