365 throw new NullPointerException("name can't be null"); |
365 throw new NullPointerException("name can't be null"); |
366 |
366 |
367 this.mask = mask; |
367 this.mask = mask; |
368 |
368 |
369 if (cpath.equals("<<ALL FILES>>")) { |
369 if (cpath.equals("<<ALL FILES>>")) { |
|
370 allFiles = true; |
370 directory = true; |
371 directory = true; |
371 recursive = true; |
372 recursive = true; |
372 cpath = ""; |
373 cpath = ""; |
|
374 return; |
|
375 } |
|
376 |
|
377 // Validate path by platform's default file system |
|
378 try { |
|
379 String name = cpath.endsWith("*") ? cpath.substring(0, cpath.length() - 1) + "-" : cpath; |
|
380 builtInFS.getPath(new File(name).getPath()); |
|
381 } catch (InvalidPathException ipe) { |
|
382 invalid = true; |
373 return; |
383 return; |
374 } |
384 } |
375 |
385 |
376 // store only the canonical cpath if possible |
386 // store only the canonical cpath if possible |
377 cpath = AccessController.doPrivileged(new PrivilegedAction<>() { |
387 cpath = AccessController.doPrivileged(new PrivilegedAction<>() { |
574 * |
584 * |
575 * @param that the FilePermission to check against. |
585 * @param that the FilePermission to check against. |
576 * @return the effective mask |
586 * @return the effective mask |
577 */ |
587 */ |
578 boolean impliesIgnoreMask(FilePermission that) { |
588 boolean impliesIgnoreMask(FilePermission that) { |
|
589 if (this == that) { |
|
590 return true; |
|
591 } |
|
592 if (allFiles) { |
|
593 return true; |
|
594 } |
|
595 if (this.invalid || that.invalid) { |
|
596 return false; |
|
597 } |
|
598 if (that.allFiles) { |
|
599 return false; |
|
600 } |
579 if (FilePermCompat.nb) { |
601 if (FilePermCompat.nb) { |
580 if (this == that) { |
|
581 return true; |
|
582 } |
|
583 if (allFiles) { |
|
584 return true; |
|
585 } |
|
586 if (this.invalid || that.invalid) { |
|
587 return false; |
|
588 } |
|
589 if (that.allFiles) { |
|
590 return false; |
|
591 } |
|
592 // Left at least same level of wildness as right |
602 // Left at least same level of wildness as right |
593 if ((this.recursive && that.recursive) != that.recursive |
603 if ((this.recursive && that.recursive) != that.recursive |
594 || (this.directory && that.directory) != that.directory) { |
604 || (this.directory && that.directory) != that.directory) { |
595 return false; |
605 return false; |
596 } |
606 } |
784 if (! (obj instanceof FilePermission)) |
794 if (! (obj instanceof FilePermission)) |
785 return false; |
795 return false; |
786 |
796 |
787 FilePermission that = (FilePermission) obj; |
797 FilePermission that = (FilePermission) obj; |
788 |
798 |
|
799 if (this.invalid || that.invalid) { |
|
800 return false; |
|
801 } |
789 if (FilePermCompat.nb) { |
802 if (FilePermCompat.nb) { |
790 if (this.invalid || that.invalid) { |
|
791 return false; |
|
792 } |
|
793 return (this.mask == that.mask) && |
803 return (this.mask == that.mask) && |
794 (this.allFiles == that.allFiles) && |
804 (this.allFiles == that.allFiles) && |
795 this.npath.equals(that.npath) && |
805 this.npath.equals(that.npath) && |
796 Objects.equals(npath2, that.npath2) && |
806 Objects.equals(npath2, that.npath2) && |
797 (this.directory == that.directory) && |
807 (this.directory == that.directory) && |
798 (this.recursive == that.recursive); |
808 (this.recursive == that.recursive); |
799 } else { |
809 } else { |
800 return (this.mask == that.mask) && |
810 return (this.mask == that.mask) && |
|
811 (this.allFiles == that.allFiles) && |
801 this.cpath.equals(that.cpath) && |
812 this.cpath.equals(that.cpath) && |
802 (this.directory == that.directory) && |
813 (this.directory == that.directory) && |
803 (this.recursive == that.recursive); |
814 (this.recursive == that.recursive); |
804 } |
815 } |
805 } |
816 } |