Package org.wildfly.security.permission
Class AbstractNamedPermission<This extends AbstractNamedPermission<This>>
- java.lang.Object
-
- java.security.Permission
-
- org.wildfly.security.permission.AbstractPermission<This>
-
- org.wildfly.security.permission.AbstractNamedPermission<This>
-
- All Implemented Interfaces:
Serializable
,Guard
,PermissionVerifier
- Direct Known Subclasses:
AbstractActionPermission
,AbstractNameOnlyPermission
public abstract class AbstractNamedPermission<This extends AbstractNamedPermission<This>> extends AbstractPermission<This>
An abstract base class for named permissions with useful API and implementation methods.Subclasses of this class are always serialized as a special serialized permission object, which captures the type class, the permission name (if any), and the permission action (if any) as a string. Therefore, none of the fields of any subclass of this class are serialized unless they are included in the name or actions properties.
Concrete subclasses are expected to be immutable and final.
- Author:
- David M. Lloyd
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static long
serialVersionUID
-
Fields inherited from interface org.wildfly.security.permission.PermissionVerifier
ALL, NONE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractNamedPermission(String name)
Construct a new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
equals(This other)
Determine whether this permission object is equal to another object of this permission type.int
hashCode()
Get the hash code of this permission.boolean
implies(This permission)
Determine whether this permission implies another permission.boolean
impliesName(String name)
Determine whether this permission implies the given name.boolean
impliesName(Permission permission)
Determine whether this permission implies the name of the given permission.boolean
impliesName(This permission)
Determine whether this permission implies the name of the given permission.boolean
nameEquals(String name)
Determine whether this permission has a name equal to the given name.boolean
nameEquals(Permission permission)
Determine whether this permission has a name equal to the name of the given permission.boolean
nameEquals(This permission)
Determine whether this permission has a name equal to the name of the given permission.protected int
nameHashCode()
Get the hash code of the name.abstract This
withName(String name)
Create a new permission which is identical to this one, except with a newname
.-
Methods inherited from class org.wildfly.security.permission.AbstractPermission
equals, getActions, implies, newPermissionCollection, requireEmptyActions, writeReplace
-
Methods inherited from class java.security.Permission
checkGuard, getName, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.wildfly.security.permission.PermissionVerifier
and, checkPermission, not, or, toPermissionCollection, unless, xor
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractNamedPermission
protected AbstractNamedPermission(String name)
Construct a new instance.- Parameters:
name
- the permission name (must not benull
)
-
-
Method Detail
-
withName
public abstract This withName(String name)
Create a new permission which is identical to this one, except with a newname
.- Parameters:
name
- the name to use (must not benull
)- Returns:
- the new permission
-
nameEquals
public boolean nameEquals(String name)
Determine whether this permission has a name equal to the given name.- Parameters:
name
- the name to check- Returns:
true
if this permission's name is equal to the given name,false
otherwise
-
nameEquals
public final boolean nameEquals(Permission permission)
Determine whether this permission has a name equal to the name of the given permission. If the given permission is of a different type than this permission,false
is returned.- Parameters:
permission
- the permission whose name is to be checked- Returns:
true
if this permission's name is equal to the given permission's name,false
otherwise
-
nameEquals
public final boolean nameEquals(This permission)
Determine whether this permission has a name equal to the name of the given permission.- Parameters:
permission
- the permission whose name is to be checked- Returns:
true
if this permission's name is equal to the given permission's name,false
otherwise
-
nameHashCode
protected int nameHashCode()
Get the hash code of the name. The default implementation returnsgetName().hashCode()
.- Returns:
- the hash code of the name
-
impliesName
public boolean impliesName(String name)
Determine whether this permission implies the given name.- Parameters:
name
- the name to check- Returns:
true
if this permission's name implies the given name,false
otherwise
-
impliesName
public final boolean impliesName(Permission permission)
Determine whether this permission implies the name of the given permission. If the permission is not of the same type as this permission,false
is returned.- Parameters:
permission
- the permission whose name is to be checked- Returns:
true
if this permission's name implies the given name,false
otherwise
-
impliesName
public boolean impliesName(This permission)
Determine whether this permission implies the name of the given permission.- Parameters:
permission
- the permission whose name is to be checked- Returns:
true
if this permission's name implies the given name,false
otherwise
-
implies
public boolean implies(This permission)
Description copied from class:AbstractPermission
Determine whether this permission implies another permission.- Specified by:
implies
in classAbstractPermission<This extends AbstractNamedPermission<This>>
- Parameters:
permission
- the other permission- Returns:
true
if this permission implies the other;false
otherwise
-
equals
public boolean equals(This other)
Description copied from class:AbstractPermission
Determine whether this permission object is equal to another object of this permission type.- Specified by:
equals
in classAbstractPermission<This extends AbstractNamedPermission<This>>
- Parameters:
other
- the permission to compare to- Returns:
true
if the object is a permission equal to this one;false
otherwise
-
hashCode
public int hashCode()
Description copied from class:AbstractPermission
Get the hash code of this permission. The result must be consistent with the definedAbstractPermission.equals(AbstractPermission)
result.- Specified by:
hashCode
in classAbstractPermission<This extends AbstractNamedPermission<This>>
- Returns:
- the hash code of this permission
-
-