home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / security / BasicPermission.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  1.7 KB  |  86 lines

  1. package java.security;
  2.  
  3. import java.io.IOException;
  4. import java.io.ObjectInputStream;
  5. import java.io.Serializable;
  6.  
  7. public abstract class BasicPermission extends Permission implements Serializable {
  8.    private transient boolean wildcard;
  9.    private transient String path;
  10.  
  11.    private void init(String var1) {
  12.       if (var1 == null) {
  13.          throw new NullPointerException("name can't be null");
  14.       } else if (var1.equals("")) {
  15.          throw new IllegalArgumentException("name can't be empty");
  16.       } else {
  17.          if (!var1.endsWith(".*") && !var1.equals("*")) {
  18.             this.path = var1;
  19.          } else {
  20.             this.wildcard = true;
  21.             if (var1.length() == 1) {
  22.                this.path = "";
  23.             } else {
  24.                this.path = var1.substring(0, var1.length() - 1);
  25.             }
  26.          }
  27.  
  28.       }
  29.    }
  30.  
  31.    public BasicPermission(String var1) {
  32.       super(var1);
  33.       this.init(var1);
  34.    }
  35.  
  36.    public BasicPermission(String var1, String var2) {
  37.       super(var1);
  38.       this.init(var1);
  39.    }
  40.  
  41.    public boolean implies(Permission var1) {
  42.       if (var1 != null && var1.getClass() == this.getClass()) {
  43.          BasicPermission var2 = (BasicPermission)var1;
  44.          if (this.wildcard) {
  45.             if (var2.wildcard) {
  46.                return var2.path.startsWith(this.path);
  47.             } else {
  48.                return var2.path.length() > this.path.length() && var2.path.startsWith(this.path);
  49.             }
  50.          } else {
  51.             return var2.wildcard ? false : this.path.equals(var2.path);
  52.          }
  53.       } else {
  54.          return false;
  55.       }
  56.    }
  57.  
  58.    public boolean equals(Object var1) {
  59.       if (var1 == this) {
  60.          return true;
  61.       } else if (var1 != null && var1.getClass() == this.getClass()) {
  62.          BasicPermission var2 = (BasicPermission)var1;
  63.          return ((Permission)this).getName().equals(((Permission)var2).getName());
  64.       } else {
  65.          return false;
  66.       }
  67.    }
  68.  
  69.    public int hashCode() {
  70.       return ((Permission)this).getName().hashCode();
  71.    }
  72.  
  73.    public String getActions() {
  74.       return "";
  75.    }
  76.  
  77.    public PermissionCollection newPermissionCollection() {
  78.       return new BasicPermissionCollection();
  79.    }
  80.  
  81.    private synchronized void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  82.       var1.defaultReadObject();
  83.       this.init(((Permission)this).getName());
  84.    }
  85. }
  86.