Search in sources :

Example 1 with ReflectPermission

use of java.lang.reflect.ReflectPermission in project wildfly by wildfly.

the class InfinispanResourceRefTestCase method deployment.

@Deployment
public static Archive<?> deployment() {
    WebArchive war = ShrinkWrap.create(WebArchive.class, "infinispan-resource-ref.war");
    war.addClasses(InfinispanBean.class, InfinispanResourceRefTestCase.class);
    war.addAsWebInfResource(getWebXml(), "web.xml");
    war.setManifest(new StringAsset(Descriptors.create(ManifestDescriptor.class).attribute("Dependencies", "org.infinispan export").exportAsString()));
    war.addAsManifestResource(createPermissionsXmlAsset(new MBeanPermission("-#-[-]", "queryNames"), new MBeanPermission("org.infinispan.*[jboss.infinispan:*,type=Cache]", "registerMBean"), new ReflectPermission("suppressAccessChecks"), new RuntimePermission("accessDeclaredMembers"), new RuntimePermission("getClassLoader")), "permissions.xml");
    return war;
}
Also used : StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) MBeanPermission(javax.management.MBeanPermission) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) ReflectPermission(java.lang.reflect.ReflectPermission) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 2 with ReflectPermission

use of java.lang.reflect.ReflectPermission in project wildfly by wildfly.

the class JCETestCase method deployment.

@Deployment
public static Archive<?> deployment() throws Exception {
    final JavaArchive jce = ShrinkWrap.create(JavaArchive.class, "jcetest.jar").addPackage(DummyProvider.class.getPackage());
    final File jceJar = new File("target/jcetest.jar");
    jce.as(ZipExporter.class).exportTo(jceJar, true);
    final File signedJceJar = new File("target/jcetestsigned.jar");
    JavaArchive signedJce;
    if (isJCETestable()) {
        // see genkey-jcetest-keystore in pom.xml for the keystore creation
        final JarSignerUtil signer = new JarSignerUtil(new File("target/jcetest.keystore"), "password", "password", /* alias */
        "test");
        signer.sign(jceJar, signedJceJar);
        signer.verify(signedJceJar);
        signedJce = ShrinkWrap.create(ZipImporter.class, "jcetestsigned.jar").importFrom(signedJceJar).as(JavaArchive.class);
    } else {
        log.trace("skipping the test since it can run on Oracle JDK only");
        signedJce = jce;
    }
    final WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war").addClasses(ControllerServlet.class);
    final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "jcetest.ear").addAsLibrary(signedJce).addAsModule(war).addAsManifestResource(JCETestCase.class.getPackage(), "jboss-deployment-structure.xml", "jboss-deployment-structure.xml");
    // ControllerServlet and DummyProvider need the following perms for their "dirty" game
    ear.addAsManifestResource(createPermissionsXmlAsset(new FilePermission("target/jcetest.keystore", "read"), new RuntimePermission("accessDeclaredMembers"), new ReflectPermission("suppressAccessChecks"), new RuntimePermission("accessClassInPackage.sun.security.validator"), new SecurityPermission("putProviderProperty.DP"), new SecurityPermission("insertProvider"), new RuntimePermission("getProtectionDomain")), "permissions.xml");
    return ear;
}
Also used : EnterpriseArchive(org.jboss.shrinkwrap.api.spec.EnterpriseArchive) DummyProvider(org.jboss.as.test.integration.deployment.jcedeployment.provider.DummyProvider) ZipExporter(org.jboss.shrinkwrap.api.exporter.ZipExporter) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) FilePermission(java.io.FilePermission) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) ZipImporter(org.jboss.shrinkwrap.api.importer.ZipImporter) ReflectPermission(java.lang.reflect.ReflectPermission) File(java.io.File) SecurityPermission(java.security.SecurityPermission) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 3 with ReflectPermission

use of java.lang.reflect.ReflectPermission in project wildfly by wildfly.

the class ResourceAdapterCapacityPoliciesTestCase method createResourceAdapter.

@Deployment
public static Archive<?> createResourceAdapter() {
    ResourceAdapterArchive rar = ShrinkWrap.create(ResourceAdapterArchive.class, "capacity-policies-test.rar");
    rar.addAsManifestResource(LazyResourceAdapter.class.getPackage(), "ra-notx.xml", "ra.xml");
    JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "capacity-policies-test.jar");
    jar.addClass(LazyResourceAdapter.class).addClass(LazyManagedConnectionFactory.class).addClass(LazyManagedConnection.class).addClass(LazyConnection.class).addClass(LazyConnectionImpl.class).addClass(LazyXAResource.class).addClass(LazyLocalTransaction.class).addClass(LazyManagedConnectionMetaData.class).addClass(LazyConnectionFactory.class).addClass(LazyConnectionFactoryImpl.class);
    jar.addClasses(ResourceAdapterCapacityPoliciesTestCase.class, AbstractMgmtServerSetupTask.class, AbstractMgmtTestBase.class, JcaMgmtBase.class, ContainerResourceMgmtTestBase.class, MgmtOperationException.class, ManagementOperations.class, JcaTestsUtil.class, TimeoutUtil.class);
    rar.addAsManifestResource(new StringAsset("Dependencies: javax.inject.api,org.jboss.as.connector," + "org.jboss.as.controller,org.jboss.dmr,org.jboss.staxmapper," + "org.jboss.ironjacamar.impl, org.jboss.ironjacamar.jdbcadapters,org.jboss.remoting\n"), "MANIFEST.MF");
    rar.addAsManifestResource(createPermissionsXmlAsset(new RemotingPermission("createEndpoint"), new RemotingPermission("connect"), new FilePermission(System.getProperty("jboss.inst") + "/standalone/tmp/auth/*", "read"), new PropertyPermission("ts.timeout.factor", "read"), new RuntimePermission("accessDeclaredMembers"), new ReflectPermission("suppressAccessChecks")), "permissions.xml");
    rar.addAsLibrary(jar);
    return rar;
}
Also used : LazyManagedConnection(org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyManagedConnection) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) PropertyPermission(java.util.PropertyPermission) LazyLocalTransaction(org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyLocalTransaction) FilePermission(java.io.FilePermission) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) LazyConnectionImpl(org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnectionImpl) LazyResourceAdapter(org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyResourceAdapter) LazyConnectionFactory(org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnectionFactory) ResourceAdapterArchive(org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive) RemotingPermission(org.jboss.remoting3.security.RemotingPermission) ReflectPermission(java.lang.reflect.ReflectPermission) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 4 with ReflectPermission

