edu.stanford.rt.credential
Class RoleDeclaration

java.lang.Object
  |
  +--edu.stanford.rt.credential.RoleDeclaration
All Implemented Interfaces:
Constants, java.io.Serializable

public class RoleDeclaration
extends java.lang.Object
implements Constants, java.io.Serializable

Author:
Ninghui Li, Sandra Qiu
All the information about a declared role. In RTML, this is represented by a RoleDeclaration element in a ApplicationDomainSpecification document. Issue: Do not support identity yet.
See Also:
Serialized Form

Field Summary
private  RoleDeclaration baseRole
          BaseRole Element for Restriction, Extension, Projection.
private  DomainSpecification context
          Role declaration context.
private  int declarationType
          Declaration type: Restriction, Extension, Projection or Plain.
static int DEFAULT_ISSUER_TYPE
          Default issuer traces type: rule
static int DEFAULT_SUBJECT_TYPE
          Defualt issuer traces type: fact.
private  int dimension
          Default is 1
In RTML: attribute dimension.
private static int EXTENSION
           
private  boolean isIdentity
          Default is false.
private  int issuerTracesType
          Default is DEFAULT_ISSUER_TYPE
In RTML: attribute issuerTracesType.
static java.util.HashMap issuerTracesTypes
          Issuer traces types
private  java.lang.String name
          Role name.
private  OrderedMap parameterDeclarations
          Maps String (parameter name) to DataType (parameter type).
private static int PLAIN
           
private  java.util.HashMap positionToPrefixes
           
private  java.util.HashMap prefixToPositions
          This map keeps track of the ordersing of the flattend name-prefixes.
private static int PROJECTION
           
private static int RESTRICTION
           
private  int subjectTracesType
          Default is DEFAULT_SUBJECT_TYPE
In RTML: attribute subjectTracesType.
static java.util.HashMap subjectTracesTypes
          Subject traces types
 
Fields inherited from interface edu.stanford.rt.util.Constants
COLON, illegal_value_for, improper_sub_element_for, INDENT, ISSUER_TRACES_ALL, ISSUER_TRACES_DEF, ISSUER_TRACES_NONE, ISSUER_TRACES_RULE, missing_attr_value, no_support_for, SUBJECT_TRACES_ALL, SUBJECT_TRACES_FACT, SUBJECT_TRACES_NONE
 
Constructor Summary
private RoleDeclaration(DomainSpecification context, java.lang.String name, int issuerTracesType, int subjectTracesType, int dimension, boolean isIdentity, int declarationType, RoleDeclaration baseRole, OrderedMap parameterDeclarations)
          Private contructor ensures that no one else can contruct a RoleDeclaration object and the state of a RoleDeclaration object is complete (unmodifiable) once it is created.
 
Method Summary
private  void calculatePrefixPositions(java.lang.StringBuffer prefix, int position, OrderedMap paramDeclarations, java.util.HashMap prefixToPositionMap, java.util.HashMap positionToPrefixMap)
          Method calculatePrefixPositions.
static RoleDeclaration createExtensionRole(DomainSpecification context, java.lang.String name, boolean isIdentity, RoleDeclaration baseRole, OrderedMap newParameters)
          Method createExtensionRole.
static RoleDeclaration createPlainRole(DomainSpecification context, java.lang.String name, int issuerTracesType, int subjectTracesType, int dimension, boolean isIdentity, OrderedMap newParameters)
          Method createPlainRole.
static RoleDeclaration createProjectionRole(DomainSpecification context, java.lang.String name, boolean isIdentity, RoleDeclaration baseRole, java.lang.String[] parameterNames)
          Method createProjectionRole.
static RoleDeclaration createRestrictionRole(DomainSpecification context, java.lang.String name, boolean isIdentity, RoleDeclaration baseRole, OrderedMap newParameters)
          Method createRestrictionRole.
 RoleDeclaration getBaseRole()
          Returns the base role object.
 DomainSpecification getContext()
          Returns the role declaration context.
 int getDimension()
          Returns the value for dimension.
 int getIssuerTracesType()
          Returns the value for issuerTracesType.
private  java.lang.String getIssuerTracesTypeString(int issuerTracesType)
           
 java.lang.String getName()
          Returns the role name.
 OrderedMap getParameterDeclarations()
          Method getParameterDeclarations.
 DataType getParameterType(java.lang.String paramName)
          Method getParameterType.
 int getPosition(java.lang.String prefix)
          Method getPosition.
 java.util.Map getPositionToPrefixes()
          Returns a unmodifiable view of position-to-prefix map.
 java.lang.String getPrefix(int position)
          Method getPrefix.
 java.util.Map getPrefixToPositions()
          Returns a unmodifiable view of prefix-to-position map.
 int getSubjectTracesType()
          Returns the value for subjectTracesType.
private  java.lang.String getSubjectTracesTypeString(int subjectTracesType)
           
 int getTotalPrefixes()
          Returns the total number of the prefixes in the map.
 boolean isIdentity()
          Checks whether this role is an identity-based role.
 java.lang.String toString(java.lang.String indent)
          Method toString.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

issuerTracesTypes

public static java.util.HashMap issuerTracesTypes
Issuer traces types


subjectTracesTypes

public static java.util.HashMap subjectTracesTypes
Subject traces types


DEFAULT_ISSUER_TYPE

public static int DEFAULT_ISSUER_TYPE
Default issuer traces type: rule


DEFAULT_SUBJECT_TYPE

public static int DEFAULT_SUBJECT_TYPE
Defualt issuer traces type: fact.


context

private DomainSpecification context
Role declaration context.
The DomainSpecification in which the current role is declared.


name

private java.lang.String name
Role name.
In RTML: attribute name.


issuerTracesType

private int issuerTracesType
Default is DEFAULT_ISSUER_TYPE
In RTML: attribute issuerTracesType.


subjectTracesType

private int subjectTracesType
Default is DEFAULT_SUBJECT_TYPE
In RTML: attribute subjectTracesType.


dimension

private int dimension
Default is 1
In RTML: attribute dimension.


isIdentity

private boolean isIdentity
Default is false.
In RTML: attribute isIdentity.


parameterDeclarations

private OrderedMap parameterDeclarations
Maps String (parameter name) to DataType (parameter type).


declarationType

private int declarationType
Declaration type: Restriction, Extension, Projection or Plain.


baseRole

private RoleDeclaration baseRole
BaseRole Element for Restriction, Extension, Projection.


prefixToPositions

private java.util.HashMap prefixToPositions
This map keeps track of the ordersing of the flattend name-prefixes. A name-prefix is colon-separated name concatenation.


positionToPrefixes

private java.util.HashMap positionToPrefixes

RESTRICTION

private static final int RESTRICTION
See Also:
Constant Field Values

EXTENSION

private static final int EXTENSION
See Also:
Constant Field Values

PROJECTION

private static final int PROJECTION
See Also:
Constant Field Values

PLAIN

private static final int PLAIN
See Also:
Constant Field Values
Constructor Detail

RoleDeclaration

private RoleDeclaration(DomainSpecification context,
                        java.lang.String name,
                        int issuerTracesType,
                        int subjectTracesType,
                        int dimension,
                        boolean isIdentity,
                        int declarationType,
                        RoleDeclaration baseRole,
                        OrderedMap parameterDeclarations)
                 throws DomainSpecException
Private contructor ensures that no one else can contruct a RoleDeclaration object and the state of a RoleDeclaration object is complete (unmodifiable) once it is created.
And the newly created RoleDeclaration's parameter-postion mapping is also calculated.

Parameters:
context -
name -
issuerTracesType -
subjectTracesType -
dimension -
isIdentity -
declarationType -
baseRole -
parameterDeclarations -
Throws:
DomainSpecException
Method Detail

createRestrictionRole

public static RoleDeclaration createRestrictionRole(DomainSpecification context,
                                                    java.lang.String name,
                                                    boolean isIdentity,
                                                    RoleDeclaration baseRole,
                                                    OrderedMap newParameters)
                                             throws DomainSpecException
Method createRestrictionRole. Public interface to construct a Restriction type RoleDeclaration object.

Parameters:
name -
isIdentity -
baseRole -
newParameters -
Returns:
RoleDeclaration
Throws:
DomainSpecException

createExtensionRole

public static RoleDeclaration createExtensionRole(DomainSpecification context,
                                                  java.lang.String name,
                                                  boolean isIdentity,
                                                  RoleDeclaration baseRole,
                                                  OrderedMap newParameters)
                                           throws DomainSpecException
