Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
[NC-1374] Use default java secureRandom (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
jframe authored Oct 11, 2018
1 parent 6c8422d commit 90705bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,7 @@ applicationDefaultJvmArgs = [
"-Dpantheon.home=PANTHEON_HOME",
// We shutdown log4j ourselves, as otherwise his shutdown hook runs before our own and whatever
// happens during shutdown is not logged.
"-Dlog4j.shutdownHookEnabled=false",
"-Djava.security.egd=file:/dev/urandom"
"-Dlog4j.shutdownHookEnabled=false"
]

run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
import java.security.SecureRandom;

public class SecureRandomProvider {
private static final SecureRandom publicSecureRandom = new PRNGSecureRandom();
private static final SecureRandom publicSecureRandom = secureRandom();

// Returns a shared instance of secure random intended to be used where the value is used publicly
public static SecureRandom publicSecureRandom() {
return publicSecureRandom;
}

public static SecureRandom createSecureRandom() {
return new PRNGSecureRandom();
return secureRandom();
}

@SuppressWarnings("DoNotCreateSecureRandomDirectly")
private static SecureRandom secureRandom() {
return new SecureRandom();
}
}

0 comments on commit 90705bb

Please sign in to comment.