PropertyPermissionpublic final class PropertyPermission extends BasicPermission {@code PropertyPermission} objects represent a permission to access system
properties.
A permission is one of the possible permission strings like "user.name" or
"java.version". It's also possible to use a wildcard to define the permission
to several properties at once. For example "user.*" will define the
permission for "user.home", "user.name", "user.dir", ... "*" defines the
permission for all available properties.
There are two possible permission action types: read and write. Possible
actions are "read", "write", or "read,write"/"write,read". |
Fields Summary |
---|
private static final long | serialVersionUID | private transient boolean | read | private transient boolean | write | private static final ObjectStreamField[] | serialPersistentFields |
Constructors Summary |
---|
public PropertyPermission(String name, String actions)Constructs a new instance of this class.
super(name);
decodeActions(actions);
|
Methods Summary |
---|
private void | decodeActions(java.lang.String actions)
StringTokenizer tokenizer = new StringTokenizer(Util.toASCIILowerCase(actions),
" \t\n\r,"); //$NON-NLS-1$
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
if (token.equals("read")) { //$NON-NLS-1$
read = true;
} else if (token.equals("write")) { //$NON-NLS-1$
write = true;
} else {
throw new IllegalArgumentException();
}
}
if (!read && !write) {
throw new IllegalArgumentException();
}
| public boolean | equals(java.lang.Object o)Compares the argument to the receiver, and returns true if they represent
the same object using a class specific comparison. In this
case, the receiver must be a {@code PropertyPermission} for the same
property as the argument, and must have the same actions.
If {@code o} is a permission that is not a {@code PropertyPermission},
this method may throw a {@code ClassCastException}.
if (super.equals(o)) {
PropertyPermission pp = (PropertyPermission) o;
return read == pp.read && write == pp.write;
}
return false;
| public java.lang.String | getActions()Returns the actions associated with the receiver. The result will be
either "read", "write", or "read,write".
return read ? (write ? "read,write" : "read") : "write"; //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
| public int | hashCode()Returns an integer hash code for the receiver. Any two objects which
return {@code true} when passed to {@code equals} must return the same
value for this method.
return super.hashCode();
| public boolean | implies(java.security.Permission permission)Indicates whether the argument permission is implied by the receiver.
if (super.implies(permission)) {
PropertyPermission pp = (PropertyPermission) permission;
return (read || !pp.read) && (write || !pp.write);
}
return false;
| public java.security.PermissionCollection | newPermissionCollection()Returns a new {@code PermissionCollection} for holding permissions of this class.
Returns {@code null} if any {@code PermissionCollection} can be used.
return new PropertyPermissionCollection();
| private void | readObject(java.io.ObjectInputStream stream)
ObjectInputStream.GetField fields = stream.readFields();
String actions = (String) fields.get("actions", ""); //$NON-NLS-1$ //$NON-NLS-2$
decodeActions(actions);
| private void | writeObject(java.io.ObjectOutputStream stream) //$NON-NLS-1$
ObjectOutputStream.PutField fields = stream.putFields();
fields.put("actions", getActions()); //$NON-NLS-1$
stream.writeFields();
|
|