1 13 14 package org.ejbca.ui.web.admin.configuration; 15 16 import java.util.ArrayList ; 17 import java.util.Collection ; 18 import java.util.Collections ; 19 import java.util.Iterator ; 20 21 import org.ejbca.core.model.authorization.AccessRule; 22 import org.ejbca.core.model.authorization.AvailableAccessRules; 23 24 25 30 public class AccessRulesView implements java.io.Serializable { 31 32 33 37 public AccessRulesView(Collection accessrules){ 38 this.rolebasedaccessrules = new ArrayList (); 39 this.regularaccessrules = new ArrayList (); 40 this.endentityprofileaccessrules = new ArrayList (); 41 this.caaccessrules = new ArrayList (); 42 43 44 Iterator iter = accessrules.iterator(); 45 while(iter.hasNext()){ 46 Object obj = iter.next(); 47 String accessrulestring = ""; 48 AccessRule accessrule = null; 49 if( obj instanceof AccessRule ){ 50 accessrulestring = ((AccessRule) obj).getAccessRule(); 51 accessrule = (AccessRule) obj; 52 }else{ 53 accessrulestring = (String ) obj; 54 accessrule = new AccessRule(accessrulestring, 0, false); 55 } 56 boolean regular = true; 57 58 for(int i=0; i< AvailableAccessRules.ROLEACCESSRULES.length; i++){ 60 if(accessrulestring.equals(AvailableAccessRules.ROLEACCESSRULES[i])){ 61 this.rolebasedaccessrules.add(accessrule); 62 regular=false; 63 } 64 } 65 66 if(accessrulestring.startsWith("/endentityprofilesrules")){ 68 this.endentityprofileaccessrules.add(accessrule); 69 regular=false; 70 } 71 72 if(accessrulestring.startsWith(AvailableAccessRules.CAPREFIX) || accessrulestring.equals(AvailableAccessRules.CABASE)){ 74 this.caaccessrules.add(accessrule); 75 regular=false; 76 } 77 78 if(regular) 80 this.regularaccessrules.add(accessrule); 81 82 } 83 84 Collections.sort(this.rolebasedaccessrules); 85 Collections.sort(this.regularaccessrules); 86 Collections.sort(this.endentityprofileaccessrules); 87 Collections.sort(this.caaccessrules); 88 89 } 90 91 92 95 public Collection getRoleBasedAccessRules(){ 96 return this.rolebasedaccessrules; 97 } 98 99 102 public Collection getRegularAccessRules(){ 103 return this.regularaccessrules; 104 } 105 106 109 public Collection getEndEntityProfileAccessRules(){ 110 return this.endentityprofileaccessrules; 111 } 112 113 116 public Collection getCAAccessRules(){ 117 return this.caaccessrules; 118 } 119 120 122 private ArrayList rolebasedaccessrules; 124 private ArrayList regularaccessrules; 125 private ArrayList endentityprofileaccessrules; 126 private ArrayList caaccessrules; 127 } 128 | Popular Tags |