src/java.base/share/classes/java/io/FilePermission.java
changeset 58653 71fef5fae9cc
parent 58617 037ca385e957
child 58679 9c3209ff7550
equal deleted inserted replaced
58652:9b67dd88a931 58653:71fef5fae9cc
   478      * but setting a system property will override the security property value.
   478      * but setting a system property will override the security property value.
   479      *
   479      *
   480      * @param path the pathname of the file/directory.
   480      * @param path the pathname of the file/directory.
   481      * @param actions the action string.
   481      * @param actions the action string.
   482      *
   482      *
   483      * @throws IllegalArgumentException
   483      * @throws IllegalArgumentException if actions is {@code null}, empty,
   484      *          If actions is {@code null}, empty or contains an action
   484      *         malformed or contains an action other than the specified
   485      *          other than the specified possible actions.
   485      *         possible actions
   486      */
   486      */
   487     public FilePermission(String path, String actions) {
   487     public FilePermission(String path, String actions) {
   488         super(path);
   488         super(path);
   489         init(getMask(actions));
   489         init(getMask(actions));
   490     }
   490     }
   933                 throw new IllegalArgumentException(
   933                 throw new IllegalArgumentException(
   934                         "invalid permission: " + actions);
   934                         "invalid permission: " + actions);
   935             }
   935             }
   936 
   936 
   937             // make sure we didn't just match the tail of a word
   937             // make sure we didn't just match the tail of a word
   938             // like "ackbarfaccept".  Also, skip to the comma.
   938             // like "ackbarfdelete".  Also, skip to the comma.
   939             boolean seencomma = false;
   939             boolean seencomma = false;
   940             while (i >= matchlen && !seencomma) {
   940             while (i >= matchlen && !seencomma) {
   941                 switch(a[i-matchlen]) {
   941                 switch (c = a[i-matchlen]) {
   942                 case ',':
       
   943                     seencomma = true;
       
   944                     break;
       
   945                 case ' ': case '\r': case '\n':
   942                 case ' ': case '\r': case '\n':
   946                 case '\f': case '\t':
   943                 case '\f': case '\t':
   947                     break;
   944                     break;
   948                 default:
   945                 default:
       
   946                     if (c == ',' && i > matchlen) {
       
   947                         seencomma = true;
       
   948                         break;
       
   949                     }
   949                     throw new IllegalArgumentException(
   950                     throw new IllegalArgumentException(
   950                             "invalid permission: " + actions);
   951                             "invalid permission: " + actions);
   951                 }
   952                 }
   952                 i--;
   953                 i--;
   953             }
   954             }
  1139      * Adds a permission to the FilePermissionCollection. The key for the hash is
  1140      * Adds a permission to the FilePermissionCollection. The key for the hash is
  1140      * permission.path.
  1141      * permission.path.
  1141      *
  1142      *
  1142      * @param permission the Permission object to add.
  1143      * @param permission the Permission object to add.
  1143      *
  1144      *
  1144      * @throws    IllegalArgumentException - if the permission is not a
  1145      * @throws    IllegalArgumentException   if the permission is not a
  1145      *                                       FilePermission
  1146      *                                       FilePermission
  1146      *
  1147      *
  1147      * @throws    SecurityException - if this FilePermissionCollection object
  1148      * @throws    SecurityException   if this FilePermissionCollection object
  1148      *                                has been marked readonly
  1149      *                                has been marked readonly
  1149      */
  1150      */
  1150     @Override
  1151     @Override
  1151     public void add(Permission permission) {
  1152     public void add(Permission permission) {
  1152         if (! (permission instanceof FilePermission))
  1153         if (! (permission instanceof FilePermission))