1 13 14 19 20 package org.ejbca.core.model.authorization; 21 22 import java.io.Serializable ; 23 24 25 33 public class AccessRule implements Serializable , Comparable { 34 public static final int RULE_ACCEPT = 1; 36 public static final int RULE_DECLINE = 2; 37 38 39 public AccessRule(String accessrule, int rule, boolean recursive ) { 40 this.accessrule=accessrule.trim(); 41 this.rule=rule; 42 this.recursive=recursive; 43 44 setState(); 45 } 46 47 public int getRule() { 48 return rule; 49 } 50 51 public boolean isRecursive() { 52 return recursive; 53 } 54 55 public String getAccessRule() { 56 return accessrule; 57 } 58 59 public void setRule(int rule) { 60 this.rule=rule; 61 setState(); 62 } 63 64 public void setRecursive(boolean recursive) { 65 this.recursive=recursive; 66 setState(); 67 } 68 69 public void setAccessRule(String accessrule) { 70 this.accessrule=accessrule.trim(); 71 } 72 73 74 public int getRuleState(){ 75 return state; 76 } 77 78 public int compareTo(Object obj) { 79 return accessrule.compareTo(((AccessRule)obj).getAccessRule()); 80 } 81 82 private void setState(){ 84 if(recursive){ 85 switch(rule){ 86 case RULE_ACCEPT: 87 state = AccessTreeNode.STATE_ACCEPT_RECURSIVE; 88 break; 89 case RULE_DECLINE: 90 state = AccessTreeNode.STATE_DECLINE_RECURSIVE; 91 break; 92 default: 93 } 94 } 95 else{ 96 switch(rule){ 97 case RULE_ACCEPT: 98 state = AccessTreeNode.STATE_ACCEPT; 99 break; 100 case RULE_DECLINE: 101 state = AccessTreeNode.STATE_DECLINE; 102 break; 103 default: 104 } 105 } 106 } 107 108 private boolean recursive; 110 private int rule; 111 private String accessrule; 112 private int state; } 114 | Popular Tags |