-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
BCrypt
encryption for password encoding
- Loading branch information
Showing
19 changed files
with
1,671 additions
and
30 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 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
2 changes: 1 addition & 1 deletion
2
jpro-auth/core/src/main/java/one/jpro/platform/auth/core/api/FluentBasicAuthAPI.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
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 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 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
42 changes: 42 additions & 0 deletions
42
jpro-auth/core/src/main/java/one/jpro/platform/auth/core/crypto/PasswordEncoder.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,42 @@ | ||
package one.jpro.platform.auth.core.crypto; | ||
|
||
/** | ||
* Password encoder interface. | ||
* | ||
* @author Besmir Beqiri | ||
*/ | ||
public interface PasswordEncoder { | ||
|
||
/** | ||
* Encode the raw password. Generally, a good encoding algorithm applies an SHA-1 or | ||
* greater hash combined with an 8-byte or greater randomly generated salt. | ||
* | ||
* @param rawPassword the raw password to encode | ||
* @return encoded password string | ||
*/ | ||
String encode(CharSequence rawPassword); | ||
|
||
/** | ||
* Verify the encoded password obtained from storage matches the submitted raw | ||
* password after it too is encoded. Returns true if the passwords match, false if | ||
* they do not. The stored password itself is never decoded. | ||
* | ||
* @param rawPassword the raw password to encode and match | ||
* @param encodedPassword the encoded password from storage to compare with | ||
* @return true if the raw password, after encoding, matches the encoded password from | ||
* storage | ||
*/ | ||
boolean matches(CharSequence rawPassword, String encodedPassword); | ||
|
||
/** | ||
* Returns true if the encoded password should be encoded again for better security, | ||
* else false. The default implementation always returns false. | ||
* | ||
* @param encodedPassword the encoded password to check | ||
* @return true if the encoded password should be encoded again for better security, | ||
* else false. | ||
*/ | ||
default boolean upgradeEncoding(String encodedPassword) { | ||
return false; | ||
} | ||
} |
Oops, something went wrong.