|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.lightdev.app.trec.server.Agent
com.lightdev.app.trec.server.sam.SAMAdministrator
public class SAMAdministrator
SAMAdministrator is the class to manage users and roles and to associate users to roles within the Light Development Simple Access Model. SAMAdministrator basically uses methods of a user data store administrator object and adds role information to method names as required by interface SAMApplication. This enables a TREC Server object to automatically apply appropriate authentication and authorization.
When a JDBC user data store supporting transactions is used, SAMAdministrator automatically keeps referential integrity, e.g. when deleting a role, all associations to the deleted role are deleted too.
| Field Summary | |
|---|---|
static String |
DEFAULT_NAME
|
| Fields inherited from class com.lightdev.app.trec.server.Agent |
|---|
communicator |
| Constructor Summary | |
|---|---|
SAMAdministrator()
construct a SAMAdministrator |
|
| Method Summary | |
|---|---|
boolean |
backupSAM(String backupDirectory)
Make a backup of the SAM data store to a given directory. |
boolean |
changeRole(byte[] roleBytes)
change an existing role |
boolean |
changeUser(byte[] user)
change a user in the UserDataStore this adapter maps to |
boolean |
createRole(byte[] role)
create a new role |
boolean |
createUser(byte[] user,
String pw)
create a user in the UserDataStore this adapter maps to |
boolean |
deleteRole(byte[] role)
delete an existing role |
boolean |
deleteUser(byte[] user)
delete a user from the UserDataStore this adapter maps to |
void |
destroy()
required by abstract Agent class but unsused here |
Vector |
getAvailableBackups()
get the names of all SAM backups currently available on the server |
String[] |
getRequiredRoleIds()
get id of all roles required by this agent |
byte[] |
getRoleForId(String roleId)
get the role with the given id |
byte[] |
getRolesForName(String namePart)
get all users whose name contains a given string |
byte[] |
getRolesForUser(byte[] user)
get the roles that are granted to a given user |
byte[] |
getUsersForName(String namePart)
get all users whose last name contains a given string |
byte[] |
getUsersForRole(byte[] role)
get the users that are granted a given role |
boolean |
grantRole(String userId,
String roleId)
grant the given user a given role |
void |
init()
required by abstract Agent class but unsused here |
protected void |
initMethodRoleMappings()
initialize the mapping between method names, that require a role and respective role id This method is called automatically upon construction but the developer must implement it individually for all methods that are to be guarded by SAM. |
protected void |
initRoleNames()
initialize names of the roles required by this agent This method is called automatically upon construction but the developer must implement it individually for roles that are required by this agent. |
boolean |
newPassword(String userId,
String newPw)
set a given password for a given user |
boolean |
restoreSAM(String backupDirectory)
Restore the SAM data store from a given directory. |
boolean |
revokeRole(String userId,
String roleId)
revoke a given role from a given user |
void |
setUserDataStoreAdministrator(UserDataStoreAdministrator admin)
|
| Methods inherited from class com.lightdev.app.trec.server.Agent |
|---|
getNameForRole, getRoleForMethod, mapRoleToMethod, setCommunicator, setNameForRoleId |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_NAME
| Constructor Detail |
|---|
public SAMAdministrator()
| Method Detail |
|---|
public void setUserDataStoreAdministrator(UserDataStoreAdministrator admin)
public void init()
init in class Agentpublic void destroy()
destroy in class Agent
public boolean backupSAM(String backupDirectory)
throws Exception
Make a backup of the SAM data store to a given directory.
As the SAM user data store not necessarily needs to be a database, this method is implemented only for the case that the standard Light Development implementation of a JDBCStoreAdministrator using an EmbeddedDerbyAdapter is running.
backupDirectory - the directory to backup to; the EmbeddedDerbyAdapter automatically
backs up into the base directory it was constructed with and build a subdirectory named as
the given backupDirectory
Exception
public boolean restoreSAM(String backupDirectory)
throws Exception
Restore the SAM data store from a given directory.
As the SAM user data store not necessarily needs to be a database, this method is implemented only for the case that the standard Light Development implementation of a JDBCStoreAdministrator using an EmbeddedDerbyAdapter is running.
backupDirectory - the directory to restore from; the EmbeddedDerbyAdapter automatically
restores from the base directory it was constructed with and looks for the backup to restore
inside a subdirectory named as the given backupDirectory
Exception
public Vector getAvailableBackups()
throws Exception
Exception
public byte[] getRoleForId(String roleId)
throws Exception
roleId - the id to get the role for
Exception
public byte[] getUsersForRole(byte[] role)
throws Exception
role - the role to get the users for
Exception
public byte[] getRolesForUser(byte[] user)
throws Exception
user - the user to get roles for
Exception
public byte[] getRolesForName(String namePart)
throws Exception
namePart - the name part to contain
Exception
public byte[] getUsersForName(String namePart)
throws Exception
namePart - the name part to contain
Exception
public boolean createUser(byte[] user,
String pw)
throws Exception
user - the user to createpw - the password of the user
Exception - if something went wrong during user creation
public boolean changeUser(byte[] user)
throws Exception
user - the user to change
Exception - if something went wrong
public boolean deleteUser(byte[] user)
throws Exception
user - the user to delete
Exception - if something went wrong
public boolean createRole(byte[] role)
throws Exception
role - the role to create
Exception - if something went wrong
public boolean changeRole(byte[] roleBytes)
throws Exception
roleBytes - the changes to apply
Exception - if something went wrong
public boolean deleteRole(byte[] role)
throws Exception
role - the role to delete
Exception - if something went wrong
public boolean grantRole(String userId,
String roleId)
throws Exception
userId - id of the user to grant a roleroleId - id of role to grant to given user
Exception - if something went wrong
public boolean revokeRole(String userId,
String roleId)
throws Exception
userId - id of user to revoke a role fromroleId - id of role to revoke from given user
Exception - if something went wrong
public boolean newPassword(String userId,
String newPw)
throws Exception
userId - id of the user to set the password fornewPw - password to set for the given user
Exception - if something went wrong during password changepublic String[] getRequiredRoleIds()
getRequiredRoleIds in interface SAMApplicationgetRequiredRoleIds in class Agentprotected void initMethodRoleMappings()
This method is called automatically upon construction but the developer must implement it individually for all methods that are to be guarded by SAM.
initMethodRoleMappings in class Agentprotected void initRoleNames()
This method is called automatically upon construction but the developer must implement it individually for roles that are required by this agent.
initRoleNames in class Agent
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||