Skip to content
This repository has been archived by the owner on May 3, 2018. It is now read-only.

Commit

Permalink
Allow applications to override the security policy at boot
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd committed Feb 21, 2013
1 parent a6345ca commit 64b9d98
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/main/java/org/jboss/modules/Main.java
Expand Up @@ -266,6 +266,25 @@ public static void main(String[] args) throws Throwable {
__JAXPRedirected.changeAll(moduleIdentifier, Module.getBootModuleLoader());
}

final Module module;
try {
module = loader.loadModule(moduleIdentifier);
} catch (ModuleNotFoundException e) {
e.printStackTrace(System.err);
System.exit(1);
return;
}

ModularURLStreamHandlerFactory.addHandlerModule(module);
ModularContentHandlerFactory.addHandlerModule(module);

try {
final Iterator<Policy> iterator = module.loadService(Policy.class).iterator();
if (iterator.hasNext()) {
Policy.setPolicy(iterator.next());
}
} catch (Exception ignored) {}

// configure policy so that if SM is enabled, modules can still function
Policy.setPolicy(new ModulesPolicy(Policy.getPolicy()));

Expand All @@ -287,20 +306,8 @@ public static void main(String[] args) throws Throwable {
}
}

final Module module;
try {
module = loader.loadModule(moduleIdentifier);
} catch (ModuleNotFoundException e) {
e.printStackTrace(System.err);
System.exit(1);
return;
}

ModularURLStreamHandlerFactory.addHandlerModule(module);
ModularContentHandlerFactory.addHandlerModule(module);

if (defaultSecMgr) {
final Iterator<SecurityManager> iterator = ServiceLoader.load(SecurityManager.class, module.getClassLoaderPrivate()).iterator();
final Iterator<SecurityManager> iterator = module.loadService(SecurityManager.class).iterator();
if (iterator.hasNext()) {
System.setSecurityManager(iterator.next());
} else {
Expand Down

0 comments on commit 64b9d98

Please sign in to comment.