Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.security.PermissionCollection;
import java.util.PropertyPermission;

public class Main {

    public static void main(String[] args) {
        // Build property permissions collection
        PropertyPermission permission = new PropertyPermission("java.*", "read");
        PermissionCollection permissions = permission.newPermissionCollection();
        permissions.add(permission);
        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");
        }

    }
}