com.metamatrix.platform.security.api
Class StandardAuthorizationActions

java.lang.Object
  extended by com.metamatrix.platform.security.api.StandardAuthorizationActions
All Implemented Interfaces:
AuthorizationActions, java.io.Serializable, java.lang.Comparable

public class StandardAuthorizationActions
extends java.lang.Object
implements java.io.Serializable, AuthorizationActions

The static and closed set of basic authorization actions. Actions include "create", "read", "update", and "delete".

The instances are static to both close the set and minimize VM resource requirements.

See Also:
AuthorizationActions, Serialized Form

Field Summary
static AuthorizationActions ALL
           
static int ALL_VALUE
           
static AuthorizationActions DATA_CREATE
           
static java.lang.String DATA_CREATE_LABEL
           
static int DATA_CREATE_VALUE
           
static AuthorizationActions DATA_DELETE
           
static java.lang.String DATA_DELETE_LABEL
           
static int DATA_DELETE_VALUE
           
static AuthorizationActions DATA_READ
           
static java.lang.String DATA_READ_LABEL
           
static int DATA_READ_VALUE
           
static AuthorizationActions DATA_UPDATE
           
static java.lang.String DATA_UPDATE_LABEL
           
static int DATA_UPDATE_VALUE
           
static AuthorizationActions NONE
           
static java.lang.String NONE_LABEL
           
static int NONE_VALUE
           
 
Method Summary
 int compareTo(java.lang.Object obj)
          Compares this AuthorizationActions to another Object.
 boolean containsLabel(java.lang.String label)
          Return whether this instance contains the specified label
 boolean containsLabels(java.util.Collection labels)
          Return whether this instance contains all of the specified labels
 boolean containsLabels(java.lang.String[] labels)
          Return whether this instance contains all of the specified labels
 boolean equals(java.lang.Object obj)
          Returns true if the specified object is semantically equal to this instance.
static java.lang.String[] getActionsLabels(int actionsValue)
          Obtain the formatted String[] version of the given actionsValue.
static java.lang.String getActionsString(int actionsValue)
          Obtain the formatted String version of the given actionsValue.
static AuthorizationActions getAuthorizationActions(java.util.Collection labels)
          Obtain the AuthorizationActions instance that is associated with the specified set of labels.
static AuthorizationActions getAuthorizationActions(int actions)
          Obtain the AuthorizationActions instance that is associated with the specified set of actions.
static AuthorizationActions getAuthorizationActions(java.lang.String labels)
          Obtain the AuthorizationActions instance that is associated with the specified set of labels.
static AuthorizationActions getAuthorizationActions(java.lang.String[] labels)
          Obtain the AuthorizationActions instance that is associated with the specified set of labels.
static AuthorizationActions getCommonActions(AuthorizationActions actions, AuthorizationActions sharedActions)
          Get the AuthorizationActions in actions that are also in sharedActions.
static AuthorizationActions getCommonActions(int actions, int sharedActions)
          Get the AuthorizationActions in actions that are also in sharedActions.
static AuthorizationActions getIndependantActions(AuthorizationActions actions, AuthorizationActions sharedActions)
          Get the AuthorizationActions in actions that are NOT in sharedActions.
static AuthorizationActions getIndependantActions(int actions, int sharedActions)
          Get the AuthorizationActions in actions that are NOT in sharedActions.
 java.lang.String getLabel()
          Return the label of this action.
 int getLabelCount()
          Return the number of actions.
 java.lang.String[] getLabels()
          Return the set of labels of this action.
static AuthorizationActions getORedActions(AuthorizationActions actions, AuthorizationActions otherActions)
          Get the AuthorizationActions that or in actions OR are in otherActions.
 int getValue()
          Return the value of this action.
 int hashCode()
          Returns the hashCode for the object.
 boolean implies(AuthorizationActions that)
          Checks if the specified authorization's actions are "implied by" this object's actions.
 java.lang.String toString()
          Returns the stringified representation for this user ID.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE_VALUE

public static final int NONE_VALUE
See Also:
Constant Field Values

DATA_CREATE_VALUE

public static final int DATA_CREATE_VALUE
See Also:
Constant Field Values

DATA_READ_VALUE

public static final int DATA_READ_VALUE
See Also:
Constant Field Values

