Example usage for java.util PropertyPermission newPermissionCollection

List of usage examples for java.util PropertyPermission newPermissionCollection

Introduction

In this page you can find the example usage for java.util PropertyPermission newPermissionCollection.

Prototype

@Override
public PermissionCollection newPermissionCollection() 

Source Link

Document

Returns a new PermissionCollection object for storing PropertyPermission objects.

Usage

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);//  ww w.j  a v  a  2s .  c o  m
    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");
    }

}