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
private static void setupJurisdictionPolicies() throws Exception { | |
String javaHomeDir = System.getProperty("java.home"); | |
String sep = File.separator; | |
String pathToPolicyJar = javaHomeDir + sep + "lib" + sep + | |
"security" + sep; | |
File exportJar = new File(pathToPolicyJar, "US_export_policy.jar"); | |
File importJar = new File(pathToPolicyJar, "local_policy.jar"); | |
URL jceCipherURL = ClassLoader.getSystemResource | |
("javax/crypto/Cipher.class"); | |
if ((jceCipherURL == null) || | |
!exportJar.exists() || !importJar.exists()) { | |
throw new SecurityException | |
("Cannot locate policy or framework files!"); | |
} | |
// Read jurisdiction policies. | |
CryptoPermissions defaultExport = new CryptoPermissions(); | |
CryptoPermissions exemptExport = new CryptoPermissions(); | |
loadPolicies(exportJar, defaultExport, exemptExport); | |
CryptoPermissions defaultImport = new CryptoPermissions(); | |
CryptoPermissions exemptImport = new CryptoPermissions(); | |
loadPolicies(importJar, defaultImport, exemptImport); | |
// Merge the export and import policies for default applications. | |
if (defaultExport.isEmpty() || defaultImport.isEmpty()) { | |
throw new SecurityException("Missing mandatory jurisdiction " + | |
"policy files"); | |
} | |
defaultPolicy = defaultExport.getMinimum(defaultImport); | |
// Merge the export and import policies for exempt applications. | |
if (exemptExport.isEmpty()) { | |
exemptPolicy = exemptImport.isEmpty() ? null : exemptImport; | |
} else { | |
exemptPolicy = exemptExport.getMinimum(exemptImport); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment