-
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.
- Loading branch information
Showing
5 changed files
with
42 additions
and
4 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
8 changes: 6 additions & 2 deletions
8
...ab/repository/InMemoryUserRepository.java → ...pository/impl/InMemoryUserRepository.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
21 changes: 21 additions & 0 deletions
21
src/main/java/ru/ylab/security/Password4jPasswordEncoder.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,21 @@ | ||
package ru.ylab.security; | ||
|
||
import com.password4j.Password; | ||
|
||
public class Password4jPasswordEncoder implements PasswordEncoder { | ||
private static final String SECRET_KEY = "superSecret"; | ||
|
||
@Override | ||
public String encode(String password) { | ||
return Password | ||
.hash(password) | ||
.addSalt(SECRET_KEY) | ||
.withArgon2() | ||
.getResult(); | ||
} | ||
|
||
@Override | ||
public boolean verify(String password, String hash) { | ||
return Password.check(password, hash).addSalt(SECRET_KEY).withArgon2(); | ||
} | ||
} |
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,7 @@ | ||
package ru.ylab.security; | ||
|
||
public interface PasswordEncoder { | ||
String encode(String password); | ||
|
||
boolean verify(String password, String hash); | ||
} |
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