com.ibm.dse.applsrv.aa
Class SecurityRole

java.lang.Object
  |
  +--com.ibm.dse.applsrv.aa.SecurityObject
        |
        +--com.ibm.dse.applsrv.aa.SecurityRole

public class SecurityRole
extends SecurityObject
implements SecurityConstants, java.io.Serializable

This class represents a security role.

See Also:
Serialized Form

Fields inherited from class com.ibm.dse.applsrv.aa.SecurityObject
fs
 
Fields inherited from interface com.ibm.dse.applsrv.aa.SecurityConstants
ACTIVE_CONTEXTS, ALL_CONTEXTS, AUDIT_FILE, CBTF_TRACING, CONFIGURATION, CONFIGURATIONS_DATABASE, CONTEXT_ACTIVE, CONTEXT_DATABASE, CONTEXT_INACTIVE, CONTEXT_INVALID, CONTEXTS, CONTROLLER, DEFAULT_CONFIGURATIONS_DATABASE, DEFAULT_CONTEXT_DATABASE, DEFAULT_GROUPS_DATABASE, DEFAULT_RIGHTS_DATABASE, DEFAULT_ROLES_DATABASE, DEFAULT_SERVICES_DATABASE, DEFAULT_USER_DATABASE, ENCRYPTION, GLOBAL_CONTEXTS, GROUPS, GROUPS_DATABASE, INACTIVE_CONTEXTS, JDBC_DATABASE, JDBC_DRIVER, JDBC_MAX_DATA, JDBC_MAX_GROUPS, JDBC_MAX_HANDLER, JDBC_MAX_ID, JDBC_MAX_PASSWORD, JDBC_MAX_RIGHT_TIMES, JDBC_MAX_RIGHTS, JDBC_MAX_ROLE_TIMES, JDBC_MAX_ROLES, JDBC_MAX_USER_ID, JDBC_MAX_USERS, JDBC_PASSWORD, JDBC_URL, JDBC_USER_ID, LIMIT_DATABASE, LIMITS, LOGGING_HANDLER, LOGGING_OPTIONS, PERSIST_CONTEXTS, PERSISTENCE, QUERY_PASSWORDS, RIGHTS, RIGHTS_DATABASE, ROLES, ROLES_DATABASE, SECURITY_DIRECTORY, SECURITY_MANAGER, SERVICES, SERVICES_DATABASE, SPECIFIC_CONTEXTS, TEST_ADD_RIGHT_TO_USER, TEST_ADD_RIGHTS_TO_USER, TEST_AUDIT, TEST_CONTEXT_IDS, TEST_DISABLE_PERSISTENCE, TEST_EXPORT, TEST_GET_CONFIGURATION, TEST_GET_CONTEXTS, TEST_GET_GROUPS, TEST_GET_PASSWORD_ACCESS, TEST_GET_PERSISTENCE, TEST_GET_RIGHTS, TEST_GET_ROLES, TEST_GET_SERVICES, TEST_GET_UNIQUE_LOGON, TEST_GET_USERS, TEST_GROUP_IDS, TEST_IMPORT, TEST_IMPORT2, TEST_LOAD_CONFIGURATIONS, TEST_LOAD_CONTEXTS, TEST_LOAD_GROUPS, TEST_LOAD_RIGHTS, TEST_LOAD_ROLES, TEST_LOAD_SERVICES, TEST_LOAD_USERS, TEST_PERSISTENCE, TEST_QUERY_SM, TEST_REMOVE_ALL_RIGHTS_FROM_USER, TEST_RESET, TEST_RIGHT_IDS, TEST_ROLE_IDS, TEST_SAVE, TEST_SERVICE_IDS, TEST_SET_CONFIGURATION, TEST_SET_PASSWORD_ACCESS, TEST_SET_PERSISTENCE, TEST_SET_UNIQUE_LOGON, TEST_TEST1, TEST_TEST2, TEST_TEST3, TEST_TRACE, TEST_USER_IDS, TRACE_EXCEPTIONS, TRACE_FILE, TRACE_LOGGER, UNIQUE_LOGONS, USE_LIMITS, USER_DATABASE, USERS
 
