Search in sources :

Example 71 with PropertyPermission

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());
}
Also used : ModuleSecurityPolicy(org.terasology.gestalt.module.sandbox.ModuleSecurityPolicy) PermissionSet(org.terasology.gestalt.module.sandbox.PermissionSet) PropertyPermission(java.util.PropertyPermission) ModuleSecurityManager(org.terasology.gestalt.module.sandbox.ModuleSecurityManager) APIScanner(org.terasology.gestalt.module.sandbox.APIScanner)

Example 72 with PropertyPermission

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;
}
Also used : StatelessRemote(org.jboss.as.test.clustering.cluster.ejb2.stateless.bean.StatelessRemote) PropertyPermission(java.util.PropertyPermission) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive)

Example 73 with PropertyPermission

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");
}
Also used : StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) PropertyPermission(java.util.PropertyPermission) SocketPermission(java.net.SocketPermission) Properties(java.util.Properties) FilePermission(java.io.FilePermission) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 74 with PropertyPermission

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;
}
Also used : EnterpriseArchive(org.jboss.shrinkwrap.api.spec.EnterpriseArchive) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) PropertyPermission(java.util.PropertyPermission) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) SocketPermission(java.net.SocketPermission) Properties(java.util.Properties) FilePermission(java.io.FilePermission) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 75 with PropertyPermission

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]);
}
Also used : PropertyPermission(java.util.PropertyPermission) Permission(java.security.Permission) PropertyPermission(java.util.PropertyPermission) ArrayList(java.util.ArrayList)

Aggregations

PropertyPermission (java.util.PropertyPermission)99 Deployment (org.jboss.arquillian.container.test.api.Deployment)49 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)46 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)35 FilePermission (java.io.FilePermission)23 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)18 SocketPermission (java.net.SocketPermission)13 JMSOperations (org.jboss.as.test.integration.common.jms.JMSOperations)13 Permission (java.security.Permission)10 AccessControlException (java.security.AccessControlException)8 RemotingPermission (org.jboss.remoting3.security.RemotingPermission)8 PermissionCollection (java.security.PermissionCollection)7 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)7 ReflectPermission (java.lang.reflect.ReflectPermission)6 EnterpriseArchive (org.jboss.shrinkwrap.api.spec.EnterpriseArchive)6 Permissions (java.security.Permissions)5 SecurityPermission (java.security.SecurityPermission)5 AccessControlContext (java.security.AccessControlContext)4 TimeoutUtil (org.jboss.as.test.shared.TimeoutUtil)4 Method (java.lang.reflect.Method)3