Example usage for java.lang SecurityManager SecurityManager

List of usage examples for java.lang SecurityManager SecurityManager

Introduction

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

Prototype

public SecurityManager() 

Source Link

Document

Constructs a new SecurityManager.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {

    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new SecurityManager());
    }//from   www  .j  av  a 2s.c o m
}

From source file:Main.java

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

    SecurityManager sm = new SecurityManager();

    System.setSecurityManager(sm);

    sm.checkLink("JDBC");

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

From source file:Main.java

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

    SecurityManager sm = new SecurityManager();

    System.setSecurityManager(sm);

    sm.checkAccept("www.java2s.com", 8080);

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

From source file:Main.java

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

    SecurityManager sm = new SecurityManager();

    System.setSecurityManager(sm);

    // perform the check
    sm.checkDelete("test.txt");

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

From source file:Main.java

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

    SecurityManager sm = new SecurityManager();

    System.setSecurityManager(sm);

    // perform the check
    sm.checkConnect("www.java2s.com", 8080);

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

From source file:Main.java

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

    SecurityManager sm = new SecurityManager();

    System.setSecurityManager(sm);

    // perform the check
    sm.checkExec("notepad.exe");

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

From source file:Main.java

public static void main(String[] args) {

    System.setProperty("java.security.policy", "file:/C:/java.policy");

    SecurityManager sm = new SecurityManager();

    System.setSecurityManager(sm);

    // perform the check
    sm.checkAwtEventQueueAccess();//from ww w.j  a  va 2  s .  c  o m

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

From source file:Main.java

public static void main(String[] args) {

    System.setProperty("java.security.policy", "file:/C:/java.policy");

    SecurityManager sm = new SecurityManager();

    System.setSecurityManager(sm);

    Object con = sm.getSecurityContext();

    System.out.println(con);//w  ww.  j  av  a 2 s  . c  o m

}

From source file:Main.java

public static void main(String[] args) {

    System.setProperty("java.security.policy", "file:/C:/java.policy");

    SecurityManager sm = new SecurityManager();

    System.setSecurityManager(sm);

    ThreadGroup con = sm.getThreadGroup();

    System.out.println(con);//from ww  w . java  2 s. c om

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    System.setProperty("java.version", "data");

    try {//from w  ww.j  a v a 2 s .c om
        SecurityManager sm = new SecurityManager();
        System.setSecurityManager(sm);
    } catch (SecurityException se) {
        se.printStackTrace();
    }

    // no longer possible; an AccessControlException is thrown
    System.setProperty("java.version", "malicious data");
}