Java 8 PermissionCollection - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 PermissionCollection class.

This code example shows how to use the following methods:add, implies
 
        // now test permission collections 
        System.out.println("Testing PermissionCollection containing " +
                           "RuntimePermission(\"exitVM.*\")"); 
        PermissionCollection newPC = newWildcard.newPermissionCollection();
        newPC.add(newWildcard);
        System.out.println
            ("    testing implies(new RuntimePermission(\"exitVM.23\"))"); 
        if (!newPC.implies(other)) {
            throw new Exception("expected true, received false");
        } 
        System.out.println
            ("    testing implies(new RuntimePermission(\"exitVM.*\"))"); 
        if (!newPC.implies(new RuntimePermission("exitVM.*"))) {
            throw new Exception("expected true, received false");
        } 
        System.out.println
            ("    testing implies(new RuntimePermission(\"exitVM\"))"); 
        if (!newPC.implies(oldWildcard)) {
            throw new Exception("expected true, received false");

6
CodeRank
This code example shows how to use the following methods:implies
      this.delegatedManager = delegatedManager;
   } 
 
   @Override 
   public void checkPermission(Permission prmsn) {
      if (!permissions.implies(prmsn)) {
         if (delegatedManager != null) {
            delegatedManager.checkPermission(prmsn);
         } else { 
            throw new SecurityException("Operation disallowed by current security policy. "
                    + "If you believe this to be an error, please submit the resulting stack trace as a bug."); 
         } 
      } 
   } 
} 
6
CodeRank
This code example shows how to use the following methods:add, implies
    public void testImpliesCollection(){ 
         
        Permission ap = new AllPermission();
        Permission p = new DelegationPermission("\"AAA\" \"BBB\"");
        PermissionCollection pc = p.newPermissionCollection();
        assertFalse(pc.implies(ap));
        assertFalse(pc.implies(p));
        pc.add(p);
        assertTrue(pc.implies(p));
        assertFalse(pc.implies(null));
        DelegationPermission dp1 = new DelegationPermission("\"AAA\" \"BBB\"");
        assertTrue(dp1.implies(dp1));
        DelegationPermission dp2 = new DelegationPermission("\"BBB\" \"AAA\"");
        assertFalse(dp1.implies(dp2));
        assertFalse(dp1.implies(null));
        assertFalse(dp1.implies(new ServicePermission("aaa", "accept")));
    } 
 
	public void testElements() throws Exception { 
        Permission p = new DelegationPermission("\"AAA\" \"BBB\"");
5
CodeRank
This code example shows how to use the following methods:add, implies
 
        // now test permission collections 
        System.out.println("Testing PermissionCollection containing " +
                           "RuntimePermission(\"exitVM.*\")"); 
        PermissionCollection newPC = newWildcard.newPermissionCollection();
        newPC.add(newWildcard);
        System.out.println
            ("    testing implies(new RuntimePermission(\"exitVM.23\"))"); 
        if (!newPC.implies(other)) {
            throw new Exception("expected true, received false");
        } 
        System.out.println
            ("    testing implies(new RuntimePermission(\"exitVM.*\"))"); 
        if (!newPC.implies(new RuntimePermission("exitVM.*"))) {
            throw new Exception("expected true, received false");
        } 
        System.out.println
            ("    testing implies(new RuntimePermission(\"exitVM\"))"); 
        if (!newPC.implies(oldWildcard)) {
            throw new Exception("expected true, received false");

5
CodeRank
This code example shows how to use the following methods:add, setReadOnly
    public void testAddCollection() { 
        ServicePermission sp = new ServicePermission("AAA", "accept");
        PermissionCollection pc  = sp.newPermissionCollection();
         
        try { 
            pc.add(new DelegationPermission("\"aaa\" \"bbb\""));
            fail("Should not add non DelegationPermission");
        } catch (IllegalArgumentException e) {
        } 
         
        try { 
            pc.add(null);
            fail("no expected IAE");
        } catch (IllegalArgumentException e) {
        } 
         
        pc.add(new ServicePermission("AAA", "accept"));
        pc.add(new ServicePermission("BBB", "accept, initiate"));
         
        pc.setReadOnly();

5
CodeRank
This code example shows how to use the following methods:add, implies
      MBeanServerPermission p1 = new MBeanServerPermission("createMBeanServer");
      assertTrue("createMBeanServer implies newMBeanServer", p1.implies(p0));
      assertTrue("createMBeanServer implies newMBeanServer", p0.implies(p1));
 
      PermissionCollection pc = p0.newPermissionCollection();
      pc.add(p0);
      assertTrue("PC(newMBeanServer) implies createMBeanServer", pc.implies(p1));
   } 
} 
5
CodeRank
This code example shows how to use the following methods:add, implies
 
        // now test permission collections 
        System.out.println("Testing PermissionCollection containing " +
                           "RuntimePermission(\"exitVM.*\")"); 
        PermissionCollection newPC = newWildcard.newPermissionCollection();
        newPC.add(newWildcard);
        System.out.println
            ("    testing implies(new RuntimePermission(\"exitVM.23\"))"); 
        if (!newPC.implies(other)) {
            throw new Exception("expected true, received false");
        } 
        System.out.println
            ("    testing implies(new RuntimePermission(\"exitVM.*\"))"); 
        if (!newPC.implies(new RuntimePermission("exitVM.*"))) {
            throw new Exception("expected true, received false");
        } 
        System.out.println
            ("    testing implies(new RuntimePermission(\"exitVM\"))"); 
        if (!newPC.implies(oldWildcard)) {
            throw new Exception("expected true, received false");

5
CodeRank
This code example shows how to use the following methods:implies
   */ 
  public void checkPermission(final Permission perm)
  { 
    if (WorkspaceSettings.getInstance().isOfflineMode() && perm instanceof SocketPermission)
    { 
      if (permissionCollection.implies(perm) == false)
      { 
        throw new SecurityException(UtilMessages.getInstance().getString("FirewallingProxySelector.FilterMessage"));
      } 
    } 
    if (parent != null)
    { 
      parent.checkPermission(perm);
    } 
  } 
 
  /** 
   * Throws a <code>SecurityException</code> if the 
   * specified security context is denied access to the resource 
   * specified by the given permission. 
5
CodeRank
This code example shows how to use the following methods:add, implies
 
        // now test permission collections 
        System.out.println("Testing PermissionCollection containing " +
                           "RuntimePermission(\"exitVM.*\")"); 
        PermissionCollection newPC = newWildcard.newPermissionCollection();
        newPC.add(newWildcard);
        System.out.println
            ("    testing implies(new RuntimePermission(\"exitVM.23\"))"); 
        if (!newPC.implies(other)) {
            throw new Exception("expected true, received false");
        } 
        System.out.println
            ("    testing implies(new RuntimePermission(\"exitVM.*\"))"); 
        if (!newPC.implies(new RuntimePermission("exitVM.*"))) {
            throw new Exception("expected true, received false");
        } 
        System.out.println
            ("    testing implies(new RuntimePermission(\"exitVM\"))"); 
        if (!newPC.implies(oldWildcard)) {
            throw new Exception("expected true, received false");

5
CodeRank
This code example shows how to use the following methods:add
final class ProxyClassLoader extends ClassLoader {
   
  private static final ProtectionDomain PROXY_PROTECTION_DOMAIN;
   
  static { 
    PermissionCollection pc = new Permissions();
    pc.add(new AllPermission());
    PROXY_PROTECTION_DOMAIN = new ProtectionDomain(null, pc);
  } 
   
  /** A {@link Map} of classes we already know */ 
  private final ConcurrentMap<LinkedHashSet<Class<?>>, String> classes = 
                new ConcurrentHashMap<LinkedHashSet<Class<?>>, String>();
   
  private final ConcurrentMap<String, Class<?>> locatedClasses = 
                new ConcurrentHashMap<String, Class<?>>();
   
  private final Set<Class<?>> ifaces = new HashSet<Class<?>>();
   
  private final ReadWriteLock ifacesLock = new ReentrantReadWriteLock();
5
CodeRank
See Code Examples for Java 8 PermissionCollection Methods: