org.enhydra.shark.usergroup
Class DODSUserGroupManagerAdmin

java.lang.Object
  extended by org.enhydra.shark.usergroup.DODSUserGroupManagerAdmin
All Implemented Interfaces:
org.enhydra.shark.api.admin.UserGroupManagerAdmin, UserGroupManager

public class DODSUserGroupManagerAdmin
extends java.lang.Object
implements org.enhydra.shark.api.admin.UserGroupManagerAdmin

Used for managing users, groups and their relations.

Version:
0.1
Author:
Sasa Bojanic, Vladimir Puskas, Tanja Jovanovic

Constructor Summary
DODSUserGroupManagerAdmin()
           
 
Method Summary
 void addGroupToGroup(java.lang.String groupName, java.lang.String subgroupName)
          Adds an existing group subgroupName to the group groupName.
 void addUserToGroup(java.lang.String groupName, java.lang.String username)
          Adds an existing user with a given username to the given group.
 void configure(CallbackUtilities cus)
          Method configure is called at Shark start up, to configure implementation of DODSUserGroupManager.
 void createGroup(java.lang.String groupName, java.lang.String description)
          Creates a new user group.
 void createUser(java.lang.String groupName, java.lang.String username, java.lang.String password, java.lang.String firstName, java.lang.String lastName, java.lang.String emailAddress)
          Allows administrator to create new user.
 boolean doesGroupBelongToGroup(WMSessionHandle shandle, java.lang.String groupName, java.lang.String subgroupName)
          Returns true if group subgroupName is subgroup of group groupName.
protected  boolean doesGroupExist(java.lang.String groupName)
          Returns true if user group with given name exists.
 boolean doesGroupExist(WMSessionHandle shandle, java.lang.String groupName)
          Returns true if user group with given name exists.
 boolean doesUserBelongToGroup(WMSessionHandle shandle, java.lang.String groupName, java.lang.String username)
          Returns true if the given user belongs to the given group.
protected  boolean doesUserExist(java.lang.String username)
          Returns true if user with given username exists.
 boolean doesUserExist(WMSessionHandle shandle, java.lang.String username)
          Returns true if user with given username exists.
 java.lang.String[] getAllGroupnames(WMSessionHandle shandle)
          Returns Ids of all user groups.
 java.lang.String[] getAllGroupnamesForUser(WMSessionHandle shandle, java.lang.String userName)
          Returns Ids of all groups for the given user.
 java.lang.String[] getAllImmediateSubgroupsForGroup(WMSessionHandle shandle, java.lang.String groupName)
          Returns all groups that are immediate children of the given group (which are on the first level bellow the level of the given group).
 java.lang.String[] getAllImmediateUsersForGroup(WMSessionHandle shandle, java.lang.String groupName)
          Returns all users that are immediate children of the given group.
protected  java.lang.String[] getAllSubgroupsForGroup(WMSessionHandle shandle, java.lang.String groupName)
          Returns all groups that belong to the given group.
 java.lang.String[] getAllSubgroupsForGroups(WMSessionHandle shandle, java.lang.String[] groupNames)
          Returns all groups that belong to the given groups.
 java.lang.String[] getAllUsers(WMSessionHandle shandle)
          Returns Ids of all users.
protected  java.lang.String[] getAllUsersForGroup(WMSessionHandle shandle, java.lang.String groupName)
          Returns all usernames that belong to the given group.
 java.lang.String[] getAllUsersForGroups(WMSessionHandle shandle, java.lang.String[] groupNames)
          Returns all users that belong to the given groups.
