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");
}
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;
}
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;
}
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;
}
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) {
}
}
Aggregations