1 11 12 package org.eclipse.osgi.framework.internal.core; 13 14 import java.security.Permission ; 15 import java.security.PermissionCollection ; 16 import java.util.*; 17 18 23 final class UnresolvedPermissionCollection extends PermissionCollection { 24 private static final long serialVersionUID = 3618703006602703161L; 25 26 Hashtable permissions = new Hashtable(8); 27 28 UnresolvedPermissionCollection() { 29 super(); 30 } 31 32 public void add(Permission permission) { 33 if (isReadOnly()) { 34 throw new IllegalStateException (); 35 } 36 37 String name = permission.getName(); 38 39 Vector elements; 40 41 synchronized (permissions) { 42 elements = (Vector) permissions.get(name); 43 44 if (elements == null) { 45 elements = new Vector(10, 10); 46 47 permissions.put(name, elements); 48 } 49 } 50 51 elements.addElement(permission); 52 } 53 54 public Enumeration elements() { 55 return (new Enumeration() { 56 Enumeration vEnum, pEnum = permissions.elements(); 57 Object next = findNext(); 58 59 private Object findNext() { 60 if (vEnum != null) { 61 if (vEnum.hasMoreElements()) 62 return (vEnum.nextElement()); 63 } 64 if (!pEnum.hasMoreElements()) 65 return (null); 66 vEnum = ((Vector) pEnum.nextElement()).elements(); 67 return (vEnum.nextElement()); 68 } 69 70 public boolean hasMoreElements() { 71 return (next != null); 72 } 73 74 public Object nextElement() { 75 Object result = next; 76 next = findNext(); 77 return (result); 78 } 79 }); 80 } 81 82 public boolean implies(Permission permission) { 83 return false; 84 } 85 86 Vector getPermissions(String name) { 87 return (Vector) permissions.get(name); 88 } 89 } 90 | Popular Tags |