stella.util
Class DataPermission

java.lang.Object
  extended by java.security.Permission
      extended by stella.util.DataPermission
All Implemented Interfaces:
Serializable, Guard

public final class DataPermission
extends Permission

This class manages the access to STELLA-data. All permissions are for reading only, but for different level of dataproducts, like raw, reduced, meta data or a somehow 'resolution reduced' data for quicklook.

A data permission has a form that consists of three parts, with possible '*' as a wildcard. The first keyword is the Affiliation name, one of #AFFIL, followed by the user name (separated by a colon), then the proposal id. The normal wildcard rule apply. The action is one of #ACCESS.

See Also:
Serialized Form

Nested Class Summary
static class DataPermission.Access
          The different access possibilities to the data.
private static class DataPermission.DataPermissionCollection
          We want to provide our own permission collection.
static class DataPermission.Test
          Test the class.
 
Field Summary
private  EnumSet<DataPermission.Access> action
          To speed-up operation, we parse the access into a bitmask.
static String COLON
          The separator string between Affiliation, user name and propid.
private  String propid
          If a user name plus proposal was specified.
private  String user
          If a user name plus proposal was specified.
private  EnumSet<UserProfile.Affil> whom
          The affiliations accessible.
static String WILDCARD
          The wildcard string.
 
Constructor Summary
DataPermission(String name)
          Constructs a new data permission object with no access rights.
DataPermission(String name, String acton)
          Constructs a new data permission object.
 
Method Summary
static String accessString(EnumSet<DataPermission.Access> actions)
          Parses an enumeration set of actions into an access string.
static String actionsFromBitmask(short mask)
          Returns the action string from an integer bit-mask.
private  EnumSet<DataPermission.Access> checkActionConsistancy(String act)
          Checks the consitancy of the permission action.
private  EnumSet<UserProfile.Affil> checkNameConsistancy(String name)
          Checks the consistancy of the permission name.
 boolean equals(Object that)
          Additionally check the mask.
static EnumSet<DataPermission.Access> fromBitmask(short mask)
          Parses an integer bit mask into an EnumSet of actions.
 String getActions()
          Returns the actions.
 int hashCode()
          Returns the name has code.
 boolean implies(Permission to)
          Additionally to normal name matching, also the action mask must apply.
 PermissionCollection newPermissionCollection()
          Returns a new data permission collection.
static short toBitmask(EnumSet<DataPermission.Access> perms)
          Returns a bit-mask from a set of accesses.
 
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
 

Field Detail

COLON

public static final String COLON
The separator string between Affiliation, user name and propid.

See Also:
Constant Field Values

WILDCARD

public static final String WILDCARD
The wildcard string.

See Also:
Constant Field Values

action

private EnumSet<DataPermission.Access> action
To speed-up operation, we parse the access into a bitmask.


whom

private EnumSet<UserProfile.Affil> whom
The affiliations accessible.


user

private String user
If a user name plus proposal was specified.


propid

private String propid
If a user name plus proposal was specified.

Constructor Detail

DataPermission

public DataPermission(String name)
Constructs a new data permission object with no access rights.


DataPermission

public DataPermission(String name,
                      String acton)
Constructs a new data permission object. The first part, if not a wildcard, must be an #Affil. If an affil is given, a colon has to appear next. After the colon, a wildcard or a username follows, then a proposal id.
The action must be one of #Access.

Method Detail

checkActionConsistancy

private EnumSet<DataPermission.Access> checkActionConsistancy(String act)
Checks the consitancy of the permission action. The action must be coma-separated list of DataPermission.Accesses. If the Access.NONE is present, it must be the only item. If the action consists of multiple Accesses of the same type, an illegal argument is thrown.


checkNameConsistancy

private EnumSet<UserProfile.Affil> checkNameConsistancy(String name)
Checks the consistancy of the permission name. A valid name must consist of three parts, the affiliation, the user name and the proposal id, separated by COLON. Each of these parts may be wildcarded with WILDCARD.


implies

public boolean implies(Permission to)
Additionally to normal name matching, also the action mask must apply.

Specified by:
implies in class Permission

equals

public boolean equals(Object that)
Additionally check the mask.

Specified by:
equals in class Permission

hashCode

public int hashCode()
Returns the name has code.

Specified by:
hashCode in class Permission

getActions

public String getActions()
Returns the actions.

Specified by:
getActions in class Permission

actionsFromBitmask

public static String actionsFromBitmask(short mask)
Returns the action string from an integer bit-mask.


fromBitmask

public static final EnumSet<DataPermission.Access> fromBitmask(short mask)
Parses an integer bit mask into an EnumSet of actions. If mask is zero, an empty set is returned.


toBitmask

public static final short toBitmask(EnumSet<DataPermission.Access> perms)
Returns a bit-mask from a set of accesses.


accessString

public static final String accessString(EnumSet<DataPermission.Access> actions)
Parses an enumeration set of actions into an access string.


newPermissionCollection

public PermissionCollection newPermissionCollection()
Returns a new data permission collection.

Overrides:
newPermissionCollection in class Permission