1 11 12 13 package com.sun.jmx.snmp.IPAcl; 14 15 16 17 import java.util.Vector ; 18 import java.util.Enumeration ; 19 import java.io.Serializable ; 20 import java.net.UnknownHostException ; 21 22 import java.security.Principal ; 23 import java.security.acl.AclEntry ; 24 25 26 35 36 class AclEntryImpl implements AclEntry , Serializable { 37 38 private AclEntryImpl (AclEntryImpl i) throws UnknownHostException { 39 setPrincipal(i.getPrincipal()); 40 permList = new Vector (); 41 commList = new Vector (); 42 43 for (Enumeration en = i.communities(); en.hasMoreElements();){ 44 addCommunity((String )en.nextElement()); 45 } 46 47 for (Enumeration en = i.permissions(); en.hasMoreElements();){ 48 addPermission((java.security.acl.Permission )en.nextElement()); 49 } 50 if (i.isNegative()) setNegativePermissions(); 51 } 52 53 56 public AclEntryImpl (){ 57 princ = null; 58 permList = new Vector (); 59 commList = new Vector (); 60 } 61 62 67 public AclEntryImpl (Principal p) throws UnknownHostException { 68 princ = p; 69 permList = new Vector (); 70 commList = new Vector (); 71 } 72 73 78 public Object clone() { 79 AclEntryImpl i; 80 try { 81 i = new AclEntryImpl(this); 82 }catch (UnknownHostException e) { 83 i = null; 84 } 85 return (Object ) i; 86 } 87 88 94 public boolean isNegative(){ 95 return neg; 96 } 97 98 108 public boolean addPermission(java.security.acl.Permission perm){ 109 if (permList.contains(perm)) return false; 110 permList.addElement(perm); 111 return true; 112 } 113 114 121 public boolean removePermission(java.security.acl.Permission perm){ 122 if (!permList.contains(perm)) return false; 123 permList.removeElement(perm); 124 return true; 125 } 126 127 135 136 public boolean checkPermission(java.security.acl.Permission perm){ 137 return (permList.contains(perm)); 138 } 139 140 145 public Enumeration permissions(){ 146 return permList.elements(); 147 } 148 149 157 public void setNegativePermissions(){ 158 neg = true; 159 } 160 161 167 public Principal getPrincipal(){ 168 return princ; 169 } 170 171 180 public boolean setPrincipal(Principal p) { 181 if (princ != null ) 182 return false; 183 princ = p; 184 return true; 185 } 186 187 192 public String toString(){ 193 return "AclEntry:"+princ.toString(); 194 } 195 196 201 public Enumeration communities(){ 202 return commList.elements(); 203 } 204 205 214 public boolean addCommunity(String comm){ 215 if (commList.contains(comm)) return false; 216 commList.addElement(comm); 217 return true; 218 } 219 220 227 public boolean removeCommunity(String comm){ 228 if (!commList.contains(comm)) return false; 229 commList.removeElement(comm); 230 return true; 231 } 232 233 241 public boolean checkCommunity(String comm){ 242 return (commList.contains(comm)); 243 } 244 245 private Principal princ = null; 246 private boolean neg = false; 247 private Vector permList = null; 248 private Vector commList = null; 249 } 250 251 252 253 254 255 256 257 258 259 | Popular Tags |