Permission java security framework study notes

A, permission and security policy

    java.security.Permission permission to access system resources on behalf of a system resource, Perm = new new java.io.FilePermission ( "/ tmp / abc", "the Read"): This is a file permissions, is a peer "/ tmp / read abc "file" "permissions.

    Examples of one implementation of this method is a subclass of A a.implies (b):: public abstract boolean implies (Permission permission) to determine whether there is authority a, you will have permission b. There are two classes associated with the Permission class: abstract class java.security.PermissionCollection, final java.security.Permissions class, a representative of the former type of permission set (eg: FilePermission), which represents such a variety of permissions, to maintain a save PermissionCollection the map

    java.security.UnresolvedPermission: internal state security policy is represented by a rights object associated with each code source. However, it may at initialization strategy, implementation code special permission has not been loaded and defined, for example, referenced permission class may be in later to load the JAR file, an UnresolvedPermission is used to save these "unresolved" permissions. When permission check, before no authority to resolve, then you have parsed. In other words, a new object of the appropriate type has been initialized, then use this new object to replace the deleted UnresolvedPermission

    java.io.FilePermission 

file
directory (same as directory/)
directory/file
directory/* (all files in this directory)
* (all files in the current directory)
directory/- (all files in the file system under this directory)
- (all files in the file system under the current directory)
"<< ALL FILES >>" (all files in the file system), on behalf of all files under the root directory in linux system 

implies judgment: whether it has a privilege, it means having another privilege FilePermission ( "/ -", "Read, Execute") the implies FilePermission ( "/ Home / Gong / public_html / index.html", "Read")

FilePermission new new FilePermission P = ( "C: \\ TEMP \\ foo", "Read"), use of a spinning righteous character represents the correct string, such as: "\ n" represent the newline
parsed path: "c: \ temp \ foo ".
Note:
FilePermission the p-new new FilePermission = ( "/ home / gong /", "the Read"), has only lists the permissions of all files under "/ home / gong /" directory, not read
permission, want to read the directory files, the need to use the "*" or "-." Note: The code automatically have permission to read and write files in the current directory and subdirectories of.
 


Guess you like

Origin www.cnblogs.com/dengrong/p/11077271.html