Java 8 Permission - 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 Permission class.

This code example shows how to use the following methods:newPermissionCollection
 
  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);
  } 
 
  /** 
   * Throws a <code>SecurityException</code> if the requested 
   * access, specified by the given permission, is not permitted based 
   * on the security policy currently in effect. 
   * <p/> 
   * This method calls <code>AccessController.checkPermission</code> 
6
CodeRank
This code example shows how to use the following methods:getClass, getActions, getName
	public boolean implies(Permission permission) {
		if (_log.isDebugEnabled()) {
			Thread.dumpStack();
		} 
 
		Class<?> clazz = permission.getClass();
		String name = permission.getName();
		String actions = permission.getActions();
 
		if (Validator.isNotNull(actions)) {
			logSecurityException( 
				_log,
				"Permission " + clazz.getName() + " attempted to " + name +
					" on " + actions);
		} 
		else { 
			logSecurityException( 
				_log,
				"Permission " + clazz.getName() + " attempted to " + name);
		} 
7
CodeRank
This code example shows how to use the following methods:getActions, getName
	public boolean implies(Permission permission) {
		if (_permissions.implies(permission)) {
			return true; 
		} 
 
		String name = permission.getName();
		String action = permission.getActions();
 
		logSecurityException( 
			_log, "Attempted to " + action + " system property " + name);
 
		return false; 
	} 
 
	protected void initProperties() { 
		Set<String> names = getPropertySet("security-manager-properties-read");
 
		for (String name : names) {
			Permission permission = new PropertyPermission(
				name, PROPERTY_PERMISSION_READ);
6
CodeRank
This code example shows how to use the following methods:getActions, getName
		return authorizationProperty;
	} 
 
	@Override 
	public boolean implies(Permission permission) {
		String actions = permission.getActions();
		String name = permission.getName();
 
		if (!_permissions.implies(permission)) {
			logSecurityException( 
				_log, "Attempted " + actions + " for address " + name);
 
			return false; 
		} 
 
		return true; 
	} 
 
	protected void initAcceptHostsAndPorts() { 
		String[] networkParts = getPropertyArray(
6
CodeRank
This code example shows how to use the following methods:getClass, getActions, getName
 
		if (!_log.isInfoEnabled()) {
			return true; 
		} 
 
		Class<?> clazz = permission.getClass();
		String name = permission.getName();
		String actions = permission.getActions();
 
		if (Validator.isNotNull(actions)) {
			_log.info(
				"Allowing permission " + clazz.getName() + " to " + name +
					" on " + actions);
		} 
		else { 
			_log.info("Allowing permission " + clazz.getName() + " to " + name);
		} 
 
		return true; 
	} 
7
CodeRank
This code example shows how to use the following methods:getName
        // Try the permission hack 
        if (checkConnection()) 
        { 
            Permission perm = _connection.getPermission();
            if (perm instanceof java.io.FilePermission)
                return new File(perm.getName());
        } 
 
        // Try the URL file arg 
        try {return new File(_url.getFile());}
        catch(Exception e) {LogSupport.ignore(log,e);}
 
        // Don't know the file 
        return null;     
    } 
 
    /* ------------------------------------------------------------ */ 
    /** 
     * Returns the name of the resource 
     */ 
6
CodeRank
This code example shows how to use the following methods:getClass, getActions, getName
This code example shows how to use the following methods:newPermissionCollection
 
    /** 
     * Return array holding 3 collections: empty, single- and multi-element. 
     */ 
    protected Object[] getData() {
        Permission up1 = new UnresolvedPermission("131234", null, null, null);
        Permission up2 = new UnresolvedPermission("131234", "ui23rjh", null,
                null); 
        Permission up3 = new UnresolvedPermission("KUJKHVKJgyuygjhb", "xcv456",
                "26r ytf", new java.security.cert.Certificate[0]);
        PermissionCollection pc1 = up1.newPermissionCollection();
        PermissionCollection pc2 = up1.newPermissionCollection();
        pc2.add(up3);
        PermissionCollection pc3 = up1.newPermissionCollection();
        pc3.add(up1);
        pc3.add(up2);
        pc3.add(up3);
        return new Object[] { pc1, pc2, pc3 };
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getName, getActions
        ) 
    }) 
    public void testCtor() 
    { 
        String name = "basic123*$%#";
        SecurityPermission test = new SecurityPermission(name);
        assertEquals(name, test.getName());
        assertEquals("", test.getActions());
        test = new SecurityPermission(name, "#$!#12435");
        assertEquals(name, test.getName());
        assertEquals("", test.getActions());
        try{ 
            new SecurityPermission(null);
            fail("NPE is not thrown");
        } 
        catch (NullPointerException ok){}
 
        try{ 
            new SecurityPermission(null, "ds235");
            fail("NPE is not thrown");
6
CodeRank
This code example shows how to use the following methods:getActions, getName
     * @tests java.io.FilePermission#FilePermission(java.lang.String, 
     *        java.lang.String) 
     */ 
    public void test_ConstructorLjava_lang_StringLjava_lang_String() { 
        assertTrue("Used to test", true);
        FilePermission constructFile = new FilePermission("test constructor",
                "write"); 
        assertEquals(
                "action given to the constructor did not correspond - constructor failed", 
                "write", constructFile.getActions());
        assertTrue(
                "name given to the constructor did not correspond - constructor failed", 
                constructFile.getName() == "test constructor");
 
        // Regression test for HARMONY-1050 
        try { 
            new FilePermission(null, "drink");
            fail("Expected IAE");
        } catch (IllegalArgumentException e) {
            // Expected 
6
CodeRank
See Code Examples for Java 8 Permission Methods: