List of usage examples for java.util PropertyPermission PropertyPermission
PropertyPermission(String name, int mask)
From source file:Main.java
public static void main(String[] args) { System.out.println(new PropertyPermission("java.home.usr", "read").hashCode()); }
From source file:Main.java
public static void main(String[] args) { PropertyPermission permission = new PropertyPermission("java.home.usr", "read"); if (permission.equals(new PropertyPermission("java.home.usr", "read"))) { System.out.println("Has permissions on " + "java.home.usr" + " for read"); }/*from ww w . java 2 s .c o m*/ if (permission.equals(new PropertyPermission("java.home.usr", "write"))) { System.out.println("Has permissions on " + "java.home.usr" + " for write"); } }
From source file:Main.java
public static void main(String[] args) { PropertyPermission permission = new PropertyPermission("java.*", "read,write"); if (permission.implies(new PropertyPermission("java.home", "read"))) { System.out.println("Has permissions on " + "java.home" + " for read"); }// w w w . ja v a2 s . c o m // Check permission on read action if (permission.implies(new PropertyPermission("java.home", "write"))) { System.out.println("Has permissions on " + "java.home" + " for write"); } }
From source file:Main.java
public static void main(String[] args) { PropertyPermission permission = new PropertyPermission("java.home.*", "read,write"); if ("java.home.usr".matches(permission.getName())) { String actions = permission.getActions(); if (actions.contains("read")) { System.out.println("Has permissions on java.home.usr for read"); }/*from w w w.j a va 2 s. c om*/ if (actions.contains("write")) { System.out.println("Has permissions on java.home.usr for write"); } } }
From source file:Main.java
public static void main(String[] args) { // Build property permissions collection PropertyPermission permission = new PropertyPermission("java.*", "read"); PermissionCollection permissions = permission.newPermissionCollection(); permissions.add(permission);//w w w . j av a 2s . com permissions.add(new PropertyPermission("java.home.*", "read,write")); if (permissions.implies(new PropertyPermission("java.home", "read"))) { System.out.println("Has permissions on " + "java.home" + " for read"); } if (permissions.implies(new PropertyPermission("java.home", "write"))) { System.out.println("Has permissions on " + "java.home" + " for write"); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { String secretObj = "secret"; Guard guard = new PropertyPermission("java.home", "read"); GuardedObject gobj = new GuardedObject(secretObj, guard); try {/*from w w w. j a va 2 s.c om*/ Object o = gobj.getObject(); } catch (AccessControlException e) { e.printStackTrace(); } }
From source file:com.sshtools.j2ssh.configuration.ConfigurationLoader.java
/** * * * @param property//from ww w . ja va 2 s . co m * @param defaultValue * * @return */ public static String checkAndGetProperty(String property, String defaultValue) { // Check for access to sshtools.platform try { if (System.getSecurityManager() != null) { AccessController.checkPermission(new PropertyPermission(property, "read")); } return System.getProperty(property, defaultValue); } catch (AccessControlException ace) { return defaultValue; } }
From source file:com.thoughtworks.acceptance.SecurityManagerTest.java
public void testSerializeWithXppDriverAndSun14ReflectionProviderAndActiveSecurityManager() { sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.reflect")); sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.misc")); sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.text.resources")); sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.util.resources")); sm.addPermission(source, new RuntimePermission("accessDeclaredMembers")); sm.addPermission(source, new RuntimePermission("createClassLoader")); sm.addPermission(source, new RuntimePermission("fileSystemProvider")); sm.addPermission(source, new RuntimePermission("loadLibrary.nio")); sm.addPermission(source, new RuntimePermission("modifyThreadGroup")); sm.addPermission(source, new RuntimePermission("reflectionFactoryAccess")); sm.addPermission(source, new PropertyPermission("ibm.dst.compatibility", "read")); sm.addPermission(source, new PropertyPermission("java.home", "read")); sm.addPermission(source, new PropertyPermission("java.nio.file.spi.DefaultFileSystemProvider", "read")); sm.addPermission(source, new PropertyPermission("java.security.debug", "read")); sm.addPermission(source, new PropertyPermission("javax.xml.datatype.DatatypeFactory", "read")); sm.addPermission(source, new PropertyPermission("jaxp.debug", "read")); sm.addPermission(source, new PropertyPermission("jdk.util.TimeZone.allowSetDefault", "read")); sm.addPermission(source, new PropertyPermission("sun.boot.class.path", "read")); sm.addPermission(source, new PropertyPermission("sun.nio.fs.chdirAllowed", "read")); sm.addPermission(source, new PropertyPermission("sun.timezone.ids.oldmapping", "read")); sm.addPermission(source, new PropertyPermission("user.country", "read")); sm.addPermission(source, new PropertyPermission("user.dir", "read")); sm.addPermission(source, new PropertyPermission("user.timezone", "read,write")); sm.addPermission(source, new ReflectPermission("suppressAccessChecks")); sm.addPermission(source, new NetPermission("specifyStreamHandler")); sm.setReadOnly();// w w w .jav a 2 s .c o m System.setSecurityManager(sm); xstream = new XStream(); xstream.allowTypesByWildcard(AbstractAcceptanceTest.class.getPackage().getName() + ".*objects.**"); xstream.allowTypesByWildcard(this.getClass().getName() + "$*"); assertBothWays(); }
From source file:com.thoughtworks.acceptance.SecurityManagerTest.java
public void testSerializeWithXppDriverAndPureJavaReflectionProviderAndActiveSecurityManager() { sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.misc")); sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.text.resources")); sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.util.resources")); sm.addPermission(source, new RuntimePermission("accessDeclaredMembers")); sm.addPermission(source, new RuntimePermission("createClassLoader")); sm.addPermission(source, new RuntimePermission("fileSystemProvider")); sm.addPermission(source, new RuntimePermission("loadLibrary.nio")); sm.addPermission(source, new RuntimePermission("modifyThreadGroup")); sm.addPermission(source, new PropertyPermission("ibm.dst.compatibility", "read")); sm.addPermission(source, new PropertyPermission("java.home", "read")); sm.addPermission(source, new PropertyPermission("java.nio.file.spi.DefaultFileSystemProvider", "read")); sm.addPermission(source, new PropertyPermission("java.security.debug", "read")); sm.addPermission(source, new PropertyPermission("javax.xml.datatype.DatatypeFactory", "read")); sm.addPermission(source, new PropertyPermission("jaxp.debug", "read")); sm.addPermission(source, new PropertyPermission("jdk.util.TimeZone.allowSetDefault", "read")); sm.addPermission(source, new PropertyPermission("sun.boot.class.path", "read")); sm.addPermission(source, new PropertyPermission("sun.io.serialization.extendedDebugInfo", "read")); sm.addPermission(source, new PropertyPermission("sun.nio.fs.chdirAllowed", "read")); sm.addPermission(source, new PropertyPermission("sun.timezone.ids.oldmapping", "read")); sm.addPermission(source, new PropertyPermission("user.country", "read")); sm.addPermission(source, new PropertyPermission("user.dir", "read")); sm.addPermission(source, new PropertyPermission("user.timezone", "read,write")); sm.addPermission(source, new ReflectPermission("suppressAccessChecks")); sm.addPermission(source, new NetPermission("specifyStreamHandler")); sm.setReadOnly();/*from ww w .j a v a 2 s . c o m*/ System.setSecurityManager(sm); xstream = new XStream(new PureJavaReflectionProvider()); xstream.allowTypesByWildcard(AbstractAcceptanceTest.class.getPackage().getName() + ".*objects.**"); xstream.allowTypesByWildcard(this.getClass().getName() + "$*"); assertBothWays(); }
From source file:com.thoughtworks.acceptance.SecurityManagerTest.java
public void testSerializeWithDomDriverAndPureJavaReflectionProviderAndActiveSecurityManager() { sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.text.resources")); sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.util.resources")); sm.addPermission(source, new RuntimePermission("accessDeclaredMembers")); sm.addPermission(source, new RuntimePermission("createClassLoader")); sm.addPermission(source, new RuntimePermission("fileSystemProvider")); sm.addPermission(source, new RuntimePermission("loadLibrary.nio")); sm.addPermission(source, new RuntimePermission("modifyThreadGroup")); sm.addPermission(source, new RuntimePermission("reflectionFactoryAccess")); sm.addPermission(source, new PropertyPermission( "com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration", "read")); sm.addPermission(source, new PropertyPermission("elementAttributeLimit", "read")); sm.addPermission(source, new PropertyPermission("entityExpansionLimit", "read")); sm.addPermission(source,/* ww w .j av a 2 s. co m*/ new PropertyPermission("http://java.sun.com/xml/dom/properties/ancestor-check", "read")); sm.addPermission(source, new PropertyPermission("ibm.dst.compatibility", "read")); sm.addPermission(source, new PropertyPermission("java.home", "read")); sm.addPermission(source, new PropertyPermission("java.nio.file.spi.DefaultFileSystemProvider", "read")); sm.addPermission(source, new PropertyPermission("java.security.debug", "read")); sm.addPermission(source, new PropertyPermission("javax.xml.datatype.DatatypeFactory", "read")); sm.addPermission(source, new PropertyPermission("javax.xml.parsers.DocumentBuilderFactory", "read")); sm.addPermission(source, new PropertyPermission("javax.xml.accessExternalDTD", "read")); sm.addPermission(source, new PropertyPermission("javax.xml.accessExternalSchema", "read")); sm.addPermission(source, new PropertyPermission("jaxp.debug", "read")); sm.addPermission(source, new PropertyPermission("jdk.util.TimeZone.allowSetDefault", "read")); sm.addPermission(source, new PropertyPermission("jdk.xml.elementAttributeLimit", "read")); sm.addPermission(source, new PropertyPermission("jdk.xml.entityExpansionLimit", "read")); sm.addPermission(source, new PropertyPermission("jdk.xml.maxElementDepth", "read")); sm.addPermission(source, new PropertyPermission("jdk.xml.maxGeneralEntitySizeLimit", "read")); sm.addPermission(source, new PropertyPermission("jdk.xml.maxParameterEntitySizeLimit", "read")); sm.addPermission(source, new PropertyPermission("jdk.xml.maxOccurLimit", "read")); sm.addPermission(source, new PropertyPermission("jdk.xml.maxXMLNameLimit", "read")); sm.addPermission(source, new PropertyPermission("jdk.xml.totalEntitySizeLimit", "read")); sm.addPermission(source, new PropertyPermission("maxOccurLimit", "read")); sm.addPermission(source, new PropertyPermission("sun.boot.class.path", "read")); sm.addPermission(source, new PropertyPermission("sun.nio.fs.chdirAllowed", "read")); sm.addPermission(source, new PropertyPermission("sun.timezone.ids.oldmapping", "read")); sm.addPermission(source, new PropertyPermission("user.country", "read")); sm.addPermission(source, new PropertyPermission("user.dir", "read")); sm.addPermission(source, new PropertyPermission("user.timezone", "read,write")); sm.addPermission(source, new NetPermission("specifyStreamHandler")); sm.addPermission(source, new ReflectPermission("suppressAccessChecks")); sm.setReadOnly(); System.setSecurityManager(sm); xstream = new XStream(new PureJavaReflectionProvider(), new DomDriver()); xstream.allowTypesByWildcard(AbstractAcceptanceTest.class.getPackage().getName() + ".*objects.**"); xstream.allowTypesByWildcard(this.getClass().getName() + "$*"); assertBothWays(); }