Example usage for java.lang SecurityManager checkPropertyAccess

List of usage examples for java.lang SecurityManager checkPropertyAccess

Introduction

In this page you can find the example usage for java.lang SecurityManager checkPropertyAccess.

Prototype

public void checkPropertyAccess(String key) 

Source Link

Document

Throws a SecurityException if the calling thread is not allowed to access the system property with the specified key name.

Usage

From source file:Main.java

public static void main(String[] args) {
    System.setProperty("java.security.policy", "file:/C:/java.policy");

    SecurityManager sm = new Main();

    System.setSecurityManager(sm);

    sm.checkPropertyAccess("java.runtime.name");

    System.out.println("Allowed!");
}