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


Java Md5PasswordEncoder.encodePassword方法代码示例

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


在下文中一共展示了Md5PasswordEncoder.encodePassword方法的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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: saltedPasswordGenerationWithNullSaltTest

import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入方法依赖的package包/类
@Test
public void saltedPasswordGenerationWithNullSaltTest() {
    // Expect to use the default Salt
    SaltedPassword securedPassword = securityService.generateSaltedPassword("password", null);
    Md5PasswordEncoder encoder = new Md5PasswordEncoder();
    String salt = null;
    SaltedPassword expectedPassword = new SaltedPassword(encoder.encodePassword("password", salt), salt);
    Assert.assertEquals(securedPassword, expectedPassword, "Fail to generate secured password with Salt");
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:10,代码来源:SaltTest.java

示例11: saltedPasswordGenerationWithExistingUserTest

import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入方法依赖的package包/类
@Test
public void saltedPasswordGenerationWithExistingUserTest() {
    // Expect to use the user Salt
    SaltedPassword securedPassword = securityService.generateSaltedPassword("password", "SALT");
    Md5PasswordEncoder encoder = new Md5PasswordEncoder();
    SaltedPassword expectedPassword = new SaltedPassword(encoder.encodePassword("password", "SALT"), "SALT");
    Assert.assertEquals(securedPassword, expectedPassword, "Fail to generate secured password with Salt");
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:9,代码来源:SaltTest.java

示例12: updateAvatarUrlwithGravatar

import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入方法依赖的package包/类
private void updateAvatarUrlwithGravatar(MemberProfile profile) {
    if (!StringUtils.isEmpty(profile.getGravatarEmail())) {
        Md5PasswordEncoder encoder = new Md5PasswordEncoder();
        String hashedEmail = encoder.encodePassword(profile.getGravatarEmail(), null);
        profile.setAvatarUrl(String.format("https://gravatar.com/avatar/%s", hashedEmail));
    }
}
 
开发者ID:spring-io,项目名称:sagan,代码行数:8,代码来源:TeamService.java

示例13: setMd5Encoder

import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入方法依赖的package包/类
private String setMd5Encoder(String password){
	Md5PasswordEncoder passwordEncoder = new Md5PasswordEncoder();
	String hashedPassword = passwordEncoder.encodePassword(password, null);
	return hashedPassword;
}
 
开发者ID:eyupgevenim,项目名称:SpringMvcBlog,代码行数:6,代码来源:UserDaoImpl.java

示例14: getEncodedPassword

import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入方法依赖的package包/类
private String getEncodedPassword(String username, String rawPass) {
	Md5PasswordEncoder passwordEncoder = new Md5PasswordEncoder();
	String encPass = passwordEncoder.encodePassword(rawPass, username);
	return encPass;
}
 
开发者ID:GMCgames,项目名称:MarketsSimServer,代码行数:6,代码来源:DBMock.java

示例15: updateUser

import org.springframework.security.authentication.encoding.Md5PasswordEncoder; //导入方法依赖的package包/类
public void updateUser(User user) {
	if (user.isTeam()) {
		if (!StringUtils.isEmpty(user.getPassword())
				&& user.getPassword().length() > 7) {
			dml("update.user", user.getNick(), user.getCountry_id(),
					user.getInstitution_id(), user.getLid(),
					user.getLocale(), user.getPassword(),
					user.isEnableadveditor(), user.getUid());
			dml("update.user.by.admin.3", user.getCoach(),
					user.getUser_1(), user.getUser_2(), user.getUser_3(),
					user.getUid());
		} else {
			dml("update.user.1", user.getNick(), user.getCountry_id(),
					user.getInstitution_id(), user.getLid(),
					user.getLocale(), user.isEnableadveditor(),
					user.getUid());
			dml("update.user.by.admin.3", user.getCoach(),
					user.getUser_1(), user.getUser_2(), user.getUser_3(),
					user.getUid());
		}
	} else {
		if (bool("email.changed", user.getEmail(), user.getUid())) {
			dml("enable.user", false, user.getUsername());
			Md5PasswordEncoder md5 = new Md5PasswordEncoder();
			String token = md5.encodePassword(user.getUsername(),
					new Date().toString());
			dml("insert.account.activation", user.getUsername(), token,
					false);
			mailNotificationService.sendEmailChanged(user, token);
		}

		if (!StringUtils.isEmpty(user.getPassword())
				&& user.getPassword().length() > 7) {
			dml("update.user.2", user.getNick(), user.getCountry_id(),
					user.getInstitution_id(), user.getLid(),
					user.getLocale(), user.getPassword(),
					user.isProblemNotifications(),
					user.isContestNotifications(),
					user.isSubmissionNotifications(),
					user.isNewprivatemessageNotifications(),
					user.isWboardNotifications(),
					user.isEntriesNotifications(), user.isShowemail(),
					user.getGender(), user.isSee_solutions(),
					user.isEnableadveditor(), user.getUsername());
		} else {
			dml("update.user.3", user.getNick(), user.getCountry_id(),
					user.getInstitution_id(), user.getLid(),
					user.getLocale(), user.isProblemNotifications(),
					user.isContestNotifications(),
					user.isSubmissionNotifications(),
					user.isNewprivatemessageNotifications(),
					user.isWboardNotifications(),
					user.isEntriesNotifications(), user.isShowemail(),
					user.getGender(), user.isSee_solutions(),
					user.isEnableadveditor(), user.getUsername());
		}
		dml(replaceSql("update.user.4", "<dob>", parseDate(user.getDob())),
				user.getEmail(), user.getName(), user.getLastname(),
				user.isShowdob(), user.isView_problem_info(), user.getUid());

	}
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:63,代码来源:UserDAOImpl.java


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