Method createExtensionRole. Public interface to construct an Extension type RoleDeclaration object.

Parameters:
name -
isIdentity -
baseRole -
newParameters -
Returns:
RoleDeclaration
Throws:
DomainSpecException

createProjectionRole

public static RoleDeclaration createProjectionRole(DomainSpecification context,
                                                   java.lang.String name,
                                                   boolean isIdentity,
                                                   RoleDeclaration baseRole,
                                                   java.lang.String[] parameterNames)
                                            throws DomainSpecException
Method createProjectionRole. Public interface to construct a Projection type RoleDeclaration object.

Parameters:
name -
isIdentity -
baseRole -
parameterNames -
Returns:
RoleDeclaration
Throws:
DomainSpecException

createPlainRole

public static RoleDeclaration createPlainRole(DomainSpecification context,
                                              java.lang.String name,
                                              int issuerTracesType,
                                              int subjectTracesType,
                                              int dimension,
                                              boolean isIdentity,
                                              OrderedMap newParameters)
                                       throws DomainSpecException
Method createPlainRole. Public interface to construct a Plain type of RoleDeclaration object. Identity is not supported.

Parameters:
name -
issuerTracesType -
subjectTracesType -
dimension -
isIdentity -
newParameters -
Returns:
RoleDeclaration
Throws:
DomainSpecException

getContext

public DomainSpecification getContext()
Returns the role declaration context.


getName

public java.lang.String getName()
Returns the role name.


getIssuerTracesType

public int getIssuerTracesType()
Returns the value for issuerTracesType.


getSubjectTracesType

public int getSubjectTracesType()
Returns the value for subjectTracesType.


getDimension

public int getDimension()
Returns the value for dimension.


getBaseRole

public RoleDeclaration getBaseRole()
Returns the base role object.


isIdentity

public boolean isIdentity()
Checks whether this role is an identity-based role.


getParameterDeclarations

public OrderedMap getParameterDeclarations()
                                    throws DomainSpecException
Method getParameterDeclarations.

Returns:
OrderedMap Returns an OrderedMap of parameter declarations in this role declaration object.
For Restriction or Extension type RoleDeclaration, the map contains parameters declared both in base role and this role. For Projection type RoleDeclaration, the map contains only those paraeters declared in base role with matching names with this role's declared parameters.
Throws:
DomainSpecException

getParameterType

public DataType getParameterType(java.lang.String paramName)
                          throws DomainSpecException
Method getParameterType.

Parameters:
paramName - name of the declared parameter.
Returns:
DataType type of the declared parameter.
Throws:
DomainSpecException

getPrefixToPositions

public java.util.Map getPrefixToPositions()
Returns a unmodifiable view of prefix-to-position map.


getPositionToPrefixes

public java.util.Map getPositionToPrefixes()
Returns a unmodifiable view of position-to-prefix map.


getTotalPrefixes

public int getTotalPrefixes()
Returns the total number of the prefixes in the map.


getPosition

public int getPosition(java.lang.String prefix)
Method getPosition.

Parameters:
prefix - the prefix to get the position with.
Returns:
int the postition of the given prefix.

getPrefix

public java.lang.String getPrefix(int position)
Method getPrefix.

Parameters:
position - the position to get prefix with.
Returns:
String the prefix at the given position.

toString

public java.lang.String toString(java.lang.String indent)
Method toString.

Parameters:
indent -
Returns:
String

calculatePrefixPositions

private void calculatePrefixPositions(java.lang.StringBuffer prefix,
                                      int position,
                                      OrderedMap paramDeclarations,
                                      java.util.HashMap prefixToPositionMap,
                                      java.util.HashMap positionToPrefixMap)
                               throws DomainSpecException
Method calculatePrefixPositions.

Parameters:
prefix - current prefix. Prefix is a lolon-saparated string, which is the concatenation of role name and parameter names.
position - the current position of the prefix.
paramDeclarations - all parameters declared in this role.
prefixToPositionMap - a HashMap which maps a prefix to its position.
positionToPrefixMap - a HashMap which maps a position to its prefix
Throws:
DomainSpecException

getIssuerTracesTypeString

private java.lang.String getIssuerTracesTypeString(int issuerTracesType)

getSubjectTracesTypeString

private java.lang.String getSubjectTracesTypeString(int subjectTracesType)