src/share/classes/java/io/FilePermission.java

Print this page

        

@@ -74,11 +74,11 @@
  * <P>
  * The actions string is converted to lowercase before processing.
  * <P>
  * Be careful when granting FilePermissions. Think about the implications
  * of granting read and especially write access to various files and
- * directories. The "&lt;&lt;ALL FILES>>" permission with write action is
+ * directories. The "&lt;&lt;ALL FILES&gt;&gt;" permission with write action is
  * especially dangerous. This grants permission to write to the entire
  * file system. One thing this effectively allows is replacement of the
  * system binary, including the JVM runtime environment.
  *
  * <p>Please note: Code can always read a file from the same

@@ -178,13 +178,11 @@
      * Also called during de-serialization.
      *
      * @param mask the actions mask to use.
      *
      */
-    private void init(int mask)
-    {
-
+    private void init(int mask) {
         if ((mask & ALL) != mask)
                 throw new IllegalArgumentException("invalid actions mask");
 
         if (mask == NONE)
                 throw new IllegalArgumentException("invalid actions mask");

@@ -272,13 +270,11 @@
      *
      * @throws IllegalArgumentException
      *          If actions is <code>null</code>, empty or contains an action
      *          other than the specified possible actions.
      */
-
-    public FilePermission(String path, String actions)
-    {
+    public FilePermission(String path, String actions) {
         super(path);
         init(getMask(actions));
     }
 
     /**

@@ -291,12 +287,11 @@
      * @param path the pathname of the file/directory.
      * @param mask the action mask to use.
      */
 
     // package private for use by the FilePermissionCollection add method
-    FilePermission(String path, int mask)
-    {
+    FilePermission(String path, int mask) {
         super(path);
         init(mask);
     }
 
     /**

@@ -335,11 +330,10 @@
      * Checks if the Permission's actions are a proper subset of the
      * this object's actions. Returns the effective mask iff the
      * this FilePermission's path also implies that FilePermission's path.
      *
      * @param that the FilePermission to check against.
-     * @param exact return immediately if the masks are not equal
      * @return the effective mask
      */
     boolean impliesIgnoreMask(FilePermission that) {
         if (this.directory) {
             if (this.recursive) {

@@ -410,11 +404,10 @@
     /**
      * Returns the hash code value for this object.
      *
      * @return a hash code value for this object.
      */
-
     public int hashCode() {
         return this.cpath.hashCode();
     }
 
     /**

@@ -422,11 +415,10 @@
      *
      * @param actions the action string.
      * @return the actions mask.
      */
     private static int getMask(String actions) {
-
         int mask = NONE;
 
         // Null action valid?
         if (actions == null) {
             return mask;

@@ -550,11 +542,10 @@
     /**
      * Return the current action mask. Used by the FilePermissionCollection.
      *
      * @return the actions mask.
      */
-
     int getMask() {
         return mask;
     }
 
     /**

@@ -562,12 +553,11 @@
      * Always returns present actions in the following order:
      * read, write, execute, delete, readlink.
      *
      * @return the canonical string representation of the actions.
      */
-    private static String getActions(int mask)
-    {
+    private static String getActions(int mask) {
         StringBuilder sb = new StringBuilder();
         boolean comma = false;
 
         if ((mask & READ) == READ) {
             comma = true;

@@ -608,19 +598,17 @@
      * object allows both write and read actions, a call to <code>getActions</code>
      * will return the string "read,write".
      *
      * @return the canonical string representation of the actions.
      */
-    public String getActions()
-    {
+    public String getActions() {
         if (actions == null)
             actions = getActions(this.mask);
 
         return actions;
     }
 
-
     /**
      * Returns a new PermissionCollection object for storing FilePermission
      * objects.
      * <p>
      * FilePermission objects must be stored in a manner that allows them

@@ -648,11 +636,10 @@
      * returned by this <code>newPermissionCollection</code> method.
      *
      * @return a new PermissionCollection object suitable for storing
      * FilePermissions.
      */
-
     public PermissionCollection newPermissionCollection() {
         return new FilePermissionCollection();
     }
 
     /**

@@ -710,26 +697,24 @@
  * @serial include
  *
  */
 
 final class FilePermissionCollection extends PermissionCollection
-implements Serializable {
-
+    implements Serializable
+{
     // Not serialized; see serialization section at end of class
     private transient List<Permission> perms;
 
     /**
-     * Create an empty FilePermissions object.
-     *
+     * Create an empty FilePermissionCollection object.
      */
-
     public FilePermissionCollection() {
         perms = new ArrayList<>();
     }
 
     /**
-     * Adds a permission to the FilePermissions. The key for the hash is
+     * Adds a permission to the FilePermissionCollection. The key for the hash is
      * permission.path.
      *
      * @param permission the Permission object to add.
      *
      * @exception IllegalArgumentException - if the permission is not a

@@ -736,13 +721,11 @@
      *                                       FilePermission
      *
      * @exception SecurityException - if this FilePermissionCollection object
      *                                has been marked readonly
      */
-
-    public void add(Permission permission)
-    {
+    public void add(Permission permission) {
         if (! (permission instanceof FilePermission))
             throw new IllegalArgumentException("invalid permission: "+
                                                permission);
         if (isReadOnly())
             throw new SecurityException(

@@ -755,18 +738,16 @@
 
     /**
      * Check and see if this set of permissions implies the permissions
      * expressed in "permission".
      *
-     * @param p the Permission object to compare
+     * @param permission the Permission object to compare
      *
      * @return true if "permission" is a proper subset of a permission in
      * the set, false if not.
      */
-
-    public boolean implies(Permission permission)
-    {
+    public boolean implies(Permission permission) {
         if (! (permission instanceof FilePermission))
                 return false;
 
         FilePermission fp = (FilePermission) permission;
 

@@ -793,11 +774,10 @@
      * Returns an enumeration of all the FilePermission objects in the
      * container.
      *
      * @return an enumeration of all the FilePermission objects.
      */
-
     public Enumeration<Permission> elements() {
         // Convert Iterator into Enumeration
         synchronized (this) {
             return Collections.enumeration(perms);
         }

@@ -839,12 +819,13 @@
     }
 
     /*
      * Reads in a Vector of FilePermissions and saves them in the perms field.
      */
-    private void readObject(ObjectInputStream in) throws IOException,
-    ClassNotFoundException {
+    private void readObject(ObjectInputStream in)
+        throws IOException, ClassNotFoundException
+    {
         // Don't call defaultReadObject()
 
         // Read in serialized fields
         ObjectInputStream.GetField gfields = in.readFields();