use of java.util.PropertyPermission in project Terasology by MovingBlocks.
the class ModuleManager method setupSandbox.
private void setupSandbox() {
PermissionSet permissionSet = permissionProviderFactory.getBasePermissionSet();
ExternalApiWhitelist.CLASSES.forEach(permissionSet::addAPIClass);
ExternalApiWhitelist.PACKAGES.forEach(permissionSet::addAPIPackage);
APIScanner apiScanner = new APIScanner(permissionProviderFactory);
registry.stream().map(Module::getModuleManifest).forEach(apiScanner::scan);
permissionSet.grantPermission("com.google.gson", ReflectPermission.class);
permissionSet.grantPermission("com.google.gson.internal", ReflectPermission.class);
// noinspection ConstantConditions - this reference is to help find this if this method gets separated from the reactor dependency
if (reactor.core.scheduler.Scheduler.class != null) {
// lgtm [java/useless-null-check]
// In theory, PropertyPermission has wildcard matching and "reactor.*" should be sufficient to grant read access to all
// reactor configuration properties.
permissionSet.grantPermission(new PropertyPermission("reactor.*", "read"));
// In practice, the permission checks fail unless these are each named explicitly.
permissionSet.grantPermission(new PropertyPermission("reactor.bufferSize.x", "read"));
permissionSet.grantPermission(new PropertyPermission("reactor.bufferSize.small", "read"));
permissionSet.grantPermission(new PropertyPermission("reactor.trace.operatorStacktrace", "read"));
permissionSet.grantPermission(new PropertyPermission("reactor.schedulers.defaultPoolSize", "read"));
permissionSet.grantPermission(new PropertyPermission("reactor.schedulers.defaultBoundedElasticSize", "read"));
permissionSet.grantPermission(new PropertyPermission("reactor.schedulers.defaultBoundedElasticQueueSize", "read"));
}
Policy.setPolicy(new ModuleSecurityPolicy());
System.setSecurityManager(new ModuleSecurityManager());
}
use of java.util.PropertyPermission in project wildfly by wildfly.
the class RemoteStatelessFailoverTestCase method createDeploymentOnDescriptor.
private static Archive<?> createDeploymentOnDescriptor() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, MODULE_NAME_DD + ".jar");
jar.addPackage(StatelessRemote.class.getPackage());
jar.addClass(StatelessBeanDD.class);
jar.addClass(NodeNameGetter.class);
jar.addAsManifestResource(RemoteStatelessFailoverTestCase.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml");
jar.addAsResource(createPermissionsXmlAsset(new PropertyPermission("jboss.node.name", "read")), "META-INF/jboss-permissions.xml");
return jar;
}
use of java.util.PropertyPermission in project wildfly by wildfly.
the class ServiceRefTestCase method deployment.
@Deployment
public static JavaArchive deployment() {
String wsdl = FileUtils.readFile(ServiceRefTestCase.class, "TestService.wsdl");
final Properties properties = new Properties();
properties.putAll(System.getProperties());
final String node0 = NetworkUtils.formatPossibleIpv6Address((String) properties.get("node0"));
if (properties.containsKey("node0")) {
properties.put("node0", node0);
}
return ShrinkWrap.create(JavaArchive.class, "ws-serviceref-example.jar").addClasses(EJB3Bean.class, EndpointInterface.class, EndpointService.class, StatelessBean.class, StatelessRemote.class, CdiBean.class).addAsManifestResource(ServiceRefTestCase.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml").addAsManifestResource(ServiceRefTestCase.class.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml").addAsManifestResource(new StringAsset(PropertiesValueResolver.replaceProperties(wsdl, properties)), "wsdl/TestService.wsdl").addAsManifestResource(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "beans.xml").addAsManifestResource(createPermissionsXmlAsset(new FilePermission("<<ALL FILES>>", "read"), new PropertyPermission("user.dir", "read"), new RuntimePermission("getClassLoader"), new RuntimePermission("org.apache.cxf.permission", "resolveUri"), new RuntimePermission("createClassLoader"), new RuntimePermission("accessDeclaredMembers"), new SocketPermission(node0 + ":8080", "connect,resolve")), "jboss-permissions.xml");
}
use of java.util.PropertyPermission in project wildfly by wildfly.
the class ServiceRefEarTestCase method deployment.
@Deployment(testable = false)
public static Archive<?> deployment() {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ws-serviceref-example.jar").addClasses(EJB3Bean.class, EndpointInterface.class);
WebArchive war = ShrinkWrap.create(WebArchive.class, "ws-serviceref-example-servlet-client.war").addClasses(EndpointInterface.class, EndpointService.class, ServletClient.class).addAsWebInfResource(ServiceRefEarTestCase.class.getPackage(), "web.xml", "web.xml").addAsWebInfResource(ServiceRefEarTestCase.class.getPackage(), "jboss-web.xml", "jboss-web.xml");
String wsdl = FileUtils.readFile(ServiceRefEarTestCase.class, "TestService.wsdl");
final Properties properties = new Properties();
properties.putAll(System.getProperties());
final String node0 = NetworkUtils.formatPossibleIpv6Address((String) properties.get("node0"));
if (properties.containsKey("node0")) {
properties.put("node0", node0);
}
war.addAsWebInfResource(new StringAsset(PropertiesValueResolver.replaceProperties(wsdl, properties)), "wsdl/TestService.wsdl");
EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "ws-serviceref-example.ear").addAsModule(jar).addAsModule(war);
// all the following permissions are needed because EndpointService directly extends javax.xml.ws.Service class
// and CXF guys are not willing to add more privileged blocks into their code, thus deployments need to have
// the following permissions (note that the wsdl.properties permission is needed by wsdl4j)
ear.addAsManifestResource(createPermissionsXmlAsset(new FilePermission("<<ALL FILES>>", "read"), new PropertyPermission("user.dir", "read"), new RuntimePermission("getClassLoader"), new RuntimePermission("org.apache.cxf.permission", "resolveUri"), new RuntimePermission("createClassLoader"), new RuntimePermission("accessDeclaredMembers"), new SocketPermission(node0 + ":8080", "connect,resolve")), "jboss-permissions.xml");
return ear;
}
use of java.util.PropertyPermission in project wildfly by wildfly.
the class AbstractMicroProfileConfigTestCase method createPermissions.
/**
* Creates the following permissions for config tests:
* <ul>
* <li>A read {@link PropertyPermission} for each name</li>
* <li>A {@code getenv} permission for each name</li>
* <li>A {@code getenv} permission for each name replacing any dots {@code .} with an underscore {@code _}</li>
* <li>A {@code getenv} permission for each name converted to upper case</li>
* <li>A {@code getenv} permission for each name converted to upper case replacing any dots {@code .}
* with an underscore {@code _}
* </li>
* </ul>
*
* @param names the names to create the permissions for
*
* @return the set of permissions
*/
protected static Permission[] createPermissions(final String... names) {
final Collection<Permission> permissions = new ArrayList<>(names.length * 2);
for (String name : names) {
permissions.add(new PropertyPermission(name, "read"));
permissions.add(new RuntimePermission("getenv." + name));
permissions.add(new RuntimePermission("getenv." + name.replace('.', '_')));
permissions.add(new RuntimePermission("getenv." + name.toUpperCase(Locale.ROOT)));
permissions.add(new RuntimePermission("getenv." + name.replace('.', '_').toUpperCase(Locale.ROOT)));
}
return permissions.toArray(new Permission[0]);
}
Aggregations