-
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
1 parent
77f6808
commit ff4d6ba
Showing
4 changed files
with
54 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package entities.memory; | ||
|
||
import entities.DynamicPassword; | ||
|
||
import java.util.Base64; | ||
|
||
public class MemoryDynamicPassword implements DynamicPassword { | ||
private long timestamp; | ||
private String hash; | ||
|
||
public MemoryDynamicPassword() { | ||
// dummy for Morphia | ||
} | ||
|
||
public MemoryDynamicPassword(byte[] hash) { | ||
this.timestamp = System.currentTimeMillis(); | ||
this.hash = Base64.getEncoder().encodeToString(hash); | ||
} | ||
|
||
@Override | ||
public long getTimestamp() { | ||
return timestamp; | ||
} | ||
|
||
@Override | ||
public String getHashBase64() { | ||
return hash; | ||
} | ||
|
||
@Override | ||
public byte[] getHash() { | ||
try { | ||
return Base64.getDecoder().decode(hash); | ||
} catch (Exception e) { | ||
return null; | ||
} | ||
}; | ||
} |
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