Search in sources :

Example 1 with PropertyPermission

use of java.util.PropertyPermission in project jdk8u_jdk by JetBrains.

the class PrintToDir method main.

public static void main(String[] arg) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        System.out.println("Security manager detected");
        try {
            security.checkPermission(new FilePermission("<<ALL FILES>>", "read,write"));
            security.checkPermission(new PropertyPermission("user.dir", "read"));
        } catch (SecurityException se) {
            System.out.println("Security requirement not obtained.  TEST PASSED");
            return;
        }
    }
    String[] testStr = { ".", "" };
    for (int i = 0; i < testStr.length; i++) {
        System.out.println("Testing file name = \"" + testStr[i] + "\"");
        doPrinterJob(testStr[i], OrientationRequested.PORTRAIT);
        PrintToDir ptd = new PrintToDir();
        ptd.doPrintJob(testStr[i]);
        ptd.dispose();
    }
    System.out.println("TEST PASSED");
}
Also used : PropertyPermission(java.util.PropertyPermission) java.awt.print(java.awt.print)

Example 2 with PropertyPermission

use of java.util.PropertyPermission in project jdk8u_jdk by JetBrains.

the class DynamicPolicy method initStaticPolicy.

private void initStaticPolicy(PermissionCollection perms) {
    perms.add(new java.security.SecurityPermission("getPolicy"));
    perms.add(new java.security.SecurityPermission("setPolicy"));
    perms.add(new java.lang.RuntimePermission("stopThread"));
    perms.add(new java.net.SocketPermission("localhost:1024-", "listen"));
    perms.add(new PropertyPermission("java.version", "read"));
    perms.add(new PropertyPermission("java.vendor", "read"));
    perms.add(new PropertyPermission("java.vendor.url", "read"));
    perms.add(new PropertyPermission("java.class.version", "read"));
    perms.add(new PropertyPermission("os.name", "read"));
    perms.add(new PropertyPermission("os.version", "read"));
    perms.add(new PropertyPermission("os.arch", "read"));
    perms.add(new PropertyPermission("file.separator", "read"));
    perms.add(new PropertyPermission("path.separator", "read"));
    perms.add(new PropertyPermission("line.separator", "read"));
    perms.add(new PropertyPermission("java.specification.version", "read"));
    perms.add(new PropertyPermission("java.specification.vendor", "read"));
    perms.add(new PropertyPermission("java.specification.name", "read"));
    perms.add(new PropertyPermission("java.vm.specification.version", "read"));
    perms.add(new PropertyPermission("java.vm.specification.vendor", "read"));
    perms.add(new PropertyPermission("java.vm.specification.name", "read"));
    perms.add(new PropertyPermission("java.vm.version", "read"));
    perms.add(new PropertyPermission("java.vm.vendor", "read"));
    perms.add(new PropertyPermission("java.vm.name", "read"));
    return;
}
Also used : java.security(java.security) PropertyPermission(java.util.PropertyPermission) SocketPermission(java.net.SocketPermission) java.lang(java.lang)

Example 3 with PropertyPermission

use of java.util.PropertyPermission in project wildfly by wildfly.

the class VaultSystemPropertiesTestCase method deployment.

@Deployment
public static WebArchive deployment() {
    final WebArchive war = ShrinkWrap.create(WebArchive.class, "vault.war");
    war.addClass(BasicVaultServerSetupTask.class);
    war.addAsManifestResource(createPermissionsXmlAsset(new PropertyPermission("vault.testing.property", "read")), "permissions.xml");
    return war;
}
Also used : PropertyPermission(java.util.PropertyPermission) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 4 with PropertyPermission

use of java.util.PropertyPermission in project wildfly by wildfly.

the class SPNEGOLoginModuleTestCase method deployment.

/**
     * Creates {@link WebArchive}.
     *
     * @return
     */
@Deployment(name = "WEB", testable = false)
public static WebArchive deployment() {
    LOGGER.debug("Web deployment");
    final WebArchive war = createWebApp(WEBAPP_NAME, "web-spnego-authn.xml", "SPNEGO");
    war.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(// Permissions for PropagateIdentityServlet to get delegation credentials DelegationCredentialContext.getDelegCredential()
    new RuntimePermission("org.jboss.security.negotiation.getDelegCredential"), // Permissions for PropagateIdentityServlet to read properties
    new PropertyPermission(GSSTestConstants.PROPERTY_PORT, "read"), new PropertyPermission(GSSTestConstants.PROPERTY_PRINCIPAL, "read"), new PropertyPermission(GSSTestConstants.PROPERTY_PASSWORD, "read"), // Permissions for GSSTestClient to connect to GSSTestServer
    new SocketPermission(TestSuiteEnvironment.getServerAddress(), "resolve,connect"), // Permissions for GSSTestClient to initiate gss context
    new ServicePermission(GSSTestConstants.PRINCIPAL, "initiate"), new ServicePermission("krbtgt/JBOSS.ORG@JBOSS.ORG", "initiate")), "permissions.xml");
    return war;
}
Also used : PropertyPermission(java.util.PropertyPermission) ServicePermission(javax.security.auth.kerberos.ServicePermission) 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 5 with PropertyPermission

use of java.util.PropertyPermission in project spring-framework by spring-projects.

the class CallbacksSecurityTests method testSecuritySanity.

@Test
public void testSecuritySanity() throws Exception {
    AccessControlContext acc = provider.getAccessControlContext();
    try {
        acc.checkPermission(new PropertyPermission("*", "read"));
        fail("Acc should not have any permissions");
    } catch (SecurityException se) {
    // expected
    }
    final CustomCallbackBean bean = new CustomCallbackBean();
    final Method method = bean.getClass().getMethod("destroy");
    method.setAccessible(true);
    try {
        AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {

            @Override
            public Object run() throws Exception {
                method.invoke(bean);
                return null;
            }
        }, acc);
        fail("expected security exception");
    } catch (Exception ex) {
    }
    final Class<ConstructorBean> cl = ConstructorBean.class;
    try {
        AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {

            @Override
            public Object run() throws Exception {
                return cl.newInstance();
            }
        }, acc);
        fail("expected security exception");
    } catch (Exception ex) {
    }
}
Also used : AccessControlContext(java.security.AccessControlContext) PropertyPermission(java.util.PropertyPermission) Method(java.lang.reflect.Method) CustomCallbackBean(org.springframework.beans.factory.support.security.support.CustomCallbackBean) BeanCreationException(org.springframework.beans.factory.BeanCreationException) BeansException(org.springframework.beans.BeansException) ConstructorBean(org.springframework.beans.factory.support.security.support.ConstructorBean) Test(org.junit.Test)

Aggregations

PropertyPermission (java.util.PropertyPermission)98 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