Constructor Summary
protected SecurityRole(java.lang.String nameOfRole)
          Create a new instance of a Role with the specified name.
protected SecurityRole(java.lang.String nameOfRole, RoleHandlerInterface handler)
          Create a new instance of a Role with the specified name.
protected SecurityRole(java.lang.String nameOfRole, java.lang.String handler)
          Create a new instance of a Role with the specified name.
 
Method Summary
protected  void _save()
          A hack to force inheritence of a static method.
 void addRight(java.lang.String right)
          Add the named right to this role.
 void addRights(java.lang.String[] namesOfRights)
          Add rights to this role.
 void addSubRole(java.lang.String subroleName)
          Add a subrole to the current role.
 void addSubRoleNCNS(java.lang.String subroleName)
          Add a subrole to the current role.
static void controller(SecurityController ctrl)
          Set the security controller.
 boolean delete()
          Delete this role.
protected static boolean delete(java.lang.String nameOfRole)
          Delete the named role.
 void deleteRight(java.lang.String right)
          Delete the named right from this role.
 void deleteRights(java.lang.String[] namesOfRights)
          Delete the rights from this role.
protected static boolean deleteRoles(java.lang.String[] rolesToDelete, java.lang.String[] options)
          Delete the named roles subject to the specified options.
 void deleteSubRole(java.lang.String childRoleName)
          Delete a child role from the current role.
protected static boolean disablePersist()
          Disable persistence for roles.
protected static java.util.Enumeration enumerationOverRoles()
          Return an enumeration over the roles.
protected static void forceSave()
          Force a save of the current state of the roles to the database.
protected static SecurityRole get(java.lang.String nameOfRole, boolean create)
          Return the role with the specified name.
 Array getAllRights()
          Return the list of all rights contained within this role or any subrole thereof.
 Dictionary getAttributes()
          Return a dictionary containing all of the attributes of this role.
protected static SecurityPersistence getDB()
          Return the persistence controller for this class.
protected static java.lang.String getPathName()
          Return the pathname of this database of roles.
protected static boolean getPersist()
          Return the persistence state for roles.
 Array getRights()
          Return a copy of the list of rights associated with this role.
 java.lang.String[] getRightsAsArray()
          Return a copy of the list of rights associated with this role.
 java.lang.String[] getRightsAsArrayOrNull()
          Return a copy of the list of rights associated with this role.
 RoleHandlerInterface getRoleHandler()
          Return the handler for this role or null if none is defined.
 java.lang.String getRoleHandlerAsString()
          Return the name of the handler class associated with the named role.
protected static java.lang.String[] getRoleIds()
          Return the list of names of the roles.
 Array getSubRoles()
          Return a copy of the list of child roles associated with this role.
 java.lang.String[] getSubRolesAsArray()
          Return a copy of the list of child roles associated with this role.
 java.lang.String[] getSubRolesAsArrayOrNull()
          Return a copy of the list of child roles associated with this role.
 boolean hasDescendant(java.lang.String nameOfRole)
          Return true if the named role is this role or one of its descendants.
 boolean hasDirectRight(java.lang.String right)
          Return true if this role has the specified right.
 boolean hasRight(java.lang.String right)
          Return true if this role directly or indirectly (via subroles) has the specified right.
 boolean isReferencingRight(java.lang.String right)
          Return true if the specified right is being referenced.
protected static void load()
          Load the current state of the roles from the database.
protected static Dictionary loadr()
          Load and return the current state of the roles from the database.
 void logoff(SecurityContext context)
          Perform logoff handling on this role.
 void logon(SecurityContext context, java.lang.String user, java.lang.String password, java.lang.Object object)
          Perform logon handling on this role.
protected static int numberOfRoles()
          Return the number of roles that are currently defined.
protected static void reset()
          Reset the roles.
 void resetAttributes()
          Reset all attributes of this role with the exception of the role's name.
protected static Dictionary roles()
          Return a copy of the dictionary of roles.
protected static void save()
          Save the current state of the roles to the database.
protected static void setDB(SecurityPersistence securityPersistence)
          Set the persistence controller for this class.
protected static void setFileName(java.lang.String fileName)
          Set the filename of this database.
protected static void setPersist(boolean persistence)
          Enable or disable persistence for roles.
 void setRoleHandler(RoleHandlerInterface handler)
          Set the role handler.
 void setRoleHandler(java.lang.String handler)
          Set the role handler.
protected static void shutdown()
          Shutdown the security component.
 void signoff(SecurityContext context)
          Perform signoff handling on this role.
 void signon(SecurityContext context, java.lang.String user, java.lang.String password)
          Perform signon handling on this role.
 java.lang.String toString()
          Returns a string representation of this object.
 void verify()
          Verify this role.
protected static void verifyAll()
          Verify the consistancy of this database.
 
Methods inherited from class com.ibm.dse.applsrv.aa.SecurityObject
getData, getData, getDataOrNull, getName, home, prefix, putData, putData, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SecurityRole

protected SecurityRole(java.lang.String nameOfRole)
                throws DSESecurityException
Create a new instance of a Role with the specified name.
Parameters:
nameOfRole - String - the name of this role.
Throws:
DSESecurityException - - error in the request.

SecurityRole

protected SecurityRole(java.lang.String nameOfRole,
                       RoleHandlerInterface handler)
                throws DSESecurityException
Create a new instance of a Role with the specified name.
Parameters:
nameOfRole - String - the name of this role.
handler - RoleHandlerInterface - the role handler.
Throws:
DSESecurityException - - error in the request.

SecurityRole

protected SecurityRole(java.lang.String nameOfRole,
                       java.lang.String handler)
                throws DSESecurityException
Create a new instance of a Role with the specified name.
Parameters:
nameOfRole - String - the name of this role.
handler - String - the name of the class of the role handler.
Throws:
DSESecurityException - - error in the request.
Method Detail

_save

protected void _save()
              throws DSESecurityException
A hack to force inheritence of a static method.
Overrides:
_save in class SecurityObject
Throws:
DSESecurityException - - abstract method.

addRight

public void addRight(java.lang.String right)
              throws DSESecurityException
Add the named right to this role.
Parameters:
right - String - the name of the right to add.
Throws:
DSESecurityException - - error in the request.

addRights

public void addRights(java.lang.String[] namesOfRights)
               throws DSESecurityException
Add rights to this role.
Parameters:
namesOfRights - String[] - the names of the rights.
Throws:
DSESecurityException - - error in the request.

addSubRole

public void addSubRole(java.lang.String subroleName)
                throws DSESecurityException
Add a subrole to the current role.
Parameters:
subroleName - String - the role to add.
Throws:
DSESecurityException - - error in the request.

addSubRoleNCNS

public void addSubRoleNCNS(java.lang.String subroleName)
Add a subrole to the current role. Don't check the subrole for validity and don't save.
Parameters:
subroleName - String - the role to add.

controller

public static void controller(SecurityController ctrl)
Set the security controller.
Parameters:
ctrl - SecurityController - the security controller.

delete

public boolean delete()
               throws DSESecurityException
Delete this role.
Returns:
boolean - true if the delete succeeded else false.
Throws:
DSESecurityException - - database error.

delete

protected static boolean delete(java.lang.String nameOfRole)
                         throws DSESecurityException
Delete the named role.
Parameters:
nameOfRole - String - the name of the role to delete.
Returns:
boolean - true if the delete succeeded else false.
Throws:
DSESecurityException - - database error.

deleteRight

public void deleteRight(java.lang.String right)
                 throws DSESecurityException
Delete the named right from this role.
Parameters:
right - String - the name of the right to delete.
Throws:
DSESecurityException - - error in the request.

deleteRights

public void deleteRights(java.lang.String[] namesOfRights)
                  throws DSESecurityException
Delete the rights from this role.
Parameters:
namesOfRights - String[] - the names of the rights.
Throws:
DSESecurityException - - error in the request.

deleteRoles

protected static boolean deleteRoles(java.lang.String[] rolesToDelete,
                                     java.lang.String[] options)
                              throws DSESecurityException
