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

This code example shows how to use the following methods:
    static { 
        final Permissions permissions = new Permissions();
        permissions.add(new PropertyPermission("*", "read"));
        permissions.add(new RuntimePermission("queuePrintJob"));
        permissions.add(new RuntimePermission("loadLibrary"));
        permissions.add(new FilePermission("*", "read"));
        permissions.add(new FilePermission("*", "write"));
        permissions.add(new SocketPermission("*", "connect"));
        DEFAULT_PERMISSIONS = permissions;
    } 
 
    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
        final ModuleSpecification attachment = phaseContext.getDeploymentUnit().getAttachment(Attachments.MODULE_SPECIFICATION);
        if (attachment == null) {
            return; 
        } 
        if(!enabled) {
            return; 
        } 
        if (!EjbDeploymentMarker.isEjbDeployment(phaseContext.getDeploymentUnit())) {
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:toString
 */ 
public class PermissionParserTest { 
     
    @Test
    public void parsing() { 
        final FilePermission filePermission = new FilePermission("/", "read");
        Assert.assertEquals(filePermission,
                PermissionParser.getPermission( 
                "(java.io.FilePermission \"/\" \"read\")")); 
        Assert.assertEquals(filePermission,
                PermissionParser.getPermission( 
                filePermission.toString()));
        Assert.assertEquals(new AllPermission(),
                PermissionParser.getPermission( 
                "(java.security.AllPermission)")); 
        Assert.assertEquals(new AllPermission(),
                PermissionParser.getPermission( 
                "(java.security.AllPermission \"\")")); 
        Assert.assertEquals(new AllPermission(),
                PermissionParser.getPermission( 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        PermissionCollection barPermissionCollection = ap.getPermissions(cs);
 
        assertNotNull( barPermissionCollection );
 
        Permission testBarPerm = new FilePermission("/tmp/*","read,write");
        Permission testBarPerm2 = new FilePermission("/usr/*","read"); // only read was granted
        Permission testBarPerm3 = new FilePermission("/usr/*","write"); // only read was granted
 
        assertTrue( barPermissionCollection.implies( testBarPerm ) );
        assertTrue( barPermissionCollection.implies( testBarPerm2 ) );
        assertFalse( barPermissionCollection.implies( testBarPerm3 ) );
         
        // test the global permission grant 
        PermissionCollection globalPermissionCollection = ap.getPermissions( new ProtectionDomain( null, null ) );
         
        assertNotNull( globalPermissionCollection );
         
        Permission testPropertyPermission = new PropertyPermission("main.class","read");
        assertTrue( globalPermissionCollection.implies(testPropertyPermission));
        // its global so it ought to be global, double check that 

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
      System.setSecurityManager(new SecurityManager()); 
      authHelper.createTestUser("testuser", "testpassword"); 
      authHelper.loginTestUser(); 
      Subject subject = authHelper.getSubject(); 
 
      final FilePermission filePerm = new FilePermission( 
          "/tmp/test", "read"); 
 
      boolean allowed = true; 
      try { 
        Subject.doAsPrivileged(subject, new PrivilegedAction() { 
 
          public Object run() { 
            SecurityManager sm = System.getSecurityManager(); 
            if (sm != null) { 
              sm.checkPermission(filePerm); 
            } 
            return null; 
          } 
 

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getActions
			FilePermission filePermission = (FilePermission) perm;
			// Get the fileSystemManager 
			RobotFileSystemManager fileSystemManager = robotProxy.getRobotFileSystemManager();
 
			// Robot wants access to read something 
			if (filePermission.getActions().equals("read")) {
				return impliesRobotFileRead(robotProxy, fileSystemManager, filePermission);
 
			} // Robot wants access to write something 
			else if (filePermission.getActions().equals("write")) {
				return impliesRobotFileWrite(robotProxy, fileSystemManager, filePermission);
 
			} // Robot wants access to write something 
			else if (filePermission.getActions().equals("delete")) {
				return impliesRobotFileDelete(robotProxy, fileSystemManager, filePermission);
 
			} 
		} 
 
		// check package access 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        assertEquals(url, element.getUrl()); 
    } 
 
    @Test public void testGrantPermission() throws Exception{ 
        ClassPathElement element = new ClassPathElement(new URL("file:///usr/lib")); 
        element.grantPermission(new FilePermission("/usr/lib", "read")); 
        assertNotNull(element.getPermissionCollection()); 
    } 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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
Connect your IDE to all the code out there  Get Codota for Java
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
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getClass, getActions, getName
See Code Examples for Java 8 FilePermission Methods: