Team LiB
Previous Section Next Section

FilePermissionjava.io

Java 1.2serializable permission

This class is a java.security.Permission that governs access to the local filesystem. A FilePermission has a name, or target, which specifies what file or files it pertains to, and a commaseparated list of actions that may be performed on the file or files. The supported actions are read, write, delete, and execute. Read and write permission are required by any methods that read or write a file. Delete permission is required by File.delete( ), and execute permission is required by Runtime.exec( ).

The name of a FilePermission may be as simple as a file or directory name. FilePermission also supports the use of certain wildcards, however, to specify a permission that applies to more than one file. If the name of the FilePermission is a directory name followed by /* (\* on Windows platforms), it specifies all files in the named directory. If the name is a directory name followed by /- (\- on Windows), it specifies all files in the directory, and, recursively, all files in all subdirectories. A * alone specifies all files in the current directory, and a - alone specifies all files in or beneath the current directory. Finally, the special name <<ALL FILES>> matches all files anywhere in the filesystem.

Applications do not need to use this class directly. Programmers writing system-level code and system administrators configuring security policies may need to use it, however. Be very careful when granting any type of FilePermission. Restricting access (especially write access) to files is one of the cornerstones of the Java security model with regard to untrusted code.

Figure 9-18. java.io.FilePermission


public final class FilePermission extends java.security.Permission implements Serializable {
// Public Constructors
     public FilePermission(String path, String actions);  
// Public Methods Overriding Permission
     public boolean equals(Object obj);  
     public String getActions( );  
     public int hashCode( );  
     public boolean implies(java.security.Permission p);  
     public java.security.PermissionCollection newPermissionCollection( );  
}

    Team LiB
    Previous Section Next Section