Delete the named roles subject to the specified options. OPTIONS: atomic , child , exception , nosave , references , safe , skip.
Parameters:
rolesToDelete - String[] - the names of the roles to delete.
options - String[] - the options for this command.
Returns:
boolean - true if the deletes succeeded else false.
Throws:
DSESecurityException - - error in the request.

deleteSubRole

public void deleteSubRole(java.lang.String childRoleName)
                   throws DSESecurityException
Delete a child role from the current role.
Parameters:
childRoleName - String - the name of the role to delete.
Throws:
DSESecurityException - - error in the request.

disablePersist

protected static boolean disablePersist()
Disable persistence for roles.
Returns:
boolean - true if roles were persisting else false.

enumerationOverRoles

protected static java.util.Enumeration enumerationOverRoles()
Return an enumeration over the roles.
Returns:
Enumeration - the enumeration over the roles.

forceSave

protected static void forceSave()
                         throws DSESecurityException
Force a save of the current state of the roles to the database.
Throws:
DSESecurityException - - database error.

get

protected static SecurityRole get(java.lang.String nameOfRole,
                                  boolean create)
                           throws DSESecurityException
Return the role with the specified name. If the role doesn't exist & the create option is false then return null else create & return a new role with the specified name.
Parameters:
nameOfRole - String - the name of the role.
create - boolean - if the role does not exist then if true then create it else just return null.
Returns:
SecurityRole - the role.
Throws:
DSESecurityException - - error in the request.

getAllRights

public Array getAllRights()
Return the list of all rights contained within this role or any subrole thereof.
Returns:
Array - the list of all rights.

getAttributes

public Dictionary getAttributes()
                         throws DSESecurityException
Return a dictionary containing all of the attributes of this role.
Returns:
Dictionary - a dictionary containing all of the attributes of this role.
Throws:
DSESecurityException - - database error.

getDB

protected static SecurityPersistence getDB()
Return the persistence controller for this class.
Returns:
SecurityPersistence - the persistence controller.

getPathName

protected static java.lang.String getPathName()
Return the pathname of this database of roles.
Returns:
String - the pathname of this database or null if its not configured.

getPersist

protected static boolean getPersist()
Return the persistence state for roles.
Returns:
boolean - true if roles are persisting else false.

getRights

public Array getRights()
Return a copy of the list of rights associated with this role.
Returns:
Array - a copy of the list of rights.

getRightsAsArray

public java.lang.String[] getRightsAsArray()
Return a copy of the list of rights associated with this role.
Returns:
String[] - a copy of the list of rights.

getRightsAsArrayOrNull

public java.lang.String[] getRightsAsArrayOrNull()
Return a copy of the list of rights associated with this role.
Returns:
String[] - a copy of the list of rights.

getRoleHandler

public RoleHandlerInterface getRoleHandler()
Return the handler for this role or null if none is defined.
Returns:
RoleHandlerInterface - the role handler.

getRoleHandlerAsString

public java.lang.String getRoleHandlerAsString()
Return the name of the handler class associated with the named role.
Returns:
String - the name of the handler class associated with the named role.

getRoleIds

protected static java.lang.String[] getRoleIds()
Return the list of names of the roles.
Returns:
String[] - the list of names of the roles.

getSubRoles

public Array getSubRoles()
Return a copy of the list of child roles associated with this role.
Returns:
Array - a copy of the list of child roles.

getSubRolesAsArray

public java.lang.String[] getSubRolesAsArray()
Return a copy of the list of child roles associated with this role.
Returns:
String[] - a copy of the list of child roles.

getSubRolesAsArrayOrNull

public java.lang.String[] getSubRolesAsArrayOrNull()
Return a copy of the list of child roles associated with this role.
Returns:
String[] - a copy of the list of child roles.

hasDescendant

public boolean hasDescendant(java.lang.String nameOfRole)
Return true if the named role is this role or one of its descendants.
Parameters:
nameOfRole - String - the name of the role.
Returns:
boolean - the result of the search.

hasDirectRight

public boolean hasDirectRight(java.lang.String right)
Return true if this role has the specified right. Do NOT check if the right is valid.
Parameters:
right - String - the name of the right.
Returns:
boolean - true if this role has the right else false.

