Java Code Examples for java.net.SocketPermission#newPermissionCollection()

The following examples show how to use java.net.SocketPermission#newPermissionCollection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AddToReadOnlyPermissionCollection.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
static void trySockPC() throws Exception {
    try {
        SocketPermission p0= new SocketPermission("example.com","connect");
        PermissionCollection pc = p0.newPermissionCollection();
        pc.setReadOnly();   // this should lock out future adds
        //
        SocketPermission p1= new SocketPermission("example.net","connect");
        pc.add(p1);
        throw new
            Exception("Failed...SocketPermission added to readonly SocketPermissionCollection.");

    } catch (SecurityException se) {
        System.out.println("SocketPermissionCollection passed");
    }

}
 
Example 2
Source File: AddToReadOnlyPermissionCollection.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static void trySockPC() throws Exception {
    try {
        SocketPermission p0= new SocketPermission("example.com","connect");
        PermissionCollection pc = p0.newPermissionCollection();
        pc.setReadOnly();   // this should lock out future adds
        //
        SocketPermission p1= new SocketPermission("example.net","connect");
        pc.add(p1);
        throw new
            Exception("Failed...SocketPermission added to readonly SocketPermissionCollection.");

    } catch (SecurityException se) {
        System.out.println("SocketPermissionCollection passed");
    }

}
 
Example 3
Source File: AddToReadOnlyPermissionCollection.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static void trySockPC() throws Exception {
    try {
        SocketPermission p0= new SocketPermission("example.com","connect");
        PermissionCollection pc = p0.newPermissionCollection();
        pc.setReadOnly();   // this should lock out future adds
        //
        SocketPermission p1= new SocketPermission("example.net","connect");
        pc.add(p1);
        throw new
            Exception("Failed...SocketPermission added to readonly SocketPermissionCollection.");

    } catch (SecurityException se) {
        System.out.println("SocketPermissionCollection passed");
    }

}
 
Example 4
Source File: AddToReadOnlyPermissionCollection.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static void trySockPC() throws Exception {
    try {
        SocketPermission p0= new SocketPermission("example.com","connect");
        PermissionCollection pc = p0.newPermissionCollection();
        pc.setReadOnly();   // this should lock out future adds
        //
        SocketPermission p1= new SocketPermission("example.net","connect");
        pc.add(p1);
        throw new
            Exception("Failed...SocketPermission added to readonly SocketPermissionCollection.");

    } catch (SecurityException se) {
        System.out.println("SocketPermissionCollection passed");
    }

}
 
Example 5
Source File: AddToReadOnlyPermissionCollection.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static void trySockPC() throws Exception {
    try {
        SocketPermission p0= new SocketPermission("example.com","connect");
        PermissionCollection pc = p0.newPermissionCollection();
        pc.setReadOnly();   // this should lock out future adds
        //
        SocketPermission p1= new SocketPermission("example.net","connect");
        pc.add(p1);
        throw new
            Exception("Failed...SocketPermission added to readonly SocketPermissionCollection.");

    } catch (SecurityException se) {
        System.out.println("SocketPermissionCollection passed");
    }

}
 
Example 6
Source File: AddToReadOnlyPermissionCollection.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static void trySockPC() throws Exception {
    try {
        SocketPermission p0= new SocketPermission("example.com","connect");
        PermissionCollection pc = p0.newPermissionCollection();
        pc.setReadOnly();   // this should lock out future adds
        //
        SocketPermission p1= new SocketPermission("example.net","connect");
        pc.add(p1);
        throw new
            Exception("Failed...SocketPermission added to readonly SocketPermissionCollection.");

    } catch (SecurityException se) {
        System.out.println("SocketPermissionCollection passed");
    }

}
 
Example 7
Source File: AddToReadOnlyPermissionCollection.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void trySockPC() throws Exception {
    try {
        SocketPermission p0= new SocketPermission("example.com","connect");
        PermissionCollection pc = p0.newPermissionCollection();
        pc.setReadOnly();   // this should lock out future adds
        //
        SocketPermission p1= new SocketPermission("example.net","connect");
        pc.add(p1);
        throw new
            Exception("Failed...SocketPermission added to readonly SocketPermissionCollection.");

    } catch (SecurityException se) {
        System.out.println("SocketPermissionCollection passed");
    }

}
 
Example 8
Source File: AddToReadOnlyPermissionCollection.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static void trySockPC() throws Exception {
    try {
        SocketPermission p0= new SocketPermission("example.com","connect");
        PermissionCollection pc = p0.newPermissionCollection();
        pc.setReadOnly();   // this should lock out future adds
        //
        SocketPermission p1= new SocketPermission("example.net","connect");
        pc.add(p1);
        throw new
            Exception("Failed...SocketPermission added to readonly SocketPermissionCollection.");

    } catch (SecurityException se) {
        System.out.println("SocketPermissionCollection passed");
    }

}
 
Example 9
Source File: AddToReadOnlyPermissionCollection.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
static void trySockPC() throws Exception {
    try {
        SocketPermission p0= new SocketPermission("example.com","connect");
        PermissionCollection pc = p0.newPermissionCollection();
        pc.setReadOnly();   // this should lock out future adds
        //
        SocketPermission p1= new SocketPermission("example.net","connect");
        pc.add(p1);
        throw new
            Exception("Failed...SocketPermission added to readonly SocketPermissionCollection.");

    } catch (SecurityException se) {
        System.out.println("SocketPermissionCollection passed");
    }

}
 
Example 10
Source File: AddToReadOnlyPermissionCollection.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
static void trySockPC() throws Exception {
    try {
        SocketPermission p0= new SocketPermission("example.com","connect");
        PermissionCollection pc = p0.newPermissionCollection();
        pc.setReadOnly();   // this should lock out future adds
        //
        SocketPermission p1= new SocketPermission("example.net","connect");
        pc.add(p1);
        throw new
            Exception("Failed...SocketPermission added to readonly SocketPermissionCollection.");

    } catch (SecurityException se) {
        System.out.println("SocketPermissionCollection passed");
    }

}
 
Example 11
Source File: AddToReadOnlyPermissionCollection.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
static void trySockPC() throws Exception {
    try {
        SocketPermission p0= new SocketPermission("example.com","connect");
        PermissionCollection pc = p0.newPermissionCollection();
        pc.setReadOnly();   // this should lock out future adds
        //
        SocketPermission p1= new SocketPermission("example.net","connect");
        pc.add(p1);
        throw new
            Exception("Failed...SocketPermission added to readonly SocketPermissionCollection.");

    } catch (SecurityException se) {
        System.out.println("SocketPermissionCollection passed");
    }

}
 
Example 12
Source File: AddToReadOnlyPermissionCollection.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void trySockPC() throws Exception {
    try {
        SocketPermission p0= new SocketPermission("example.com","connect");
        PermissionCollection pc = p0.newPermissionCollection();
        pc.setReadOnly();   // this should lock out future adds
        //
        SocketPermission p1= new SocketPermission("example.net","connect");
        pc.add(p1);
        throw new
            Exception("Failed...SocketPermission added to readonly SocketPermissionCollection.");

    } catch (SecurityException se) {
        System.out.println("SocketPermissionCollection passed");
    }

}
 
Example 13
Source File: AddToReadOnlyPermissionCollection.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void trySockPC() throws Exception {
    try {
        SocketPermission p0= new SocketPermission("example.com","connect");
        PermissionCollection pc = p0.newPermissionCollection();
        pc.setReadOnly();   // this should lock out future adds
        //
        SocketPermission p1= new SocketPermission("example.net","connect");
        pc.add(p1);
        throw new
            Exception("Failed...SocketPermission added to readonly SocketPermissionCollection.");

    } catch (SecurityException se) {
        System.out.println("SocketPermissionCollection passed");
    }

}
 
Example 14
Source File: FirewallingSecurityManager.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public FirewallingSecurityManager() {
  parent = System.getSecurityManager();

  final SocketPermission localHost = new SocketPermission( LOCALHOST, PERMISSION_VALUE );
  final SocketPermission localHostRaw = new SocketPermission( LOCALHOST_IP, PERMISSION_VALUE );
  final SocketPermission localHostFqn = new SocketPermission( LOCALHOST_LOCALDOMAIN, PERMISSION_VALUE );
  permissionCollection = localHost.newPermissionCollection();
  permissionCollection.add( localHost );
  permissionCollection.add( localHostRaw );
  permissionCollection.add( localHostFqn );
}