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


Java Md5PasswordEncoder类代码示例

本文整理汇总了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());
		}
	}
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:19,代码来源:UserDAOImpl.java

示例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));

}
 
开发者ID:rememberber,项目名称:WeSync,代码行数:27,代码来源:DESPlus.java

示例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;
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:8,代码来源:AppSecurityModelG.java

示例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;     
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:8,代码来源:AppPasswordEncoder.java

示例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;
}
 
开发者ID:ronger-x,项目名称:player,代码行数:15,代码来源:MD5Tools.java

示例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;
	}
}
 
开发者ID:eyupgevenim,项目名称:SpringMvcBlog,代码行数:16,代码来源:UserDaoImpl.java

示例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;
}
 
开发者ID:reportportal,项目名称:service-authorization,代码行数:8,代码来源:PrimarySecurityConfigs.java

示例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;
}
 
开发者ID:marcin-pwr,项目名称:hotel,代码行数:10,代码来源:UserService.java

示例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;
}
 
开发者ID:marcin-pwr,项目名称:hotel,代码行数:10,代码来源:UserService.java

示例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);
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:13,代码来源:SpringPasswordEncoderTest.java

示例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";
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:30,代码来源:UserController.java

示例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;
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:10,代码来源:SecurityConfiguration.java

示例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);
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:14,代码来源:UserServiceImplTest.java

示例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));
}
 
开发者ID:sercxtyf,项目名称:onboard,代码行数:8,代码来源:PasswordUtilsTest.java

示例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");
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:10,代码来源:SaltTest.java


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