Package java.util

Examples of java.util.PropertyPermission


     *
     * @see        java.lang.System#getProperty(java.lang.String)
     * @see        #checkPermission(java.security.Permission) checkPermission
     */
    public void checkPropertyAccess(String key) {
        checkPermission(new PropertyPermission(key,
            SecurityConstants.PROPERTY_READ_ACTION));
    }
View Full Code Here


     */
    public static String setProperty(String key, String value) {
        checkKey(key);
        SecurityManager sm = getSecurityManager();
        if (sm != null) {
            sm.checkPermission(new PropertyPermission(key,
                SecurityConstants.PROPERTY_WRITE_ACTION));
        }

        return (String) props.setProperty(key, value);
    }
View Full Code Here

     */
    public static String clearProperty(String key) {
        checkKey(key);
        SecurityManager sm = getSecurityManager();
        if (sm != null) {
            sm.checkPermission(new PropertyPermission(key, "write"));
        }

        return (String) props.remove(key);
    }
View Full Code Here

    Object objToSave = null;
    Object objLoaded;

    try {
      PropertyPermission test = new PropertyPermission("java.*",
          "read,write");
      PermissionCollection p = test.newPermissionCollection();
      p.add(new PropertyPermission("java.*", "read"));
      p.add(new PropertyPermission("java.*", "write"));
      // System.out.println("Does implies work? " + p.implies(test));

      objToSave = p;
      if (DEBUG)
        System.out.println("Obj = " + objToSave);
View Full Code Here

   * @tests java.util.PropertyPermission#equals(java.lang.Object)
   */
  public void test_equalsLjava_lang_Object() {
    // Test for method boolean
    // java.util.PropertyPermission.equals(java.lang.Object)
    PropertyPermission equalToJavaPP = new PropertyPermission("java.*",
        "read");
    PropertyPermission notEqualToJavaPP = new PropertyPermission("java.*",
        "read, write");
    PropertyPermission alsoNotEqualToJavaPP = new PropertyPermission(
        "java.home", "read");

    assertTrue("Equal returned false for equal objects", javaPP
        .equals(equalToJavaPP));
    assertTrue("Equal returned true for objects with different names",
View Full Code Here

   * @tests java.util.PropertyPermission#implies(java.security.Permission)
   */
  public void test_impliesLjava_security_Permission() {
    // Test for method boolean
    // java.util.PropertyPermission.implies(java.security.Permission)
    PropertyPermission impliedByJavaPP = new PropertyPermission(
        "java.home", "read");
    PropertyPermission notImpliedByJavaPP = new PropertyPermission(
        "java.home", "read,write");
    PropertyPermission impliedByUserPP = new PropertyPermission(
        "user.name", "read,write");
    PropertyPermission alsoImpliedByUserPP = new PropertyPermission(
        "user.name", "write");
    assertTrue("Returned false for implied permission (subset of .*)",
        javaPP.implies(impliedByJavaPP));
    assertTrue("Returned true for unimplied permission", !javaPP
        .implies(notImpliedByJavaPP));
View Full Code Here

    /**
     * @tests java.util.PropertyPermission#readObject(ObjectInputStream)
     * @tests java.util.PropertyPermission#writeObject(ObjectOutputStream)
     */
    public void test_serialization() throws Exception{
        PropertyPermission pp = new PropertyPermission("test", "read");
        SerializationTest.verifySelf(pp, comparator);
        SerializationTest.verifyGolden(this, pp, comparator);
    }
View Full Code Here

                    if (arg.matches("-D.*")) {
                        int i = arg.indexOf("=");
                        String p = arg.substring(2, i != -1 ? i : arg.length());
                        String v = arg.substring(i + 1);
                        try {
                            PropertyPermission pp = new PropertyPermission(p, "write");
                            pp.checkGuard(null);
                            JXAenvUtils._setSysValue(p, v);
                        } catch (SecurityException ex) {
                            if (JXAenvUtils._debugSys) {
                                ex.printStackTrace();
                            }
View Full Code Here

        permissionsDenied.add(new AllPermission());
        permissionsGranted = new Permissions();

        // junit harness stuff
        permissionsGranted
                .add(new PropertyPermission("line.separator", "read"));
        permissionsGranted.add(new RuntimePermission("exitVM"));
        permissionsGranted.add(new LoggingPermission("control", null));

        //grant permission to install security manager :-)
        permissionsGranted.add(new RuntimePermission("setSecurityManager"));
View Full Code Here

    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) {
View Full Code Here

TOP

Related Classes of java.util.PropertyPermission

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.