hasRight

public boolean hasRight(java.lang.String right)
Return true if this role directly or indirectly (via subroles) has the specified right. Do NOT check if the right is valid.
Parameters:
right - String - the name of the right.
Returns:
boolean - true if this role has the right else false.

isReferencingRight

public boolean isReferencingRight(java.lang.String right)
Return true if the specified right is being referenced. Do NOT check if the right is valid.
Parameters:
right - String - the name of the right.
Returns:
boolean - true if the right is being referenced else false.

load

protected static void load()
                    throws DSESecurityException
Load the current state of the roles from the database.
Throws:
DSESecurityException - - database error.

loadr

protected static Dictionary loadr()
                           throws DSESecurityException
Load and return the current state of the roles from the database.
Returns:
Dictionary - the database.
Throws:
DSESecurityException - - database error.

logoff

public void logoff(SecurityContext context)
            throws DSESecurityException
Perform logoff handling on this role.
Parameters:
context - SecurityContext - the context.
Throws:
DSESecurityException - - error in the request.

logon

public void logon(SecurityContext context,
                  java.lang.String user,
                  java.lang.String password,
                  java.lang.Object object)
           throws DSESecurityException
Perform logon handling on this role.
Parameters:
context - SecurityContext - the context.
user - String - the user id.
password - String - the password.
object - Object - an arbitrary object interpreted by the role handler.
Throws:
DSESecurityException - - error in the request.

numberOfRoles

protected static int numberOfRoles()
Return the number of roles that are currently defined.
Returns:
int - the number of roles that are currently defined.

reset

protected static void reset()
                     throws DSESecurityException
Reset the roles.
Throws:
DSESecurityException - - database error.

resetAttributes

public void resetAttributes()
                     throws DSESecurityException
Reset all attributes of this role with the exception of the role's name.
Throws:
DSESecurityException - - error during save.

roles

protected static Dictionary roles()
Return a copy of the dictionary of roles.
Returns:
Dictionary - a copy of the roles.

save

protected static void save()
                    throws DSESecurityException
Save the current state of the roles to the database.
Throws:
DSESecurityException - - database error.

setDB

protected static void setDB(SecurityPersistence securityPersistence)
Set the persistence controller for this class.
Parameters:
securityPersistence - SecurityPersistence - the persistence controller.

setFileName

protected static void setFileName(java.lang.String fileName)
Set the filename of this database.
Parameters:
fileName - String - the name of this database.

setPersist

protected static void setPersist(boolean persistence)
Enable or disable persistence for roles.
Parameters:
persistence - boolean - true to enable persistence, false to disable it.

setRoleHandler

public void setRoleHandler(RoleHandlerInterface handler)
                    throws DSESecurityException
Set the role handler.
Parameters:
handler - RoleHandlerInterface - the role handler.
Throws:
DSESecurityException - - database error.

setRoleHandler

public void setRoleHandler(java.lang.String handler)
                    throws DSESecurityException
Set the role handler.
Parameters:
handler - String - the name of the role handler class.
Throws:
DSESecurityException - - error in the request.

shutdown

protected static void shutdown()
                        throws DSESecurityException
Shutdown the security component.
Throws:
DSESecurityException - - error in the request.

signoff

public void signoff(SecurityContext context)
             throws DSESecurityException
Perform signoff handling on this role.
Parameters:
context - SecurityContext - the context.
Throws:
DSESecurityException - - error in the request.

signon

public void signon(SecurityContext context,
                   java.lang.String user,
                   java.lang.String password)
            throws DSESecurityException
Perform signon handling on this role.
Parameters:
context - SecurityContext - the context.
user - String - the user id.
password - String - the password.
Throws:
DSESecurityException - - error in the request.

toString

public java.lang.String toString()
Returns a string representation of this object.
Overrides:
toString in class java.lang.Object
Returns:
String - a string representation of this object.

verify

public void verify()
            throws DSESecurityException
Verify this role.
Throws:
DSESecurityException - - error in the request.

verifyAll

protected static void verifyAll()
                         throws DSESecurityException
Verify the consistancy of this database.
Throws:
DSESecurityException - - error in the request.