org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder Java Examples

The following examples show how to use org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuthenticationFilter.java    From spring-boot-security-example with MIT License 5 votes vote down vote up
private void addSessionContextToLogging() {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    String tokenValue = "EMPTY";
    if (authentication != null && !Strings.isNullOrEmpty(authentication.getDetails().toString())) {
        MessageDigestPasswordEncoder encoder = new MessageDigestPasswordEncoder("SHA-1");
        tokenValue = encoder.encodePassword(authentication.getDetails().toString(), "not_so_random_salt");
    }
    MDC.put(TOKEN_SESSION_KEY, tokenValue);

    String userValue = "EMPTY";
    if (authentication != null && !Strings.isNullOrEmpty(authentication.getPrincipal().toString())) {
        userValue = authentication.getPrincipal().toString();
    }
    MDC.put(USER_SESSION_KEY, userValue);
}
 
Example #2
Source File: UserEditForm.java    From unitime with Apache License 2.0 4 votes vote down vote up
public static String encodePassword(String clearTextPassword) {
	return new MessageDigestPasswordEncoder("MD5", true).encodePassword(clearTextPassword, null);
}
 
Example #3
Source File: PasswordChangeBackend.java    From unitime with Apache License 2.0 4 votes vote down vote up
private static String encode(String password) {
	return new MessageDigestPasswordEncoder("MD5", true).encodePassword(password, null);
}
 
Example #4
Source File: DbAuthenticateModule.java    From unitime with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the MD5 hash and encodes it in Base 64 notation
 * 
 * @param clearTextPassword
 * @return
 * @throws NoSuchAlgorithmException
 */
public static String getEncodedPassword(String clearTextPassword) {
	return new MessageDigestPasswordEncoder("MD5", true).encodePassword(clearTextPassword, null);
}