protected  com.lutris.appserver.server.sql.DBTransaction getDBTransaction()
           
 java.lang.String getGroupAttribute(WMSessionHandle shandle, java.lang.String groupName, java.lang.String attName)
          If you call this method exception will be thrown - DODS implementation of UserGroup interface does not implement this method.
 java.lang.String getGroupDescription(WMSessionHandle shandle, java.lang.String groupName)
          Returns a group description.
 java.lang.String[] getGroups(WMSessionHandle sessionHandle, java.lang.String expression)
           
 java.lang.String[] getObjects(WMSessionHandle sessionHandle, java.lang.String expression)
           
 java.lang.String getUserAttribute(WMSessionHandle shandle, java.lang.String username, java.lang.String attName)
          If you call this method exception will be thrown - DODS implementation of UserGroup interface does not implement this method.
 java.lang.String getUserEMailAddress(WMSessionHandle shandle, java.lang.String username)
          Returns string representing email address for the user with the given username.
 java.lang.String getUserFirstName(WMSessionHandle shandle, java.lang.String username)
          Returns string representing user's first name.
 java.lang.String getUserLastName(WMSessionHandle shandle, java.lang.String username)
          Returns string representing user's last name.
 java.lang.String getUserPassword(WMSessionHandle shandle, java.lang.String username)
           
 java.lang.String getUserRealName(WMSessionHandle shandle, java.lang.String username)
          Returns string representing the real name for the shark user with the given username (first and last name).
 void moveGroup(java.lang.String currentParentGroup, java.lang.String newParentGroup, java.lang.String subgroupName)
          Moves group subgroupName from the group currentParentGroup to group newParentGroup.
 void moveUser(java.lang.String currentGroup, java.lang.String newGroup, java.lang.String username)
          Moves user username from the group currentGroup to group newGroup.
protected  void refreshDOCaches()
           
 void removeGroup(java.lang.String groupName)
          Removes user group.
 void removeGroupFromGroup(java.lang.String groupName, java.lang.String subgroupName)
          Removes group subgroupName from the group groupName.
 void removeGroupTree(java.lang.String groupName)
          Deletes group groupName and all its child groups that don't belong to any other group except this one.
 void removeUser(java.lang.String username)
          Allows administrator to remove the user.
 void removeUserFromGroup(java.lang.String groupName, java.lang.String username)
          Removes the user from the group.
 void removeUsersFromGroupTree(java.lang.String groupName)
          Removes all users from group group that don't belong to any other group except this one.
protected  void setLDBName()
           
 void setPassword(java.lang.String username, java.lang.String password)
          Sets user password.
 void updateGroup(java.lang.String groupName, java.lang.String description)
          Allows administrator to update data about group.
 void updateUser(java.lang.String username, java.lang.String firstName, java.lang.String lastName, java.lang.String emailAddress)
          Allows administrator to update data about user.
 boolean validateUser(java.lang.String username, java.lang.String password)
          Validates user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DODSUserGroupManagerAdmin

public DODSUserGroupManagerAdmin()
Method Detail

configure

public void configure(CallbackUtilities cus)
               throws java.lang.Exception
Method configure is called at Shark start up, to configure implementation of DODSUserGroupManager.

Specified by:
configure in interface UserGroupManager
Parameters:
cus - an instance of CallbackUtilities used to get properties for configuring user group manager in Shark.
Throws:
java.lang.Exception - thrown if configuring doesn't succeed.

getAllGroupnames

public java.lang.String[] getAllGroupnames(WMSessionHandle shandle)
                                    throws java.lang.Exception
Returns Ids of all user groups.

Specified by:
getAllGroupnames in interface UserGroupManager
Returns:
List of user group Ids.
Throws:
java.lang.Exception - If something unexpected happens.

getAllGroupnamesForUser

public java.lang.String[] getAllGroupnamesForUser(WMSessionHandle shandle,
                                                  java.lang.String userName)
                                           throws java.lang.Exception
Returns Ids of all groups for the given user.

Specified by:
getAllGroupnamesForUser in interface UserGroupManager
Parameters:
userName - name of the given user.
Returns:
List of all group ids for the given user.
Throws:
java.lang.Exception - If something unexpected happens.

getAllUsers

public java.lang.String[] getAllUsers(WMSessionHandle shandle)
                               throws java.lang.Exception
Returns Ids of all users.

Specified by:
getAllUsers in interface UserGroupManager
Returns:
List of user Ids.
Throws:
java.lang.Exception - If something unexpected happens.

getAllUsersForGroup

protected java.lang.String[] getAllUsersForGroup(WMSessionHandle shandle,
                                                 java.lang.String groupName)
                                          throws java.lang.Exception
Returns all usernames that belong to the given group.

Parameters:
groupName - name of the given group.
Returns:
List of all usernames that belong to given group.
Throws:
java.lang.Exception - If something unexpected happens.

getAllUsersForGroups

public java.lang.String[] getAllUsersForGroups(WMSessionHandle shandle,
                                               java.lang.String[] groupNames)
                                        throws java.lang.Exception
Returns all users that belong to the given groups.

Specified by:
getAllUsersForGroups in interface UserGroupManager
Parameters:
groupNames - names of the given groups.
Returns:
List of all users that belong to given groups.
Throws:
java.lang.Exception - If something unexpected happens.

getAllImmediateUsersForGroup

public java.lang.String[] getAllImmediateUsersForGroup(WMSessionHandle shandle,
                                                       java.lang.String groupName)
                                                throws java.lang.Exception
Returns all users that are immediate children of the given group.

Specified by:
getAllImmediateUsersForGroup in interface UserGroupManager
Parameters:
groupName - name of the given group.
Returns:
List of all immediate (direct) users that belong to the given group.
Throws:
java.lang.Exception - If something unexpected happens.

getAllSubgroupsForGroup

protected java.lang.String[] getAllSubgroupsForGroup(WMSessionHandle shandle,
                                                     java.lang.String groupName)
                                              throws java.lang.Exception
Returns all groups that belong to the given group.

Parameters:
groupName - name of the given group.
Returns:
List of all groups that belong to the given group.
Throws:
java.lang.Exception - If something unexpected happens.

getAllSubgroupsForGroups

public java.lang.String[] getAllSubgroupsForGroups(WMSessionHandle shandle,
                                                   java.lang.String[] groupNames)
                                            throws java.lang.Exception
Returns all groups that belong to the given groups.

Specified by:
getAllSubgroupsForGroups in interface UserGroupManager
Parameters:
groupNames - names of the given groups.
Returns:
List of all groups that belong to the given groups.
Throws:
java.lang.Exception - If something unexpected happens.

getAllImmediateSubgroupsForGroup

public java.lang.String[] getAllImmediateSubgroupsForGroup(WMSessionHandle shandle,
                                                           java.lang.String groupName)
                                                    throws java.lang.Exception
Returns all groups that are immediate children of the given group (which are on the first level bellow the level of the given group).

Specified by:
getAllImmediateSubgroupsForGroup in interface UserGroupManager
Parameters:
groupName - name of the given group.
Returns:
List of all groups that are immediate children of the given group.
Throws:
java.lang.Exception - If something unexpected happens.

doesGroupExist

public boolean doesGroupExist(WMSessionHandle shandle,
                              java.lang.String groupName)
                       throws java.lang.Exception
Returns true if user group with given name exists.

Specified by:
doesGroupExist in interface UserGroupManager
Parameters:
groupName - name of the given group.
Returns:
true if user group exists, otherwise false.
Throws:
java.lang.Exception - If something unexpected happens.

doesGroupBelongToGroup

public boolean doesGroupBelongToGroup(WMSessionHandle shandle,
                                      java.lang.String groupName,
                                      java.lang.String subgroupName)
                               throws java.lang.Exception
Returns true if group subgroupName is subgroup of group groupName.

Specified by:
doesGroupBelongToGroup in interface UserGroupManager
Parameters:
groupName - name of the given group.
subgroupName - name of the given subgroup.
Returns:
true if group subgroupName is subgroup of group groupName, otherwise false.
Throws:
java.lang.Exception - If something unexpected happens.

getGroupDescription

public java.lang.String getGroupDescription(WMSessionHandle shandle,
                                            java.lang.String groupName)
                                     throws java.lang.Exception
Returns a group description.

Specified by:
getGroupDescription in interface UserGroupManager
Parameters:
groupName - name of the given group.
Returns:
Group description.
Throws:
java.lang.Exception - If something unexpected happens.

doesUserBelongToGroup

public boolean doesUserBelongToGroup(WMSessionHandle shandle,
                                     java.lang.String groupName,
                                     java.lang.String username)
                              throws java.lang.Exception
Returns true if the given user belongs to the given group.

Specified by:
doesUserBelongToGroup in interface UserGroupManager
Parameters:
groupName - name of the given group.
username - username used to uniquely identify shark user.
Returns:
true if the given user belongs to the given group, otherwise false.
Throws:
java.lang.Exception - If something unexpected happens.

doesUserExist

public boolean doesUserExist(WMSessionHandle shandle,
                             java.lang.String username)
                      throws java.lang.Exception
Returns true if user with given username exists.

Specified by:
doesUserExist in interface UserGroupManager
Parameters:
username - username of the shark user.
Returns:
true if the user with the given username exists, otherwise false.
Throws:
java.lang.Exception - If something unexpected happens.

getUserPassword

public java.lang.String getUserPassword(WMSessionHandle shandle,
                                        java.lang.String username)
                                 throws java.lang.Exception
Specified by:
getUserPassword in interface UserGroupManager
Throws:
java.lang.Exception

getUserRealName

public java.lang.String getUserRealName(WMSessionHandle shandle,
                                        java.lang.String username)
                                 throws java.lang.Exception
Returns string representing the real name for the shark user with the given username (first and last name).

Specified by:
getUserRealName in interface UserGroupManager
Parameters:
username - username of the shark user.
Returns:
Real name of the shark user.
Throws:
java.lang.Exception - If something unexpected happens.

getUserFirstName

public java.lang.String getUserFirstName(WMSessionHandle shandle,
                                         java.lang.String username)
                                  throws java.lang.Exception
Returns string representing user's first name.

Specified by:
getUserFirstName in interface UserGroupManager
Parameters:
username - username of the shark user.
Returns:
First name of the shark user.
Throws:
java.lang.Exception - If something unexpected happens.

getUserLastName

public java.lang.String getUserLastName(WMSessionHandle shandle,
                                        java.lang.String username)
                                 throws java.lang.Exception
Returns string representing user's last name.

Specified by:
getUserLastName in interface UserGroupManager
Parameters:
username - username of the shark user.
Returns:
Last name of the shark user.
Throws:
java.lang.Exception - If something unexpected happens.

getUserEMailAddress

public java.lang.String getUserEMailAddress(WMSessionHandle shandle,
                                            java.lang.String username)
                                     throws java.lang.Exception
Returns string representing email address for the user with the given username.

Specified by:
getUserEMailAddress in interface UserGroupManager
Parameters:
username - username of the shark user.
Returns:
Email of the shark user.
Throws:
java.lang.Exception - If something unexpected happens.

createGroup

public void createGroup(java.lang.String groupName,
                        java.lang.String description)
                 throws java.lang.Exception
Creates a new user group.

Specified by:
createGroup in interface org.enhydra.shark.api.admin.UserGroupManagerAdmin
Parameters:
groupName - name of the given group.
description - group description.
Throws:
java.lang.Exception - If something unexpected happens.

removeGroup

public void removeGroup(java.lang.String groupName)
                 throws java.lang.Exception
Removes user group.

Specified by:
removeGroup in interface org.enhydra.shark.api.admin.UserGroupManagerAdmin
Parameters:
groupName - name of the given group.
Throws:
java.lang.Exception - If something unexpected happens.

updateGroup

public void updateGroup(java.lang.String groupName,
                        java.lang.String description)
                 throws java.lang.Exception
Allows administrator to update data about group.

Specified by:
updateGroup in interface org.enhydra.shark.api.admin.UserGroupManagerAdmin
Parameters:
groupName - name of the given group.
description - group description.
Throws:
java.lang.Exception - If something unexpected happens.

addGroupToGroup

public void addGroupToGroup(java.lang.String groupName,
                            java.lang.String subgroupName)
                     throws java.lang.Exception
Adds an existing group subgroupName to the group groupName.

Specified by:
addGroupToGroup in interface org.enhydra.shark.api.admin.UserGroupManagerAdmin
Parameters:
groupName - name of the given group.
subgroupName - name of the given subgroup to be added.
Throws:
java.lang.Exception - If something unexpected happens.

removeGroupFromGroup

public void removeGroupFromGroup(java.lang.String groupName,
                                 java.lang.String subgroupName)
                          throws java.lang.Exception
Removes group subgroupName from the group groupName.

Specified by:
removeGroupFromGroup in interface org.enhydra.shark.api.admin.UserGroupManagerAdmin
Parameters:
groupName - name of the given group.
subgroupName - name of the given subgroup to be removed.
Throws:
java.lang.Exception - If something unexpected happens.

removeGroupTree

public void removeGroupTree(java.lang.String groupName)
                     throws java.lang.Exception
Deletes group groupName and all its child groups that don't belong to any other group except this one.

Specified by:
removeGroupTree in interface org.enhydra.shark.api.admin.UserGroupManagerAdmin
Parameters:
groupName - name of the given group.
Throws:
java.lang.Exception - If something unexpected happens.

removeUsersFromGroupTree

public void removeUsersFromGroupTree(java.lang.String groupName)
                              throws java.lang.Exception
Removes all users from group group that don't belong to any other group except this one.

Specified by:
removeUsersFromGroupTree in interface org.enhydra.shark.api.admin.UserGroupManagerAdmin
Parameters:
groupName - name of the given group.
Throws:
java.lang.Exception - If something unexpected happens.

moveGroup

public void moveGroup(java.lang.String currentParentGroup,
                      java.lang.String newParentGroup,
                      java.lang.String subgroupName)
               throws java.lang.Exception
Moves group subgroupName from the group currentParentGroup to group newParentGroup.

Specified by:
moveGroup in interface org.enhydra.shark.api.admin.UserGroupManagerAdmin
Parameters:
currentParentGroup - current group that contains group subgroupName.
newParentGroup - new group where group subgroupName will be moved to.
subgroupName - subgroup that will be moved.
Throws:
java.lang.Exception - If something unexpected happens.

addUserToGroup

public void addUserToGroup(java.lang.String groupName,
                           java.lang.String username)
                    throws java.lang.Exception
Adds an existing user with a given username to the given group.

Specified by:
addUserToGroup in interface org.enhydra.shark.api.admin.UserGroupManagerAdmin
Parameters:
groupName - name of the given group.
username - username used to uniquely identify shark user.
Throws:
java.lang.Exception - If something unexpected happens.

removeUserFromGroup

public void removeUserFromGroup(java.lang.String groupName,
                                java.lang.String username)
                         throws java.lang.Exception
Removes the user from the group.

Specified by:
removeUserFromGroup in interface org.enhydra.shark.api.admin.UserGroupManagerAdmin
Parameters:
groupName - name of the given group.
username - username used to uniquely identify shark user.
Throws:
java.lang.Exception - If something unexpected happens.

moveUser

public void moveUser(java.lang.String currentGroup,
                     java.lang.String newGroup,
                     java.lang.String username)
              throws java.lang.Exception
Moves user username from the group currentGroup to group newGroup.

Specified by:
moveUser in interface org.enhydra.shark.api.admin.UserGroupManagerAdmin
Parameters:
currentGroup - current group that contains the user.
newGroup - new group where the user will be moved to.
username - the user that will be moved.
Throws:
java.lang.Exception - If something unexpected happens.

getObjects

public java.lang.String[] getObjects(WMSessionHandle sessionHandle,
                                     java.lang.String expression)
                              throws java.lang.Exception
Specified by:
getObjects in interface UserGroupManager
Throws:
java.lang.Exception

getGroups

public java.lang.String[] getGroups(WMSessionHandle sessionHandle,
                                    java.lang.String expression)
                             throws java.lang.Exception
Specified by:
getGroups in interface UserGroupManager
Throws:
java.lang.Exception

createUser

public void createUser(java.lang.String groupName,
                       java.lang.String username,
                       java.lang.String password,
                       java.lang.String firstName,
                       java.lang.String lastName,
                       java.lang.String emailAddress)
                throws java.lang.Exception
Allows administrator to create new user. After its creation, the client application will always be able to log onto shark using username and password defined for the user.

Specified by:
createUser in interface org.enhydra.shark.api.admin.UserGroupManagerAdmin
Parameters:
groupName - groupName used to uniquely identify group - this parameter is mandatory.
username - username used to uniquely identify user - this parameter is mandatory.
password - password used to authenticate - this parameter is mandatory.
firstName - the user's first name.
lastName - the user's last name.
emailAddress - email address of the user.
Throws:
java.lang.Exception - If something unexpected happens (i.e the user with given username already exists).

updateUser

public void updateUser(java.lang.String username,
                       java.lang.String firstName,
                       java.lang.String lastName,
                       java.lang.String emailAddress)
                throws java.lang.Exception
Allows administrator to update data about user.

Specified by:
updateUser in interface org.enhydra.shark.api.admin.UserGroupManagerAdmin
Parameters:
username - username used to uniquely identify user - this parameter is mandatory.
firstName - the user's first name.
lastName - the user's last name.
emailAddress - email address of the user.
Throws:
java.lang.Exception - If something unexpected happens (i.e the user with given username does not exist).

removeUser

public void removeUser(java.lang.String username)
                throws java.lang.Exception
Allows administrator to remove the user.

Specified by:
removeUser in interface org.enhydra.shark.api.admin.UserGroupManagerAdmin
Parameters:
username - username used to uniquely identify user.
Throws:
java.lang.Exception - If something unexpected happens (i.e the user with given username does not exist, or this is a user that can't be removed).

setPassword

public void setPassword(java.lang.String username,
                        java.lang.String password)
                 throws java.lang.Exception
Sets user password.

Specified by:
setPassword in interface org.enhydra.shark.api.admin.UserGroupManagerAdmin
Parameters:
username - username of the shark user.
password - new password of the shark user.
Throws:
java.lang.Exception - If something unexpected happens.

validateUser

public boolean validateUser(java.lang.String username,
                            java.lang.String password)
                     throws java.lang.Exception
Validates user.

Specified by:
validateUser in interface UserGroupManager
Parameters:
username - user name.
password - user password.
Returns:
true if user is validated, otherwise false.
Throws:
java.lang.Exception - If something unexpected happens.

doesGroupExist

protected boolean doesGroupExist(java.lang.String groupName)
                          throws java.lang.Exception
Returns true if user group with given name exists.

Parameters:
groupName - name of the given group.
Returns:
true if user group exists, otherwise false.
Throws:
java.lang.Exception - If something unexpected happens.

doesUserExist

protected boolean doesUserExist(java.lang.String username)
                         throws java.lang.Exception
Returns true if user with given username exists.

Parameters:
username - username of the shark user.
Returns:
true if the user with the given username exists, otherwise false.
Throws:
java.lang.Exception - If something unexpected happens.

getDBTransaction

protected com.lutris.appserver.server.sql.DBTransaction getDBTransaction()
                                                                  throws java.lang.Exception
Throws:
java.lang.Exception

setLDBName

protected void setLDBName()

refreshDOCaches

protected void refreshDOCaches()
                        throws java.lang.Exception
Throws:
java.lang.Exception

getGroupAttribute

public java.lang.String getGroupAttribute(WMSessionHandle shandle,
                                          java.lang.String groupName,
                                          java.lang.String attName)
                                   throws java.lang.Exception
If you call this method exception will be thrown - DODS implementation of UserGroup interface does not implement this method.

Specified by:
getGroupAttribute in interface UserGroupManager
Throws:
java.lang.Exception

getUserAttribute

public java.lang.String getUserAttribute(WMSessionHandle shandle,
                                         java.lang.String username,
                                         java.lang.String attName)
                                  throws java.lang.Exception
If you call this method exception will be thrown - DODS implementation of UserGroup interface does not implement this method.

Specified by:
getUserAttribute in interface UserGroupManager
Throws:
java.lang.Exception