use of java.lang.reflect.ReflectPermission in project wildfly by wildfly.

the class FaultToleranceApplicationArchiveProcessor method process.

@Override
public void process(Archive<?> applicationArchive, TestClass testClass) {
    if (!(applicationArchive instanceof ClassContainer)) {
        return;
    }
    ClassContainer<?> classContainer = (ClassContainer<?>) applicationArchive;
    classContainer.addClass(CleanupMetricRegistries.class);
    if (applicationArchive instanceof LibraryContainer) {
        JavaArchive additionalBeanArchive = ShrinkWrap.create(JavaArchive.class);
        additionalBeanArchive.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
        ((LibraryContainer<?>) applicationArchive).addAsLibrary(additionalBeanArchive);
    } else {
        classContainer.addAsResource(EmptyAsset.INSTANCE, "META-INF/beans.xml");
    }
    if (!applicationArchive.contains("META-INF/beans.xml")) {
        applicationArchive.add(EmptyAsset.INSTANCE, "META-INF/beans.xml");
    }
    // Run the TCK with security manager
    if (applicationArchive instanceof ManifestContainer) {
        ManifestContainer<?> mc = (ManifestContainer<?>) applicationArchive;
        mc.addAsManifestResource(createPermissionsXmlAsset(// Permissions required by test instrumentation - arquillian-core.jar and arquillian-testng.jar
        new ReflectPermission("suppressAccessChecks"), new PropertyPermission("*", "read"), new RuntimePermission("accessDeclaredMembers"), // Permissions required by test instrumentation - awaitility.jar
        new RuntimePermission("setDefaultUncaughtExceptionHandler"), new RuntimePermission("modifyThread")), "permissions.xml");
    }
}
Also used : PropertyPermission(java.util.PropertyPermission) ClassContainer(org.jboss.shrinkwrap.api.container.ClassContainer) LibraryContainer(org.jboss.shrinkwrap.api.container.LibraryContainer) ManifestContainer(org.jboss.shrinkwrap.api.container.ManifestContainer) ReflectPermission(java.lang.reflect.ReflectPermission) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive)

Example 5 with ReflectPermission

use of java.lang.reflect.ReflectPermission in project wildfly by wildfly.

the class DeploymentHelper method getWebArchiveWithPermissions.

public WebArchive getWebArchiveWithPermissions(final String archiveName) {
    final String javaHome = TestSuiteEnvironment.getSystemProperty("java.home");
    final String serverHostPort = TestSuiteEnvironment.getServerAddress() + ":" + TestSuiteEnvironment.getHttpPort();
    final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, archiveName + ".war").addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml")).addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(new ReflectPermission("suppressAccessChecks"), new ReflectPermission("accessDeclaredMembers"), // Permissions for port access
    new PropertyPermission("management.address", "read"), new PropertyPermission("node0", "read"), new PropertyPermission("jboss.http.port", "read"), new SocketPermission(serverHostPort, "connect,resolve"), // Permissions for the new client creation
    new RuntimePermission("accessDeclaredMembers"), new RuntimePermission("createClassLoader"), new RuntimePermission("getClassLoader"), new RuntimePermission("org.apache.cxf.permission"), new RuntimePermission("accessClassInPackage.com.sun.org.apache.xerces.internal.jaxp"), new FilePermission(javaHome + File.separator + "lib" + File.separator + "wsdl.properties", "read"), new PropertyPermission("user.dir", "read"), new PropertyPermission("arquillian.debug", "read"), new FilePermission(System.getProperty("basedir") + File.separator + "target" + File.separator + "workdir" + File.separator + "xcatalog", "read")), "permissions.xml");
    return webArchive;
}
Also used : PropertyPermission(java.util.PropertyPermission) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) SocketPermission(java.net.SocketPermission) ReflectPermission(java.lang.reflect.ReflectPermission) FilePermission(java.io.FilePermission)

Aggregations

ReflectPermission (java.lang.reflect.ReflectPermission)17 FilePermission (java.io.FilePermission)12 Deployment (org.jboss.arquillian.container.test.api.Deployment)10 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)10 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)9 RemotingPermission (org.jboss.remoting3.security.RemotingPermission)7 PropertyPermission (java.util.PropertyPermission)6 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)4 Permissions (java.security.Permissions)3 SecurityPermission (java.security.SecurityPermission)3 MBeanPermission (javax.management.MBeanPermission)3 ResourceAdapterArchive (org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive)3 SocketPermission (java.net.SocketPermission)2 Permission (java.security.Permission)2 LazyConnectionFactory (org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnectionFactory)2 LazyConnectionImpl (org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnectionImpl)2 LazyLocalTransaction (org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyLocalTransaction)2 LazyManagedConnection (org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyManagedConnection)2 LazyResourceAdapter (org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyResourceAdapter)2 EnterpriseArchive (org.jboss.shrinkwrap.api.spec.EnterpriseArchive)2