Skip to content

Instantly share code, notes, and snippets.

@ssledz
Last active October 13, 2017 15:05
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 ssledz/d06568224e1a6635263d799c95de8ce1 to your computer and use it in GitHub Desktop.
Save ssledz/d06568224e1a6635263d799c95de8ce1 to your computer and use it in GitHub Desktop.
A quick test to see if you have the JCE Unlimited Strength Jurisdiction Policy files installed
import java.security.Provider;
import java.security.Security;
import java.util.Arrays;
import javax.crypto.Cipher;
public class ShowCryptoProviders
{
private static final String EOL = System.getProperty("line.separator");
public static void main(final String[] args)
{
final Provider[] providers = Security.getProviders();
final Boolean verbose = Arrays.asList(args).contains("-v");
for (final Provider p : providers)
{
System.out.format("%s %s%s", p.getName(), p.getVersion(), EOL);
for (final Object o : p.keySet())
{
if (verbose)
{
System.out.format("\t%s : %s%s", o, p.getProperty((String)o), EOL);
}
}
}
try {
int len = Cipher.getMaxAllowedKeyLength("AES");
System.out.println("Key length: " + len);
if(len > 128) {
System.out.println("JCE Unlimited is supported");
} else {
System.out.println("JCE Unlimited not supported");
}
} catch(Exception e) {
System.out.println("JCE Unlimited not supported");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment