1 13 14 package org.ejbca.core.model.authorization; 15 16 import java.util.ArrayList ; 17 import java.util.Collections ; 18 import java.util.Collection ; 19 import java.util.Iterator ; 20 import java.io.Serializable ; 21 22 27 public class AdminGroup implements Serializable , Comparable { 28 29 30 31 public AdminGroup(String admingroupname, int caid) { 32 this.admingroupname=admingroupname; 33 this.caid=caid; 34 accessrules = new ArrayList (); 35 adminentities = new ArrayList (); 36 } 37 38 public AdminGroup(int admingroupid, String admingroupname, int caid, ArrayList accessrules, ArrayList adminentities){ 39 this.admingroupid=admingroupid; 40 this.admingroupname=admingroupname; 41 this.caid=caid; 42 this.accessrules=accessrules; 43 this.adminentities=adminentities; 44 } 45 46 48 public int getNumberOfAccessRules() { 49 return accessrules.size(); 50 } 51 52 53 public Collection getAccessRules() { 54 return accessrules; 55 } 56 57 58 public int getNumberAdminEntities() { 59 return adminentities.size(); 60 } 61 62 63 public Collection getAdminEntities() { 64 return adminentities; 65 } 66 67 public int getCAId(){ 68 return this.caid; 69 } 70 71 public int getAdminGroupId(){ 72 return this.admingroupid; 73 } 74 75 public String getAdminGroupName(){ 76 return this.admingroupname; 77 } 78 79 81 public Collection nonUsedAccessRules(Collection availableaccessrules){ 82 ArrayList nonusedaccessrules = new ArrayList (); 83 int result; 84 Collections.sort(accessrules); 85 if(availableaccessrules != null){ 86 Iterator iter = availableaccessrules.iterator(); 87 while(iter.hasNext()){ 88 String availableaccessrule = (String ) iter.next(); 89 result=java.util.Collections.binarySearch(accessrules,new AccessRule(availableaccessrule, 0, false)); 90 if(result < 0){ 91 nonusedaccessrules.add(availableaccessrule); 93 } 94 } 95 } 96 return nonusedaccessrules; 97 } 98 99 100 public int compareTo(Object o) { 101 if(caid != ((AdminGroup) o).getCAId()) 102 return caid - ((AdminGroup) o).getCAId(); 103 return admingroupname.compareTo(((AdminGroup)o).getAdminGroupName()); 104 } 105 106 108 private int admingroupid; 110 private String admingroupname; 111 private int caid; 112 private ArrayList accessrules; 113 private ArrayList adminentities; 114 } 115 | Popular Tags |