Methods Summary |
---|
private final void | checkName(java.lang.String name)Checks name parameter
if (name == null) {
throw new NullPointerException(Messages.getString("security.28")); //$NON-NLS-1$
}
if (name.length() == 0) {
throw new IllegalArgumentException(Messages.getString("security.29")); //$NON-NLS-1$
}
|
public boolean | equals(java.lang.Object obj)Compares the specified object with this {@code BasicPermission} for
equality. Returns {@code true} if the specified object has the same class
and the two {@code Permissions}s have the same name.
The {@link #implies(Permission)} method should be used for making access
control checks.
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
return this.getName().equals(((Permission)obj).getName());
}
return false;
|
public java.lang.String | getActions()Returns the actions associated with this permission. Since {@code
BasicPermission} instances have no actions, an empty string is returned.
return ""; //$NON-NLS-1$
|
public int | hashCode()Returns the hash code value for this {@code BasicPermission}. Returns the
same hash code for {@code BasicPermission}s that are equal to each other
as required by the general contract of {@link Object#hashCode}.
return getName().hashCode();
|
public boolean | implies(java.security.Permission permission)Indicates whether the specified permission is implied by this permission.
if (permission != null && permission.getClass() == this.getClass()) {
return nameImplies(getName(), permission.getName());
}
return false;
|
static boolean | nameImplies(java.lang.String thisName, java.lang.String thatName)Checks if {@code thisName} implies {@code thatName},
accordingly to hierarchical property naming convention.
It is assumed that names cannot be {@code null} or empty.
if (thisName == thatName) {
return true;
}
int end = thisName.length();
if (end > thatName.length()) {
return false;
}
if (thisName.charAt(--end) == '*"
&& (end == 0 || thisName.charAt(end - 1) == '.")) {
//wildcard found
end--;
} else if (end != (thatName.length()-1)) {
//names are not equal
return false;
}
for (int i = end; i >= 0; i--) {
if (thisName.charAt(i) != thatName.charAt(i)) {
return false;
}
}
return true;
|
public java.security.PermissionCollection | newPermissionCollection()Returns an empty {@link PermissionCollection} for holding permissions.
For {@code PermissionCollection} (and subclasses which do not override
this method), the collection which is returned does not invoke
the {@link #implies(Permission)} method of the permissions which are
stored in it when checking if the collection implies a permission.
Instead, it assumes that if the type of the permission is correct, and
the name of the permission is correct, there is a match.
return new BasicPermissionCollection();
|
private void | readObject(java.io.ObjectInputStream in)Checks name after default deserialization.
in.defaultReadObject();
checkName(this.getName());
|