fix[litemall-wx-api,litemall-admin-api]: 采用spring-security的BCryptPasswordEncoder来对用户和管理员密码加密。目前存在问题是,两个模块使用了两次代码。之后可能会实现一个新的litemall-util模块来存放通用类。

This commit is contained in:
Junling Bu
2018-04-06 14:15:33 +08:00
parent 3e672d4747
commit 62964b8be5
9 changed files with 1596 additions and 9 deletions

View File

@@ -0,0 +1,25 @@
package org.linlinjava.litemall.admin;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.linlinjava.litemall.admin.util.bcrypt.BCryptPasswordEncoder;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class BcryptTest {
@Test
public void test() {
String rawPassword = "aaaaaa";
String encodedPassword ="";
BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
encodedPassword = bCryptPasswordEncoder.encode(rawPassword);
System.out.println("rawPassword=" + rawPassword + " encodedPassword=" + encodedPassword);
Assert.assertTrue(bCryptPasswordEncoder.matches(rawPassword, encodedPassword));
}
}