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


Java ShaPasswordEncoder.encodePassword方法代码示例

本文整理汇总了Java中org.springframework.security.authentication.encoding.ShaPasswordEncoder.encodePassword方法的典型用法代码示例。如果您正苦于以下问题:Java ShaPasswordEncoder.encodePassword方法的具体用法?Java ShaPasswordEncoder.encodePassword怎么用?Java ShaPasswordEncoder.encodePassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.security.authentication.encoding.ShaPasswordEncoder的用法示例。


在下文中一共展示了ShaPasswordEncoder.encodePassword方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入方法依赖的package包/类
static public void main(String[] args ) {
	if (args == null || args.length != 2) {
		System.out.println("Please use: EssencePasswordEncoderSHA username password");
		System.exit(1);
	}
	ShaPasswordEncoder encoder = new ShaPasswordEncoder(256);
	String hash = encoder.encodePassword(args[1], args[0]); // pwd, salt
	System.out.println("Encoded password for " + args[0] + "/" + args[1] + " is: " + hash);
}
 
开发者ID:dpinney,项目名称:essence,代码行数:10,代码来源:EssencePasswordEncoderSHA.java

示例2: main

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入方法依赖的package包/类
public static void main(String[] args) {
	ShaPasswordEncoder enc = new ShaPasswordEncoder(512);
	enc.setIterations(1000);
	enc.setEncodeHashAsBase64(true);
	String encodedPass = enc.encodePassword("nesa", "nesa");
	System.out.println(encodedPass);
	System.out.println(enc.isPasswordValid(encodedPass, "nesa", "nesa"));
}
 
开发者ID:PacktPublishing,项目名称:Spring-MVC-Blueprints,代码行数:9,代码来源:CartPasswordEncoder.java

示例3: testSha

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入方法依赖的package包/类
@SuppressWarnings("unused")
static private void testSha() {
	ShaPasswordEncoder encoder = new ShaPasswordEncoder();
	String hash = encoder.encodePassword("test1", "test1"); // pwd, salt
	System.out.println("test1:" + hash);
	System.out.println("test2:" + encoder.encodePassword("test2", "test2"));
	
	ShaPasswordEncoder encoder1 = new ShaPasswordEncoder(256);
	String hash1 = encoder1.encodePassword("test1", "test1"); // pwd, salt
	System.out.println("test1-256:" + hash1);
}
 
开发者ID:dpinney,项目名称:essence,代码行数:12,代码来源:PasswordEncoderTest.java

示例4: authenticate

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入方法依赖的package包/类
@Override
public User authenticate(String username, String password) {
    // get user by username
    User user = userDao.getByUsername(username);
    if (user != null) {
        ShaPasswordEncoder pwdEnc = new ShaPasswordEncoder();
        String pwd = pwdEnc.encodePassword(password, user.getSalt());
        if (pwd.equals(user.getPassword())) {
            return user;
        }
    }
    return null;
}
 
开发者ID:bernfried,项目名称:SimplePRP,代码行数:14,代码来源:UserServiceImpl.java

示例5: encode

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入方法依赖的package包/类
public static String encode(String password) {
    ShaPasswordEncoder encoder = new ShaPasswordEncoder(256);
    String encodedPassword = encoder.encodePassword(password, null);
    return encodedPassword;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:6,代码来源:Sha256PasswordEncoderMain.java

示例6: create

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入方法依赖的package包/类
/**
 * Create user detail with given username and encrypted given password.
 *
 * @param username username
 * @param password plain text password
 * @return user detail
 */
public static UserDetails create(String username, String password) {
    final ShaPasswordEncoder encoder = new ShaPasswordEncoder(256);
    final String hashedPassword = encoder.encodePassword(password, username);
    return new UserDetailsImpl(username, hashedPassword);
}
 
开发者ID:dzolo,项目名称:wildfly-arquillian-spring-security,代码行数:13,代码来源:UserDetailsBuilder.java


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