DATA_UPDATE_VALUE

public static final int DATA_UPDATE_VALUE
See Also:
Constant Field Values

DATA_DELETE_VALUE

public static final int DATA_DELETE_VALUE
See Also:
Constant Field Values

ALL_VALUE

public static final int ALL_VALUE
See Also:
Constant Field Values

NONE_LABEL

public static final java.lang.String NONE_LABEL
See Also:
Constant Field Values

DATA_CREATE_LABEL

public static final java.lang.String DATA_CREATE_LABEL
See Also:
Constant Field Values

DATA_READ_LABEL

public static final java.lang.String DATA_READ_LABEL
See Also:
Constant Field Values

DATA_UPDATE_LABEL

public static final java.lang.String DATA_UPDATE_LABEL
See Also:
Constant Field Values

DATA_DELETE_LABEL

public static final java.lang.String DATA_DELETE_LABEL
See Also:
Constant Field Values

NONE

public static final AuthorizationActions NONE

DATA_CREATE

public static final AuthorizationActions DATA_CREATE

DATA_UPDATE

public static final AuthorizationActions DATA_UPDATE

DATA_READ

public static final AuthorizationActions DATA_READ

DATA_DELETE

public static final AuthorizationActions DATA_DELETE

ALL

public static final AuthorizationActions ALL
Method Detail

getAuthorizationActions

public static AuthorizationActions getAuthorizationActions(int actions)
Obtain the AuthorizationActions instance that is associated with the specified set of actions.

Parameters:
actions - the set of actions (logical inclusive OR)
Returns:
the instance associated with the set of action, or null if the actions do not correspond to an existing instance
Throws:
java.lang.IllegalArgumentException - if the specified set of actions is invalid.

getAuthorizationActions

public static AuthorizationActions getAuthorizationActions(java.lang.String[] labels)
Obtain the AuthorizationActions instance that is associated with the specified set of labels.

Parameters:
labels - the set of labels
Returns:
the instance associated with the set of labels, or null if the labels do not correspond to an existing instance
Throws:
java.lang.IllegalArgumentException - if the specified set of actions is invalid.

getAuthorizationActions

public static AuthorizationActions getAuthorizationActions(java.lang.String labels)
Obtain the AuthorizationActions instance that is associated with the specified set of labels.

Parameters:
labels - the set of labels, with labels all being separated by commas, and must correspond exactly to the getLabel of one of the actions.
Returns:
the instance associated with the set of labels, or null if the labels do not correspond to an existing instance
Throws:
java.lang.IllegalArgumentException - if the specified set of actions is invalid.

getAuthorizationActions

public static AuthorizationActions getAuthorizationActions(java.util.Collection labels)
Obtain the AuthorizationActions instance that is associated with the specified set of labels.

Parameters:
labels - the set of labels
Returns:
the instance associated with the set of labels, or null if the labels do not correspond to an existing instance
Throws:
java.lang.IllegalArgumentException - if the specified set of actions is invalid.

getORedActions

public static AuthorizationActions getORedActions(AuthorizationActions actions,
                                                  AuthorizationActions otherActions)
Get the AuthorizationActions that or in actions OR are in otherActions. May be StandardAuthorizationActions.NONE if there are no actions in either argument.

Parameters:
actions -
otherActions -
Returns:
The logical OR of the AuthorizationActions in both args or StandardAuthorizationActions.NONE if none exist.

getCommonActions

public static AuthorizationActions getCommonActions(AuthorizationActions actions,
                                                    AuthorizationActions sharedActions)
Get the AuthorizationActions in actions that are also in sharedActions. May be StandardAuthorizationActions.NONE if there are no common actions.

Parameters:
actions -
sharedActions -
Returns:
The AuthorizationActions common to both args or StandardAuthorizationActions.NONE if none exist.

getCommonActions

public static AuthorizationActions getCommonActions(int actions,
                                                    int sharedActions)
Get the AuthorizationActions in actions that are also in sharedActions. May be StandardAuthorizationActions.NONE if there are no common actions.

Parameters:
actions -
sharedActions -
Returns:
The AuthorizationActions common to both args or StandardAuthorizationActions.NONE if none exist.

getIndependantActions

public static AuthorizationActions getIndependantActions(AuthorizationActions actions,
                                                         AuthorizationActions sharedActions)
Get the AuthorizationActions in actions that are NOT in sharedActions. May be actions if there are no common actions.

Parameters:
actions -
sharedActions -
Returns:
The AuthorizationActions in actions that are NOT in sharedActions.

getIndependantActions

public static AuthorizationActions getIndependantActions(int actions,
                                                         int sharedActions)
Get the AuthorizationActions in actions that are NOT in sharedActions. May be actions if there are no common actions.

Parameters:
actions -
sharedActions -
Returns:
The AuthorizationActions in actions that are NOT in sharedActions.

getActionsLabels

public static java.lang.String[] getActionsLabels(int actionsValue)
Obtain the formatted String[] version of the given actionsValue.

Parameters:
actionsValue - The set of actions to determiine labels.
Returns:
The String[] of labels associated with the set of actions.
Throws:
java.lang.IllegalArgumentException - if the specified set of actions is invalid.

getActionsString

public static java.lang.String getActionsString(int actionsValue)
Obtain the formatted String version of the given actionsValue.

Parameters:
actionsValue - The set of actions to determiine labels.
Returns:
The formatted action string associated with the set of actions.
Throws:
java.lang.IllegalArgumentException - if the specified set of actions is invalid.

getValue

public int getValue()
Return the value of this action.

Specified by:
getValue in interface AuthorizationActions
Returns:
the value of this action.

getLabelCount

public int getLabelCount()
Return the number of actions.

Specified by:
getLabelCount in interface AuthorizationActions
Returns:
the number of actions.

getLabel

public java.lang.String getLabel()
Return the label of this action.

Specified by:
getLabel in interface AuthorizationActions
Returns:
the label of this action.

getLabels

public java.lang.String[] getLabels()
Return the set of labels of this action.

Specified by:
getLabels in interface AuthorizationActions
Returns:
the set of labels of this action.

containsLabel

public boolean containsLabel(java.lang.String label)
Return whether this instance contains the specified label

Specified by:
containsLabel in interface AuthorizationActions
Parameters:
label - the single label that is to be checked
Returns:
true if this instance contains the specified label, or false otherwise

containsLabels

public boolean containsLabels(java.lang.String[] labels)
Return whether this instance contains all of the specified labels

Specified by:
containsLabels in interface AuthorizationActions
Parameters:
labels - the array of labels that are to be checked
Returns:
true if this instance contains all of the specified labels, or false otherwise

containsLabels

public boolean containsLabels(java.util.Collection labels)
Return whether this instance contains all of the specified labels

Specified by:
containsLabels in interface AuthorizationActions
Parameters:
labels - the set of labels that are to be checked
Returns:
true if this instance contains all of the specified labels, or false otherwise

toString

public java.lang.String toString()
Returns the stringified representation for this user ID. This is in the form username@domain.

Overrides:
toString in class java.lang.Object
Returns:
the string representation

equals

public boolean equals(java.lang.Object obj)
Returns true if the specified object is semantically equal to this instance. Note: this method is consistent with compareTo().

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object that this instance is to be compared to.
Returns:
whether the object is equal to this object.

hashCode

public int hashCode()
Returns the hashCode for the object.

Overrides:
hashCode in class java.lang.Object
Returns:
the hashCode for the object

compareTo

public int compareTo(java.lang.Object obj)
Compares this AuthorizationActions to another Object. If the Object is a AuthorizationActions, this function compares the attributes. Otherwise, it throws a ClassCastException (as AuthorizationActions instances are comparable only to other AuthorizationActions instances). Note: this method is consistent with equals().

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - the authorization to compare this instance against.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object, respectively.
Throws:
java.lang.ClassCastException - if the specified object's type prevents it from being compared to this AuthorizationActions.

implies

public boolean implies(AuthorizationActions that)
Checks if the specified authorization's actions are "implied by" this object's actions.

More specifically, this method returns true if:

  • action is an instanceof StandardAuthorizationActions, and

  • action is a proper subset of this object's actions

Specified by:
implies in interface AuthorizationActions
Parameters:
that - the authorization action to check against.
Returns:
true if the specified authorization action is implied by this object, false if not


Copyright © 2009. All Rights Reserved.