本文整理汇总了Java中org.springframework.security.authentication.encoding.Md5PasswordEncoder类的典型用法代码示例。如果您正苦于以下问题:Java Md5PasswordEncoder类的具体用法?Java Md5PasswordEncoder怎么用?Java Md5PasswordEncoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Md5PasswordEncoder类属于org.springframework.security.authentication.encoding包,在下文中一共展示了Md5PasswordEncoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTeams
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入依赖的package包/类
public void createTeams(Team team) {
for (int i = 0; i < team.getTotal(); i++) {
String username = buildteamUsername(team.getUsername(),
team.getTotal(), i + 1);
String nick = buildteamUsername(team.getNick(), team.getTotal(),
i + 1);
Md5PasswordEncoder md5 = new Md5PasswordEncoder();
Team add = new Team(username, md5.encodePassword(
team.getPassword(), "ABC123XYZ789"), nick,
team.getCountry(), team.getInstitution(), team.getLocale());
add.setUpdate_nick(team.isUpdate_nick());
insertTeam(add);
if (team.getContest() > 0) {
insertUserContest(add.getUid(), team.getContest(),
team.getGroup());
}
}
}
示例2: main
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入依赖的package包/类
public static void main(String[] args) {
String test = "asdf";
String password = "asdfasdf";
try {
DESPlus des = new DESPlus();
String miwen = des.encrypt(test);
System.out.println("加密后的字符:" + miwen);
DESPlus des1 = new DESPlus();
System.out.println("解密后的字符:" + des1.decrypt(miwen));
String password_miwen = des.encrypt(password);
System.out.println("密码加密后的字符:" + password_miwen);
DESPlus password_des1 = new DESPlus();
System.out.println("密码解密后的字符:" + password_des1.decrypt("asdfasdfasdf"));
} catch (Exception e) {
e.printStackTrace();
}
Md5PasswordEncoder mp = new Md5PasswordEncoder();
mp.encodePassword("000000", null);
System.out.println(mp.encodePassword("111111", null));
}
示例3: md5PasswordEncoder
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入依赖的package包/类
@Bean
public Md5PasswordEncoder md5PasswordEncoder(){
Md5PasswordEncoder md5 = new Md5PasswordEncoder();
md5.setEncodeHashAsBase64(true);
md5.setIterations(32);
return md5;
}
示例4: md5Encoder
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入依赖的package包/类
public String md5Encoder(String password, String salt) {
Md5PasswordEncoder md5PasswordEncoder = new Md5PasswordEncoder();
md5PasswordEncoder.setEncodeHashAsBase64(true);
md5PasswordEncoder.setIterations(32);
String encoded = md5PasswordEncoder.encodePassword(password,salt);
return encoded;
}
示例5: md5EncodePassword
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入依赖的package包/类
/**
*
* 以“用户名+密码”为加密对象,进行MD5加密
* @param password
* @param userName
* @return
*/
public static String md5EncodePassword(String password, String userName)
{
Md5PasswordEncoder md5 = new Md5PasswordEncoder();
md5.setEncodeHashAsBase64(false);
String encodedPassword = md5.encodePassword(password, userName);
return encodedPassword;
}
示例6: saveUser
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入依赖的package包/类
public boolean saveUser(User user) {
jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "INSERT INTO users(UserName, FirstName, LastName, Email, Password) VALUES(?,?,?,?,?)";
//this will change setMd5Encoder()
Md5PasswordEncoder passwordEncoder = new Md5PasswordEncoder();
String hashedPassword = passwordEncoder.encodePassword(user.getPassword(), null);
Object[] args =new Object[]{user.getUserName(), user.getFirstName(), user.getLastName(), user.getEmail(), hashedPassword};
int result = jdbcTemplate.update(sql, args);
if(result != 0){
return true;
} else {
return false;
}
}
示例7: basicPasswordAuthProvider
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入依赖的package包/类
@Bean
AuthenticationProvider basicPasswordAuthProvider() {
BasicPasswordAuthenticationProvider provider = new BasicPasswordAuthenticationProvider();
provider.setUserDetailsService(userDetailsService());
provider.setPasswordEncoder(new Md5PasswordEncoder());
return provider;
}
示例8: createActivationToken
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入依赖的package包/类
public String createActivationToken(User user, Boolean save) {
Md5PasswordEncoder encoder = new Md5PasswordEncoder();
String activationToken = encoder.encodePassword(user.getUserName(), applicationSecret);
if (save) {
user.setToken(activationToken);
this.userRepository.save(user);
}
return activationToken;
}
示例9: createResetPasswordToken
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入依赖的package包/类
public String createResetPasswordToken(User user, Boolean save) {
Md5PasswordEncoder encoder = new Md5PasswordEncoder();
String resetToken = encoder.encodePassword(user.getEmail(), applicationSecret);
if (save) {
user.setToken(resetToken);
this.userRepository.save(user);
}
return resetToken;
}
示例10: testSpringPasswordEncoderInstance
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入依赖的package包/类
@Test
public void testSpringPasswordEncoderInstance() {
PasswordEncoder passwordEncoder = autoWiredIdmIdmEngineConfiguration.getPasswordEncoder();
autoWiredIdmIdmEngineConfiguration.setPasswordEncoder(new SpringEncoder(new Md5PasswordEncoder()));
validatePassword();
autoWiredIdmIdmEngineConfiguration.setPasswordEncoder(new SpringEncoder(new StandardPasswordEncoder()));
validatePassword();
autoWiredIdmIdmEngineConfiguration.setPasswordEncoder(passwordEncoder);
}
示例11: createNewAccount
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入依赖的package包/类
@RequestMapping(value = "/createnewaccount.xhtml", method = RequestMethod.POST)
public String createNewAccount(Model model, User user, BindingResult bindingResult, RedirectAttributes redirectAttributes) {
user.setDob(new Date(user.getYear() - 1900, user.getMonth() - 1, user.getDay()));
regValidator.validate(user, bindingResult);
if (bindingResult.hasErrors()) {
model.addAttribute("countries", countryDAO.objects("enabled.countries", Country.class));
model.addAttribute("planguages", utilDAO.getEnabledProgramingLanguages());
model.addAttribute("locales", utilDAO.objects("enabled.locale", Locale.class));
if (user.getCountry_id() != 0) {
List<Institution> institutions = institutionDAO.getEnabledInstitutionsByCountry_id(user.getCountry_id());
institutions.add(0, new Institution(-1, "NONE", "NONE INSTITUTION"));
model.addAttribute("institutions", institutions);
}
return "/user/createnewaccount";
}
Md5PasswordEncoder md5 = new Md5PasswordEncoder();
user.setPassword(md5.encodePassword(user.getPassword(), "ABC123XYZ789"));
userDAO.InsertUser(user);
String token = md5.encodePassword(user.getUsername(), "ABC123XYZ789");
userDAO.dml("insert.account.activation", user.getUsername(), token, true);
try {
mailNotificationService.sendAccountVerification(user, token);
} catch (Exception e){
redirectAttributes.addFlashAttribute("message", "text.errorsendemail");
}
return "redirect:/user/registrationsuccess.xhtml";
}
示例12: daoAuthenticationProvider
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入依赖的package包/类
private DaoAuthenticationProvider daoAuthenticationProvider(){
DaoAuthenticationProvider bean = new DaoAuthenticationProvider();
bean.setUserDetailsService(jdbcDaoImpl());
bean.setPasswordEncoder(new Md5PasswordEncoder());
SystemWideSaltSource saltSource = new SystemWideSaltSource();
saltSource.setSystemWideSalt("ABC123XYZ789");
bean.setSaltSource(saltSource);
return bean;
}
示例13: setUp
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入依赖的package包/类
/**
*
*/
@Before
public final void setUp() {
userService = new UserServiceImpl();
userService.setPasswordEncoder(new Md5PasswordEncoder());
ReflectionSaltSource saltSource = new ReflectionSaltSource();
saltSource.setUserPropertyToUse("getUsername");
userService.setSaltSource(saltSource);
userDao = EasyMock.createMock(UserDao.class);
userService.setUserDao(userDao);
}
示例14: testOldPWMigrate
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入依赖的package包/类
@Test
public void testOldPWMigrate() {
PasswordEncoder encoder = new Md5PasswordEncoder();
String oldPW = encoder.encodePassword(STRING, null).toUpperCase();
String newPW = PasswordUtils.updateOldEncPass(oldPW, DATESTRING);
assertTrue("Old PW should match", PasswordUtils.isPasswordValid(newPW, STRING, DATESTRING));
}
示例15: saltedPasswordWitDefaultSaltGenerationTest
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入依赖的package包/类
@Test
public void saltedPasswordWitDefaultSaltGenerationTest() {
SaltedPassword saltedPassword = securityService.generateSaltedPassword("password");
Md5PasswordEncoder encoder = new Md5PasswordEncoder();
// Expect to use the default Salt
String salt = ConstantValues.defaultSaltValue.getString();
SaltedPassword expectedPassword = new SaltedPassword(encoder.encodePassword("password", salt), salt);
Assert.assertEquals(saltedPassword, expectedPassword, "Fail to generate secured password with Salt");
}