-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://github.com/rreganjr/Requel/issues/2
In UserImpl the password encryption algorithm is now a property so that it can be updated periodically and automatically when a user resets a password or logs in to the system and the current algorithm used isn't the preferred algorithm. The preferred algorithm is defined as a static final property on the UserImpl class versus being configurable so that it can't be accidentally configured with an insecure algorithm. The intent is that new version will update the UserImpl class with security improvements and when deployed users' passwords will be re-encrypted as they use the system. The preferred algorithm is set to PBKDF2WITHHMACSHA512, which is a private key password encoder that supports an iteration count. The iteration count is also a property and the preferred value is set to 50,000 iterations. PBKDF2 is the minimum recommended by OWASP, but also the only recommended algorithm built-in to Java. There is now also a password salt property generated using a SecureRandom SHA1PRNG it is reset when upgrading the encryption or resetting the password. There is now password validation. A password must be between 1 and 128 characters long and can't be only whitespace. There is now a UserImplTest that covers all the new password changes plus most of the original UserImpl methods. Signed-off-by: rreganjr <[email protected]>
- Loading branch information
Showing
11 changed files
with
740 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/com/rreganjr/requel/user/PasswordException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.rreganjr.requel.user; | ||
|
||
import com.rreganjr.requel.RequelException; | ||
|
||
public class PasswordException extends RequelException { | ||
|
||
public static final String MSG_PROBLEM_ENCRYPTING_PASSWORD = "There was a problem encrypting the user's password."; | ||
public static final String MSG_PROBLEM_ENCRYPTING_PASSWORD_WITH_MESSAGE = "There was a problem encrypting the user's password: %s"; | ||
public static final String MSG_PROBLEM_GENERATING_PASSWORD_SALT = "There was a problem generating the password salt value."; | ||
public static final String MSG_BAD_ALGORITHM_NAME = "The supplied algorithm name '%s' is not a supported SecretKeyFactory or MessageDigest algorithm name."; | ||
|
||
public static PasswordException problemEncryptingPassword(Exception e) { | ||
return new PasswordException(e, MSG_PROBLEM_ENCRYPTING_PASSWORD); | ||
} | ||
|
||
public static PasswordException problemEncryptingPassword(String message) { | ||
return new PasswordException(MSG_PROBLEM_ENCRYPTING_PASSWORD_WITH_MESSAGE, message); | ||
} | ||
|
||
public static PasswordException badAlgorithmName(String badAlgorithmName) { | ||
return new PasswordException(MSG_BAD_ALGORITHM_NAME, badAlgorithmName); | ||
} | ||
|
||
public static PasswordException problemGeneratingPasswordSalt(Exception e) { | ||
return new PasswordException(e, MSG_PROBLEM_GENERATING_PASSWORD_SALT); | ||
} | ||
|
||
protected PasswordException(String format, Object... args) { | ||
super(format, args); | ||
} | ||
|
||
protected PasswordException(Throwable cause, String format, Object... args) { | ||
super(cause, format, args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.