Skip to content

Instantly share code, notes, and snippets.

@ferrybig
Created August 13, 2018 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferrybig/2b599fad57e58c95b851b68a9c1f0267 to your computer and use it in GitHub Desktop.
Save ferrybig/2b599fad57e58c95b851b68a9c1f0267 to your computer and use it in GitHub Desktop.
Optional.ofNullable(Security.getProvider(provider)) // only on Windows
.map(p-> p.getService(type, alg)) // should exist but who knows?
.ifPresent(svc-> Security.insertProviderAt( // insert our provider with single SecureRandom service
new Provider(name, p.getVersion(), null) {{ //NOSONAR
setProperty(String.format("%s.%s", type, alg), svc.getClassName());
}}, 1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment