home *** CD-ROM | disk | FTP | other *** search
- package netscape.security;
-
- import netscape.util.ClassInfo;
- import netscape.util.Codable;
- import netscape.util.CodingException;
- import netscape.util.Decoder;
- import netscape.util.Encoder;
-
- public final class Privilege implements Codable {
- static final int VERSION = 1;
- public static final int N_PERMISSIONS = 3;
- public static final int FORBIDDEN = 0;
- public static final int ALLOWED = 1;
- public static final int BLANK = 2;
- private int itsPerm;
- public static final int N_DURATIONS = 3;
- public static final int SCOPE = 0;
- public static final int SESSION = 1;
- public static final int FOREVER = 2;
- private int itsDuration;
- private boolean itsInited = false;
- private static Privilege[][] itsPrivilegeCache = new Privilege[3][3];
-
- public Privilege() {
- }
-
- private Privilege(int var1, int var2) {
- this.itsPerm = var1;
- this.itsDuration = var2;
- this.itsInited = true;
- }
-
- public static Privilege findPrivilege(int var0, int var1) {
- return itsPrivilegeCache[var0][var1];
- }
-
- public static int add(int var0, int var1) {
- return var0 < var1 ? var0 : var1;
- }
-
- public static Privilege add(Privilege var0, Privilege var1) {
- return var0.itsPerm < var1.itsPerm ? var0 : var1;
- }
-
- public boolean samePermission(Privilege var1) {
- return var1.itsPerm == this.itsPerm;
- }
-
- public boolean samePermission(int var1) {
- return this.itsPerm == var1;
- }
-
- public boolean sameDuration(Privilege var1) {
- return var1.itsDuration == this.itsDuration;
- }
-
- public boolean sameDuration(int var1) {
- return this.itsDuration == var1;
- }
-
- public boolean isAllowed() {
- return this.itsPerm == 1;
- }
-
- public boolean isForbidden() {
- return this.itsPerm == 0;
- }
-
- public boolean isBlank() {
- return this.itsPerm == 2;
- }
-
- public int getPermission() {
- return this.itsPerm;
- }
-
- public int getDuration() {
- return this.itsDuration;
- }
-
- public String toString() {
- String var1 = null;
- String var2 = null;
- switch (this.itsPerm) {
- case 0:
- var1 = "forbidden";
- break;
- case 1:
- var1 = "allowed";
- break;
- case 2:
- var1 = "blank";
- }
-
- switch (this.itsDuration) {
- case 0:
- var2 = var1 + " in the current scope";
- break;
- case 1:
- var2 = var1 + " in the current browser session";
- break;
- case 2:
- var2 = var1 + " forever";
- }
-
- return var2;
- }
-
- public void describeClassInfo(ClassInfo var1) {
- var1.addClass("Privilege", 1);
- var1.addField("Perm", (byte)8);
- var1.addField("Duration", (byte)8);
- }
-
- public void encode(Encoder var1) throws CodingException {
- var1.encodeInt("Perm", this.itsPerm);
- var1.encodeInt("Duration", this.itsDuration);
- }
-
- public void decode(Decoder var1) throws CodingException {
- if (!this.itsInited) {
- this.itsInited = true;
- this.itsPerm = var1.decodeInt("Perm");
- this.itsDuration = var1.decodeInt("Duration");
- }
- }
-
- public void finishDecoding() throws CodingException {
- }
-
- static {
- for(int var0 = 0; var0 < 3; ++var0) {
- for(int var1 = 0; var1 < 3; ++var1) {
- itsPrivilegeCache[var0][var1] = new Privilege(var0, var1);
- }
- }
-
- }
- }
-