Methods Summary |
---|
public void | add(java.security.Permission permission)Adds the given {@code Permission} to this heterogeneous {@code
PermissionCollection}. The {@code permission} is stored in its
appropriate {@code PermissionCollection}. // = false;
if (isReadOnly()) {
throw new SecurityException(Messages.getString("security.15")); //$NON-NLS-1$
}
if (permission == null) {
throw new NullPointerException(Messages.getString("security.20")); //$NON-NLS-1$
}
Class klass = permission.getClass();
PermissionCollection klassMates = (PermissionCollection)klasses
.get(klass);
if (klassMates == null) {
synchronized (klasses) {
klassMates = (PermissionCollection)klasses.get(klass);
if (klassMates == null) {
klassMates = permission.newPermissionCollection();
if (klassMates == null) {
klassMates = new PermissionsHash();
}
klasses.put(klass, klassMates);
}
}
}
klassMates.add(permission);
if (klass == AllPermission.class) {
allEnabled = true;
}
|
public java.util.Enumeration | elements()
return new MetaEnumeration(klasses.values().iterator());
|
public boolean | implies(java.security.Permission permission)
if (permission == null) {
// RI compatible
throw new NullPointerException(Messages.getString("security.21")); //$NON-NLS-1$
}
if (allEnabled) {
return true;
}
Class klass = permission.getClass();
PermissionCollection klassMates = null;
UnresolvedPermissionCollection billets = (UnresolvedPermissionCollection)klasses
.get(UnresolvedPermission.class);
if (billets != null && billets.hasUnresolved(permission)) {
// try to fill up klassMates with freshly resolved permissions
synchronized (klasses) {
klassMates = (PermissionCollection)klasses.get(klass);
try {
klassMates = billets.resolveCollection(permission,
klassMates);
} catch (Exception ignore) {
//TODO log warning
ignore.printStackTrace();
}
if (klassMates != null) {
//maybe klassMates were just created
// so put them into common map
klasses.put(klass, klassMates);
// very uncommon case, but not improbable one
if (klass == AllPermission.class) {
allEnabled = true;
}
}
}
} else {
klassMates = (PermissionCollection)klasses.get(klass);
}
if (klassMates != null) {
return klassMates.implies(permission);
}
return false;
|
private void | readObject(java.io.ObjectInputStream in)Reads the object from stream and checks for consistency.
ObjectInputStream.GetField fields = in.readFields();
Map perms = (Map)fields.get("perms", null); //$NON-NLS-1$
klasses = new HashMap();
synchronized (klasses) {
for (Iterator iter = perms.keySet().iterator(); iter.hasNext();) {
Class key = (Class)iter.next();
PermissionCollection pc = (PermissionCollection)perms.get(key);
if (key != pc.elements().nextElement().getClass()) {
throw new InvalidObjectException(Messages.getString("security.22")); //$NON-NLS-1$
}
klasses.put(key, pc);
}
}
allEnabled = fields.get("allPermission", null) != null; //$NON-NLS-1$
if (allEnabled && !klasses.containsKey(AllPermission.class)) {
throw new InvalidObjectException(Messages.getString("security.23")); //$NON-NLS-1$
}
|
private void | writeObject(java.io.ObjectOutputStream out)Outputs fields via default mechanism.
ObjectOutputStream.PutField fields = out.putFields();
fields.put("perms", new Hashtable(klasses)); //$NON-NLS-1$
fields.put("allPermission", allEnabled ? klasses //$NON-NLS-1$
.get(AllPermission.class) : null);
out.writeFields();
|