Package org.wildfly.security.permission
Class AbstractActionSetPermission<This extends AbstractActionSetPermission<This>>
- java.lang.Object
-
- java.security.Permission
-
- org.wildfly.security.permission.AbstractPermission<This>
-
- org.wildfly.security.permission.AbstractNamedPermission<This>
-
- org.wildfly.security.permission.AbstractActionPermission<This>
-
- org.wildfly.security.permission.AbstractActionSetPermission<This>
-
- All Implemented Interfaces:
Serializable
,Guard
,PermissionVerifier
public abstract class AbstractActionSetPermission<This extends AbstractActionSetPermission<This>> extends AbstractActionPermission<This>
An abstract base class for permissions which use a bit set to represent actions.- Author:
- David M. Lloyd
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private int
actionBits
private StringEnumeration
actionEnumeration
private String
actions
private static long
serialVersionUID
-
Fields inherited from interface org.wildfly.security.permission.PermissionVerifier
ALL, NONE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractActionSetPermission(String name, int actionBits, StringEnumeration actionEnumeration)
Construct a new instance.protected
AbstractActionSetPermission(String name, String actions, StringEnumeration actionEnumeration)
Construct a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
actionsEquals(This permission)
Determine whether the actions of this permission are equal to the actions of givenpermission
.protected int
actionsHashCode()
Get the actions hash code.private int
actionsMask()
protected abstract This
constructWithActionBits(int actionBits)
Construct or return a permission of this type with the same name as this one but with the given action bits.private int
getActionBit(String actionName)
int
getActionBits()
Get the action bits of this permission.private String
getActionName(int bit)
String
getActions()
Get the actions string.boolean
impliesActionBits(int actionBits)
Determine whether this permission's actions value implies the given action bits.boolean
impliesActions(String actions)
Determine whether this permission's actions value implies the given actions value.boolean
impliesActions(This permission)
Determine whether this permission's actions value implies the actions of the givenpermission
.private static boolean
isSet(int bits, int test)
int
parseActions(String actionsString)
Parse the actions string into a bit set.This
withActionBits(int actionBits)
Get a permission which is identical to this one, but with new actions which consist of the union of the actions from this permission and the action bits from the given value.This
withActions(String actionsString)
Get a permission which is identical to this one, but with new actions which consist of the union of the actions from this permission and the actions from the given string.This
withActionsFrom(This permission)
Get a permission which is identical to this one, but with new actions which consist of the union of the actions from this permission and the actions from the given permission.This
withNewActionBits(int actionBits)
Get a permission which is identical to this one, but with new action bits as given byactionBits
.This
withNewActions(String actionsString)
Get a permission which is identical to this one, but with new actions as given byactionsString
.This
withNewActionsFrom(This permission)
Get a permission which is identical to this one, but with new actions as given byactionsString
.This
withoutActionBits(int actionBits)
Get a permission which is identical to this one, but with new actions which consist of the actions from this permission without the action bits from the given value.This
withoutActions(String actionsString)
Get a permission which is identical to this one, but with new actions which consist of the actions from this permission without the actions from the given string.This
withoutActionsFrom(This permission)
Get a permission which is identical to this one, but with new actions which consist of the actions from this permission without the actions from the given permission.-
Methods inherited from class org.wildfly.security.permission.AbstractActionPermission
actionsEquals, actionsEquals, equals, hashCode, implies, impliesActions
-
Methods inherited from class org.wildfly.security.permission.AbstractNamedPermission
impliesName, impliesName, impliesName, nameEquals, nameEquals, nameEquals, nameHashCode, withName
-
Methods inherited from class org.wildfly.security.permission.AbstractPermission
equals, 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
-
actionEnumeration
private final StringEnumeration actionEnumeration
-
actionBits
private final int actionBits
-
actions
private String actions
-
-
Constructor Detail
-
AbstractActionSetPermission
protected AbstractActionSetPermission(String name, int actionBits, StringEnumeration actionEnumeration)
Construct a new instance. The given bits are masked byactionsMask()
before being stored in the object instance.- Parameters:
name
- the permission nameactionBits
- the permission action bitsactionEnumeration
- the permission actions enumeration
-
AbstractActionSetPermission
protected AbstractActionSetPermission(String name, String actions, StringEnumeration actionEnumeration)
Construct a new instance.- Parameters:
name
- the permission nameactions
- the permission actions stringactionEnumeration
- the permission actions enumeration
-
-
Method Detail
-
getActionBits
public final int getActionBits()
Get the action bits of this permission.- Returns:
- the action bits
-
actionsEquals
public final boolean actionsEquals(This permission)
Description copied from class:AbstractActionPermission
Determine whether the actions of this permission are equal to the actions of givenpermission
.- Specified by:
actionsEquals
in classAbstractActionPermission<This extends AbstractActionSetPermission<This>>
- Parameters:
permission
- the permission whose actions are to be compared- Returns:
true
if the actions are equal,false
otherwise
-
impliesActions
public final boolean impliesActions(This permission)
Description copied from class:AbstractActionPermission
Determine whether this permission's actions value implies the actions of the givenpermission
.- Specified by:
impliesActions
in classAbstractActionPermission<This extends AbstractActionSetPermission<This>>
- Parameters:
permission
- the permission whose actions are to be compared- Returns:
true
if this permission implies the other;false
otherwise
-
impliesActions
public final boolean impliesActions(String actions)
Description copied from class:AbstractActionPermission
Determine whether this permission's actions value implies the given actions value.- Specified by:
impliesActions
in classAbstractActionPermission<This extends AbstractActionSetPermission<This>>
- Parameters:
actions
- the actions to test (must not benull
)- Returns:
true
if this permission implies the other;false
otherwise
-
impliesActionBits
public final boolean impliesActionBits(int actionBits)
Determine whether this permission's actions value implies the given action bits.- Parameters:
actionBits
- the actions bits to test- Returns:
true
if this permission implies the given action bits;false
otherwise
-
actionsMask
private int actionsMask()
-
getActionBit
private int getActionBit(String actionName) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
getActionName
private String getActionName(int bit) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
actionsHashCode
protected final int actionsHashCode()
Description copied from class:AbstractActionPermission
Get the actions hash code.- Specified by:
actionsHashCode
in classAbstractActionPermission<This extends AbstractActionSetPermission<This>>
- Returns:
- the actions hash code
-
getActions
public final String getActions()
Get the actions string. The string is computed the first time this method is called, and cached thereafter.- Overrides:
getActions
in classAbstractPermission<This extends AbstractActionSetPermission<This>>
- Returns:
- the actions string (not
null
)
-
parseActions
public final int parseActions(String actionsString) throws IllegalArgumentException
Parse the actions string into a bit set.- Parameters:
actionsString
- the actions string- Returns:
- the bit set
- Throws:
IllegalArgumentException
- if the actions string contained an invalid name or invalid syntax
-
withActions
public final This withActions(String actionsString)
Description copied from class:AbstractActionPermission
Get a permission which is identical to this one, but with new actions which consist of the union of the actions from this permission and the actions from the given string. The returned permission may or may not be a new instance, and may be equal to this instance.- Specified by:
withActions
in classAbstractActionPermission<This extends AbstractActionSetPermission<This>>
- Parameters:
actionsString
- the actions string (must not benull
)- Returns:
- the permission (not
null
)
-
withActionsFrom
public final This withActionsFrom(This permission)
Description copied from class:AbstractActionPermission
Get a permission which is identical to this one, but with new actions which consist of the union of the actions from this permission and the actions from the given permission. The returned permission may or may not be a new instance, and may be equal to this instance.- Overrides:
withActionsFrom
in classAbstractActionPermission<This extends AbstractActionSetPermission<This>>
- Parameters:
permission
- the other permission (must not benull
)- Returns:
- the permission (not
null
)
-
withActionBits
public final This withActionBits(int actionBits)
Get a permission which is identical to this one, but with new actions which consist of the union of the actions from this permission and the action bits from the given value. The returned permission may or may not be a new instance, and may be equal to this instance.- Parameters:
actionBits
- the action bits- Returns:
- the permission (not
null
)
-
withoutActions
public final This withoutActions(String actionsString)
Description copied from class:AbstractActionPermission
Get a permission which is identical to this one, but with new actions which consist of the actions from this permission without the actions from the given string. The returned permission may or may not be a new instance, and may be equal to this instance.- Specified by:
withoutActions
in classAbstractActionPermission<This extends AbstractActionSetPermission<This>>
- Parameters:
actionsString
- the actions string (must not benull
)- Returns:
- the permission (not
null
)
-
withoutActionsFrom
public final This withoutActionsFrom(This permission)
Description copied from class:AbstractActionPermission
Get a permission which is identical to this one, but with new actions which consist of the actions from this permission without the actions from the given permission. The returned permission may or may not be a new instance, and may be equal to this instance.- Overrides:
withoutActionsFrom
in classAbstractActionPermission<This extends AbstractActionSetPermission<This>>
- Parameters:
permission
- the other permission (must not benull
)- Returns:
- the permission (not
null
)
-
withoutActionBits
public final This withoutActionBits(int actionBits)
Get a permission which is identical to this one, but with new actions which consist of the actions from this permission without the action bits from the given value. The returned permission may or may not be a new instance, and may be equal to this instance.- Parameters:
actionBits
- the action bits- Returns:
- the permission (not
null
)
-
withNewActions
public final This withNewActions(String actionsString)
Description copied from class:AbstractActionPermission
Get a permission which is identical to this one, but with new actions as given byactionsString
. The returned permission may or may not be a new instance, and may be equal to this instance.- Specified by:
withNewActions
in classAbstractActionPermission<This extends AbstractActionSetPermission<This>>
- Parameters:
actionsString
- the actions string (must not benull
)- Returns:
- the permission (not
null
)
-
withNewActionsFrom
public final This withNewActionsFrom(This permission)
Description copied from class:AbstractActionPermission
Get a permission which is identical to this one, but with new actions as given byactionsString
. The returned permission may or may not be a new instance, and may be equal to this instance.- Overrides:
withNewActionsFrom
in classAbstractActionPermission<This extends AbstractActionSetPermission<This>>
- Parameters:
permission
- the other permission (must not benull
)- Returns:
- the permission (not
null
)
-
withNewActionBits
public final This withNewActionBits(int actionBits)
Get a permission which is identical to this one, but with new action bits as given byactionBits
. The returned permission may or may not be a new instance, and may be equal to this instance.- Parameters:
actionBits
- the action bits- Returns:
- the permission (not
null
)
-
constructWithActionBits
protected abstract This constructWithActionBits(int actionBits)
Construct or return a permission of this type with the same name as this one but with the given action bits.- Parameters:
actionBits
- the action bits- Returns:
- the permission
-
isSet
private static boolean isSet(int bits, int test)
-
-