Search in sources :

Example 71 with SocketPermission

use of java.net.SocketPermission in project wildfly by wildfly.

the class DefaultDataSourceRemovedTestCase method defaultDSWithNameAndCtx.

@Deployment(name = "with-default-ds-with-name-and-ctx")
public static WebArchive defaultDSWithNameAndCtx() {
    WebArchive war = ShrinkWrap.create(WebArchive.class, "with-default-ds-with-name-and-ctx.war");
    war.addClasses(DefaultDSWithCtxListenerServlet.class);
    war.addPackage(HttpRequest.class.getPackage());
    war.addAsManifestResource(createPermissionsXmlAsset(new RuntimePermission("modifyThread"), new SocketPermission(TestSuiteEnvironment.getHttpAddress() + ":" + TestSuiteEnvironment.getHttpPort(), "connect,resolve")), "permissions.xml");
    return war;
}
Also used : HttpRequest(org.jboss.as.test.integration.common.HttpRequest) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) SocketPermission(java.net.SocketPermission) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 72 with SocketPermission

use of java.net.SocketPermission in project wildfly by wildfly.

the class AuthenticationTestCase method deployment.

@Deployment
public static Archive<?> deployment() {
    final String SERVER_HOST_PORT = TestSuiteEnvironment.getHttpAddress() + ":" + TestSuiteEnvironment.getHttpPort();
    final Package currentPackage = AuthenticationTestCase.class.getPackage();
    // using JavaArchive doesn't work, because of a bug in Arquillian, it only deploys wars properly
    final WebArchive war = ShrinkWrap.create(WebArchive.class, "ejb3security.war").addPackage(WhoAmIBean.class.getPackage()).addPackage(EntryBean.class.getPackage()).addClass(WhoAmI.class).addClass(Util.class).addClass(Entry.class).addClasses(WhoAmIServlet.class, AuthenticationTestCase.class).addClasses(AbstractSecurityDomainSetup.class, EjbSecurityDomainSetup.class).addAsResource(currentPackage, "users.properties", "users.properties").addAsResource(currentPackage, "roles.properties", "roles.properties").addAsWebInfResource(currentPackage, "web.xml", "web.xml").addAsWebInfResource(currentPackage, "jboss-web.xml", "jboss-web.xml").addAsWebInfResource(currentPackage, "jboss-ejb3.xml", "jboss-ejb3.xml").addAsManifestResource(new StringAsset("Manifest-Version: 1.0\nDependencies: org.jboss.as.controller-client,org.jboss.dmr\n"), "MANIFEST.MF").addAsManifestResource(createPermissionsXmlAsset(// login module needs to modify principal to commit logging in
    new AuthPermission("modifyPrincipals"), // AuthenticationTestCase#execute calls ExecutorService#shutdownNow
    new RuntimePermission("modifyThread"), // AuthenticationTestCase#execute calls sun.net.www.http.HttpClient#openServer under the hood
    new SocketPermission(SERVER_HOST_PORT, "connect,resolve"), new ElytronPermission("getSecurityDomain"), new ElytronPermission("authenticate")), "permissions.xml");
    war.addPackage(CommonCriteria.class.getPackage());
    return war;
}
Also used : StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) AuthPermission(javax.security.auth.AuthPermission) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) SocketPermission(java.net.SocketPermission) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) EntryBean(org.jboss.as.test.integration.ejb.security.authentication.EntryBean) CommonCriteria(org.jboss.as.test.categories.CommonCriteria) ElytronPermission(org.wildfly.security.permission.ElytronPermission) AbstractSecurityDomainSetup(org.jboss.as.test.integration.security.common.AbstractSecurityDomainSetup) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 73 with SocketPermission

use of java.net.SocketPermission 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 SocketPermission

use of java.net.SocketPermission 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 SocketPermission

use of java.net.SocketPermission in project wildfly by wildfly.

the class WebSuspendTestCase method deployment.

@Deployment
public static WebArchive deployment() {
    WebArchive war = ShrinkWrap.create(WebArchive.class, "web-suspend.war");
    war.addPackage(WebSuspendTestCase.class.getPackage());
    war.addPackage(HttpRequest.class.getPackage());
    war.addClass(TestSuiteEnvironment.class);
    war.addAsResource(new StringAsset("Dependencies: org.jboss.dmr, org.jboss.as.controller, org.jboss.remoting\n"), "META-INF/MANIFEST.MF");
    war.addAsManifestResource(createPermissionsXmlAsset(new PropertyPermission("management.address", "read"), new PropertyPermission("jboss.http.port", "read"), new PropertyPermission("node0", "read"), // executorService.shutdown() needs the following permission
    new RuntimePermission("modifyThread"), // ManagementClient needs the following permissions and a dependency on 'org.jboss.remoting3' module
    new RemotingPermission("createEndpoint"), new RemotingPermission("connect"), // HttpClient needs the following permission
    new SocketPermission(TestSuiteEnvironment.getServerAddress() + ":" + TestSuiteEnvironment.getHttpPort(), "connect,resolve"), new FilePermission(System.getProperty("jboss.inst") + "/standalone/tmp/auth/*", "read")), "permissions.xml");
    return war;
}
Also used : HttpRequest(org.jboss.as.test.integration.common.HttpRequest) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) PropertyPermission(java.util.PropertyPermission) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) SocketPermission(java.net.SocketPermission) RemotingPermission(org.jboss.remoting3.security.RemotingPermission) FilePermission(java.io.FilePermission) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Aggregations

SocketPermission (java.net.SocketPermission)83 Deployment (org.jboss.arquillian.container.test.api.Deployment)27 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)27 FilePermission (java.io.FilePermission)17 PropertyPermission (java.util.PropertyPermission)13 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)13 AccessControlContext (java.security.AccessControlContext)9 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)9 Test (org.testng.annotations.Test)8 URL (java.net.URL)7 PrivilegedActionException (java.security.PrivilegedActionException)6 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)6 HttpRequest (org.jboss.as.test.integration.common.HttpRequest)6 MockTracer (io.opentracing.mock.MockTracer)5 IOException (java.io.IOException)5 DatagramSocket (java.net.DatagramSocket)5 SecurityPermission (java.security.SecurityPermission)5 InetAddress (java.net.InetAddress)4 InetSocketAddress (java.net.InetSocketAddress)4 MulticastSocket (java.net.MulticastSocket)4