Last active
October 13, 2017 15:05
-
-
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
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
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