home *** CD-ROM | disk | FTP | other *** search
- package java.io;
-
- import java.security.AccessController;
- import java.security.Permission;
- import java.security.PermissionCollection;
- import sun.security.action.GetPropertyAction;
-
- public final class FilePermission extends Permission implements Serializable {
- private static final int EXECUTE = 1;
- private static final int WRITE = 2;
- private static final int READ = 4;
- private static final int DELETE = 8;
- private static final int ALL = 15;
- private static final int NONE = 0;
- private transient int mask;
- private transient boolean directory;
- private transient boolean recursive;
- private String actions;
- private transient String cpath;
- private static final String RECURSIVE = "-";
- private static final String WILD = "*";
- private static final String SEP_RECURSIVE;
- private static final String SEP_WILD;
- private static final long serialVersionUID = 7930732926638008763L;
-
- private void init(int var1) {
- if ((var1 & 15) != var1) {
- throw new IllegalArgumentException("invalid actions mask");
- } else if (var1 == 0) {
- throw new IllegalArgumentException("invalid actions mask");
- } else if (((Permission)this).getName() == null) {
- throw new NullPointerException("name can't be null");
- } else {
- this.mask = var1;
- this.cpath = ((Permission)this).getName();
- if (this.cpath.equals("<<ALL FILES>>")) {
- this.directory = true;
- this.recursive = true;
- this.cpath = "";
- } else {
- if (!this.cpath.endsWith(SEP_RECURSIVE) && !this.cpath.equals("-")) {
- if (this.cpath.endsWith(SEP_WILD) || this.cpath.equals("*")) {
- this.directory = true;
- this.cpath = this.cpath.substring(0, this.cpath.length() - 1);
- }
- } else {
- this.directory = true;
- this.recursive = true;
- this.cpath = this.cpath.substring(0, this.cpath.length() - 1);
- }
-
- if (this.cpath.equals("")) {
- this.cpath = (String)AccessController.doPrivileged(new GetPropertyAction("user.dir"));
- }
-
- this.cpath = (String)AccessController.doPrivileged(new 1(this));
- }
- }
- }
-
- public FilePermission(String var1, String var2) {
- super(var1);
- this.init(getMask(var2));
- }
-
- FilePermission(String var1, int var2) {
- super(var1);
- this.init(var2);
- }
-
- public boolean implies(Permission var1) {
- if (!(var1 instanceof FilePermission)) {
- return false;
- } else {
- FilePermission var2 = (FilePermission)var1;
- return (this.mask & var2.mask) == var2.mask && this.impliesIgnoreMask(var2);
- }
- }
-
- boolean impliesIgnoreMask(FilePermission var1) {
- if (this.directory) {
- if (!this.recursive) {
- if (var1.directory) {
- return var1.recursive ? false : this.cpath.equals(var1.cpath);
- } else {
- int var2 = var1.cpath.lastIndexOf(File.separatorChar);
- if (var2 == -1) {
- return false;
- } else {
- String var3 = var1.cpath.substring(0, var2 + 1);
- return this.cpath.equals(var3);
- }
- }
- } else if (var1.directory) {
- return var1.cpath.length() >= this.cpath.length() && var1.cpath.startsWith(this.cpath);
- } else {
- return var1.cpath.length() > this.cpath.length() && var1.cpath.startsWith(this.cpath);
- }
- } else {
- return this.cpath.equals(var1.cpath);
- }
- }
-
- public boolean equals(Object var1) {
- if (var1 == this) {
- return true;
- } else if (!(var1 instanceof FilePermission)) {
- return false;
- } else {
- FilePermission var2 = (FilePermission)var1;
- return this.mask == var2.mask && this.cpath.equals(var2.cpath) && this.directory == var2.directory && this.recursive == var2.recursive;
- }
- }
-
- public int hashCode() {
- return this.cpath.hashCode();
- }
-
- private static int getMask(String param0) {
- // $FF: Couldn't be decompiled
- }
-
- int getMask() {
- return this.mask;
- }
-
- private static String getActions(int var0) {
- StringBuffer var1 = new StringBuffer();
- boolean var2 = false;
- if ((var0 & 4) == 4) {
- var2 = true;
- var1.append("read");
- }
-
- if ((var0 & 2) == 2) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("write");
- }
-
- if ((var0 & 1) == 1) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("execute");
- }
-
- if ((var0 & 8) == 8) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("delete");
- }
-
- return var1.toString();
- }
-
- public String getActions() {
- if (this.actions == null) {
- this.actions = getActions(this.mask);
- }
-
- return this.actions;
- }
-
- public PermissionCollection newPermissionCollection() {
- return new FilePermissionCollection();
- }
-
- private synchronized void writeObject(ObjectOutputStream var1) throws IOException {
- if (this.actions == null) {
- this.getActions();
- }
-
- var1.defaultWriteObject();
- }
-
- private synchronized void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
- var1.defaultReadObject();
- this.init(getMask(this.actions));
- }
-
- // $FF: synthetic method
- static String access$000(FilePermission var0) {
- return var0.cpath;
- }
-
- // $FF: synthetic method
- static boolean access$100(FilePermission var0) {
- return var0.directory;
- }
-
- static {
- SEP_RECURSIVE = File.separator + "-";
- SEP_WILD = File.separator + "*";
- }
- }
-