1 11 12 package org.eclipse.osgi.framework.internal.core; 13 14 import java.security.Permission ; 15 import java.util.*; 16 17 21 final class BundleCombinedPermissions extends BundlePermissionCollection { 22 private static final long serialVersionUID = 4049357526208360496L; 23 private static final Enumeration EMPTY_ENUMERATION = new Enumeration() { 25 public boolean hasMoreElements() { 26 return false; 27 } 28 public Object nextElement() { 29 throw new NoSuchElementException(); 30 } 31 }; 32 private BundlePermissionCollection assigned; 33 private BundlePermissionCollection implied; 34 private ConditionalPermissions conditional; 35 private ConditionalPermissionSet restrictedPermissions; 36 private boolean isDefault; 37 38 43 BundleCombinedPermissions(BundlePermissionCollection implied) { 44 this.implied = implied; 45 46 setReadOnly(); 47 } 48 49 55 void setAssignedPermissions(BundlePermissionCollection assigned, boolean isDefault) { 56 this.assigned = assigned; 57 this.isDefault = isDefault; 58 } 59 60 65 void setConditionalPermissions(ConditionalPermissions conditional) { 66 this.conditional = conditional; 67 } 68 69 void checkConditionalPermissionInfo(ConditionalPermissionInfoImpl cpi) { 70 if (conditional != null) { 71 conditional.checkConditionalPermissionInfo(cpi); 72 } 73 } 74 75 void unresolvePermissions() { 76 if (assigned != null) 77 assigned.unresolvePermissions(); 78 if (implied != null) 79 implied.unresolvePermissions(); 80 if (conditional != null) 81 conditional.unresolvePermissions(); 82 if (restrictedPermissions != null) 83 restrictedPermissions.unresolvePermissions(); 84 } 85 86 94 public void add(Permission permission) { 95 throw new SecurityException (); 96 } 97 98 105 public Enumeration elements() { 106 return EMPTY_ENUMERATION; 110 } 111 112 123 public boolean implies(Permission permission) { 124 if ((implied != null) && implied.implies(permission)) 125 return true; 126 127 129 if ((restrictedPermissions != null) && !restrictedPermissions.implies(permission)) { 130 return false; 131 } 132 133 135 if (!isDefault && assigned != null) 136 return assigned.implies(permission); 137 if (conditional != null) { 138 boolean conditionalImplies = conditional.implies(permission); 139 if (!conditional.isEmpty()) { 140 return conditionalImplies; 141 } 142 } 143 145 return assigned.implies(permission); 146 } 147 148 155 public void setRestrictedPermissions(ConditionalPermissionSet restrictedPermissions) { 156 this.restrictedPermissions = restrictedPermissions; 157 } 158 } 159 | Popular Tags |