org.itracker.services.implementations
Class UserServiceImpl

java.lang.Object
  extended by org.itracker.services.implementations.UserServiceImpl
All Implemented Interfaces:
UserService

public class UserServiceImpl
extends Object
implements UserService

Implements the UserService interface. See that interface for method descriptions.

See Also:
UserService

Constructor Summary
UserServiceImpl(ConfigurationService configurationService, ProjectService projectService, UserDAO userDAO, PermissionDAO permissionDAO, UserPreferencesDAO userPreferencesDAO)
           
UserServiceImpl(ConfigurationService configurationService, ProjectService projectService, UserDAO userDAO, ProjectDAO projectDAO, ReportDAO reportDAO, PermissionDAO permissionDAO, UserPreferencesDAO userPreferencesDAO)
          Deprecated. use constructor without projectDA= und reportDAO instead
 
Method Summary
 boolean addUserPermissions(Integer userId, List<Permission> newPermissions)
          Resets all of the permissions for a user in the database.
 boolean allowPasswordUpdates(User user, Object authentication, int authType, int reqSource)
          This method checks to see if the given user's password can be updated locally.
 boolean allowPermissionUpdates(User user, Object authentication, int authType, int reqSource)
          This method checks to see if the given user's permission information can be updated locally.
 boolean allowPreferenceUpdates(User user, Object authentication, int authType, int reqSource)
          This method checks to see if the given user's preference information can be updated locally.
 boolean allowProfileCreation(User user, Object authentication, int authType, int reqSource)
          This method checks to see if a new user profile can be created within ITracker
 boolean allowProfileUpdates(User user, Object authentication, int authType, int reqSource)
          This method checks to see if the given user's core user profile information can be updated locally.
 boolean allowRegistration(User user, Object authentication, int authType, int reqSource)
          This method checks to see if the given user is allowed to self register.
 User checkLogin(String login, Object authentication, int authType, int reqSource)
          This method checks the login of a user, and returns the user if authentication was successful.
 void clearOwnedProjects(User user)
           
 User createUser(User user)
           
 List<User> findUsersForProjectByPermissionTypeList(Integer projectID, Integer[] permissionTypes)
           
 String generateUserPassword(User user)
           
 List<User> getActiveUsers()
           
 List<User> getAllUsers()
           
 int getNumberUsers()
           
 List<Permission> getPermissionsByUserId(Integer userId)
          Returns an array of Permission objects for the requested userId.
 List<User> getPossibleOwners(Issue issue, Integer projectId, Integer userId)
           
 List<User> getSuperUsers()
           
 User getUser(Integer userId)
           
 User getUserByLogin(String login)
           
 String getUserPasswordByLogin(String login)
           
 List<Permission> getUserPermissionsLocal(User user)
          This method will call local EJBs to find all permissions for a user.
 Map<Integer,Set<PermissionType>> getUsersMapOfProjectIdsAndSetOfPermissionTypes(User user, int reqSource)
          Deprecated. 
 List<User> getUsersWithAnyProjectPermission(Integer projectId, int[] permissionTypes)
          This method will return a list of users with any of the supplied permission, either explicitly, or by their role as a super user.
 List<User> getUsersWithAnyProjectPermission(Integer projectId, int[] permissionTypes, boolean activeOnly)
          This method will return a list of users with any of the supplied permission, either explicitly, or by their role as a super user.
 Collection<User> getUsersWithAnyProjectPermission(Integer projectId, Integer[] permissionTypes)
          This method will return a list of users with any of the supplied permission, either explicitly, or by their role as a super user.
 List<User> getUsersWithPermissionLocal(Integer projectId, int permissionType)
          This method will call local EJBs to find users with a specific permission.
 List<User> getUsersWithProjectPermission(Integer projectId, int permissionType)
          This method will return a list of users with a specific permission, either explicitly, or by their role as a super user.
 List<User> getUsersWithProjectPermission(Integer projectId, int[] permissionTypes, boolean requireAll, boolean activeOnly)
          This method will return a list of users with the supplied permission, either explicitly, or by their role as a super user.
 List<User> getUsersWithProjectPermission(Integer projectId, int permissionType, boolean activeOnly)
          This method will return a list of users with a specific permission, either explicitly, or by their role as a super user.
 boolean removeUserPermissions(Integer userId, List<Permission> newPermissions)
          Resets all of the permissions for a user in the database.
 boolean setUserPermissions(Integer userId, List<Permission> newPermissions)
          Resets all of the permissions for a user in the database.
 boolean updateAuthenticator(Integer userId, List<Permission> permissions)
          Adds an additional set of permissions to a user in the database.
 User updateUser(User user)
           
 UserPreferences updateUserPreferences(UserPreferences userPrefs)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserServiceImpl

public UserServiceImpl(ConfigurationService configurationService,
                       ProjectService projectService,
                       UserDAO userDAO,
                       PermissionDAO permissionDAO,
                       UserPreferencesDAO userPreferencesDAO)
Parameters:
configurationService -
projectService -
userDAO -
permissionDAO -
userPreferencesDAO -

UserServiceImpl

public UserServiceImpl(ConfigurationService configurationService,
                       ProjectService projectService,
                       UserDAO userDAO,
                       ProjectDAO projectDAO,
                       ReportDAO reportDAO,
                       PermissionDAO permissionDAO,
                       UserPreferencesDAO userPreferencesDAO)
Deprecated. use constructor without projectDA= und reportDAO instead

Parameters:
configurationService -
projectService -
userDAO -
projectDAO -
reportDAO -
permissionDAO -
userPreferencesDAO -
Method Detail

getUser

public User getUser(Integer userId)
Specified by:
getUser in interface UserService

getUserByLogin

public User getUserByLogin(String login)
                    throws NoSuchEntityException
Specified by:
getUserByLogin in interface UserService
Throws:
NoSuchEntityException

getUserPasswordByLogin

public String getUserPasswordByLogin(String login)
Specified by:
getUserPasswordByLogin in interface UserService

getAllUsers

public List<User> getAllUsers()
Specified by:
getAllUsers in interface UserService

getNumberUsers

public int getNumberUsers()
Specified by:
getNumberUsers in interface UserService

getActiveUsers

public List<User> getActiveUsers()
Specified by:
getActiveUsers in interface UserService

getSuperUsers

public List<User> getSuperUsers()
Specified by:
getSuperUsers in interface UserService

createUser

public User createUser(User user)
                throws UserException
Specified by:
createUser in interface UserService
Throws:
UserException

updateUser

public User updateUser(User user)
                throws UserException
Specified by:
updateUser in interface UserService
Throws:
UserException

generateUserPassword

public String generateUserPassword(User user)
                            throws PasswordException
Specified by:
generateUserPassword in interface UserService
Throws:
PasswordException

updateUserPreferences

public UserPreferences updateUserPreferences(UserPreferences userPrefs)
                                      throws UserException
Specified by:
updateUserPreferences in interface UserService
Throws:
UserException

clearOwnedProjects

public void clearOwnedProjects(User user)
Specified by:
clearOwnedProjects in interface UserService

findUsersForProjectByPermissionTypeList

public List<User> findUsersForProjectByPermissionTypeList(Integer projectID,
                                                          Integer[] permissionTypes)
Specified by:
findUsersForProjectByPermissionTypeList in interface UserService

getUsersWithPermissionLocal

public List<User> getUsersWithPermissionLocal(Integer projectId,
                                              int permissionType)
Description copied from interface: UserService
This method will call local EJBs to find users with a specific permission. This method is used by the deafult authenticator to manage permissions locally. If a pluggable authenticator is implemented that stores permissions in an external system, calling this method may not have up to date information.

Specified by:
getUsersWithPermissionLocal in interface UserService
Parameters:
projectId - id of the project on which the returned users have permissions
permissionType - the type of permission to search for
Returns:
an array of UserModels containing the users with the permission

getUserPermissionsLocal

public List<Permission> getUserPermissionsLocal(User user)
Description copied from interface: UserService
This method will call local EJBs to find all permissions for a user. This method is used by the deafult authenticator to manage permissions locally. If a pluggable authenticator is implemented that stores permissions in an external system, calling this method may not have up to date information.

Specified by:
getUserPermissionsLocal in interface UserService
Parameters:
user - the user to find the permissions for
Returns:
an array of PermissionModels containing the user's permissions

getPermissionsByUserId

public List<Permission> getPermissionsByUserId(Integer userId)
Description copied from interface: UserService
Returns an array of Permission objects for the requested userId.

Specified by:
getPermissionsByUserId in interface UserService
Parameters:
userId - the userId, not the login, to find the permissions of

updateAuthenticator

public boolean updateAuthenticator(Integer userId,
                                   List<Permission> permissions)
Description copied from interface: UserService
Adds an additional set of permissions to a user in the database. This does not remove any existing permissions. Any duplication permissions will be ignored. Before updating the permissions, this method will call the pluggable authenticator to have the permission set augmented. This augmented set of permissions will then be used for the actual update.

Specified by:
updateAuthenticator in interface UserService
Parameters:
userId - the userId, not login, of the user to add the permissions to
permissions - an array of PermissionModels that represent the new permissions to add to the user
Returns:
true if the operation was successful

addUserPermissions

public boolean addUserPermissions(Integer userId,
                                  List<Permission> newPermissions)
Description copied from interface: UserService
Resets all of the permissions for a user in the database. The new permissions for the user are contained in a HashMap object. The keys of this map MUST be in the format PermProd. For example to add the VIEW_ALL permission to project 3, the key would be Perm7Prod3. The value of the key would be a Permission object. Before updating the permissions, this method will call the pluggable authenticator to have the permission set augmented. This augmented set of permissions will then be used for the actual update.

Specified by:
addUserPermissions in interface UserService
Parameters:
userId - the userId, not login, of the user to add the permissions to
newPermissions - a HashMap containing keys and Permission values as described in the method description.
Returns:
true if the operation was successful
See Also:
UserUtilities

setUserPermissions

public boolean setUserPermissions(Integer userId,
                                  List<Permission> newPermissions)
Description copied from interface: UserService
Resets all of the permissions for a user in the database. The new permissions for the user are contained in a HashMap object. The keys of this map MUST be in the format PermProd. For example to add the VIEW_ALL permission to project 3, the key would be Perm7Prod3. The value of the key would be a Permission object. Before updating the permissions, this method will call the pluggable authenticator to have the permission set augmented. This augmented set of permissions will then be used for the actual update.

Specified by:
setUserPermissions in interface UserService
Parameters:
userId - - id of update-user
newPermissions - - set of new permissions for this user
Returns:
true if the operation was successful
See Also:
UserUtilities

removeUserPermissions

public boolean removeUserPermissions(Integer userId,
                                     List<Permission> newPermissions)
Description copied from interface: UserService
Resets all of the permissions for a user in the database. The new permissions for the user are contained in a HashMap object. The keys of this map MUST be in the format PermProd. For example to add the VIEW_ALL permission to project 3, the key would be Perm7Prod3. The value of the key would be a Permission object. Before updating the permissions, this method will call the pluggable authenticator to have the permission set augmented. This augmented set of permissions will then be used for the actual update.

Specified by:
removeUserPermissions in interface UserService
Parameters:
userId - the userId, not login, of the user to add the permissions to
newPermissions - a HashMap containing keys and Permission values as described in the method description.
Returns:
true if the operation was successful
See Also:
UserUtilities

getUsersMapOfProjectIdsAndSetOfPermissionTypes

@Deprecated
public Map<Integer,Set<PermissionType>> getUsersMapOfProjectIdsAndSetOfPermissionTypes(User user,
                                                                                                  int reqSource)
Deprecated. 

Description copied from interface: UserService
Returns a HashMap of all permissions a user has. The HashMap uses the projectId as the key values, and then contains a HashSet as the value of the key containing Integer objects of the permissions a user has. A special key of the Integer -1 may also be in the HashMap. This key is used to represent if the user is a super user, and in which case the user has all permissions be default. The value of this key would be a Boolen object with the value true if the user was a super user. This HashMap is usually not used directly, but in conjunction with the hasPermission methods in UserUtilities to determine if a user has a particular permission.

Specified by:
getUsersMapOfProjectIdsAndSetOfPermissionTypes in interface UserService
reqSource - the source of the request
Returns:
a Map of permission types by project ID
See Also:
UserUtilities.hasPermission(java.util.Map>, int)

getUsersWithProjectPermission

public List<User> getUsersWithProjectPermission(Integer projectId,
                                                int permissionType)
Description copied from interface: UserService
This method will return a list of users with a specific permission, either explicitly, or by their role as a super user. This list is obtained calling a method in the pluggable authenticator, so the actual source of the data may not be the local datastore.

Specified by:
getUsersWithProjectPermission in interface UserService
Parameters:
projectId - the project to find the permission for
permissionType - the permission to check for
Returns:
an array of Users that represent the users that have the permission

getUsersWithProjectPermission

public List<User> getUsersWithProjectPermission(Integer projectId,
                                                int permissionType,
                                                boolean activeOnly)
Description copied from interface: UserService
This method will return a list of users with a specific permission, either explicitly, or by their role as a super user. This list is obtained calling a method in the pluggable authenticator, so the actual source of the data may not be the local datastore.

Specified by:
getUsersWithProjectPermission in interface UserService
Parameters:
projectId - the project to find the permission for
permissionType - the permission to check for
activeOnly - only include users who are currently active
Returns:
an array of UserModels that represent the users that have the permission

getUsersWithAnyProjectPermission

public List<User> getUsersWithAnyProjectPermission(Integer projectId,
                                                   int[] permissionTypes)
Description copied from interface: UserService
This method will return a list of users with any of the supplied permission, either explicitly, or by their role as a super user. This list is obtained calling a method in the pluggable authenticator, so the actual source of the data may not be the local datastore.

Specified by:
getUsersWithAnyProjectPermission in interface UserService
Parameters:
projectId - the project to find the permission for
permissionTypes - the permissions that are checked against
Returns:
an array of UserModels that represent the users that have the permission

getUsersWithAnyProjectPermission

public Collection<User> getUsersWithAnyProjectPermission(Integer projectId,
                                                         Integer[] permissionTypes)
Description copied from interface: UserService
This method will return a list of users with any of the supplied permission, either explicitly, or by their role as a super user. This list is obtained calling a method in the pluggable authenticator, so the actual source of the data may not be the local datastore.

Specified by:
getUsersWithAnyProjectPermission in interface UserService
Parameters:
projectId - the project to find the permission for
Returns:
an array of UserModels that represent the users that have the permission

getUsersWithAnyProjectPermission

public List<User> getUsersWithAnyProjectPermission(Integer projectId,
                                                   int[] permissionTypes,
                                                   boolean activeOnly)
Description copied from interface: UserService
This method will return a list of users with any of the supplied permission, either explicitly, or by their role as a super user. This list is obtained calling a method in the pluggable authenticator, so the actual source of the data may not be the local datastore.

Specified by:
getUsersWithAnyProjectPermission in interface UserService
Parameters:
projectId - the project to find the permission for
permissionTypes - the permissions that are checked against
activeOnly - only include users who are currently active
Returns:
an array of UserModels that represent the users that have the permission

getUsersWithProjectPermission

public List<User> getUsersWithProjectPermission(Integer projectId,
                                                int[] permissionTypes,
                                                boolean requireAll,
                                                boolean activeOnly)
Description copied from interface: UserService
This method will return a list of users with the supplied permission, either explicitly, or by their role as a super user. This list is obtained calling a method in the pluggable authenticator, so the actual source of the data may not be the local datastore.

Specified by:
getUsersWithProjectPermission in interface UserService
Parameters:
projectId - the project to find the permission for
permissionTypes - the permissions that are checked against
requireAll - true if all the permissions in the array are required, false if only one is required
activeOnly - only include users who are currently active
Returns:
an array of UserModels that represent the users that have the permission

getPossibleOwners

public List<User> getPossibleOwners(Issue issue,
                                    Integer projectId,
                                    Integer userId)
Specified by:
getPossibleOwners in interface UserService

checkLogin

public User checkLogin(String login,
                       Object authentication,
                       int authType,
                       int reqSource)
                throws AuthenticatorException
Description copied from interface: UserService
This method checks the login of a user, and returns the user if authentication was successful.

Specified by:
checkLogin in interface UserService
Parameters:
login - the login the user/client provided
authentication - the user's authentication information, if known
authType - the type of authentication information being provided
reqSource - the source from which the request was made (eg web, api)
Returns:
a User if the login is successful
Throws:
AuthenticatorException - an exception if the login is unsuccessful, or an error occurs

allowRegistration

public boolean allowRegistration(User user,
                                 Object authentication,
                                 int authType,
                                 int reqSource)
                          throws AuthenticatorException
Description copied from interface: UserService
This method checks to see if the given user is allowed to self register.

Specified by:
allowRegistration in interface UserService
Parameters:
user - a User object that contains the data the user submitted
authentication - the user's authentication information, if known
authType - the type of authentication information being provided
reqSource - the source from which the request was made (eg web, api)
Returns:
true if the user is allowed to register
Throws:
AuthenticatorException - an exception if an error occurs

allowProfileCreation

public boolean allowProfileCreation(User user,
                                    Object authentication,
                                    int authType,
                                    int reqSource)
                             throws AuthenticatorException
Description copied from interface: UserService
This method checks to see if a new user profile can be created within ITracker

Specified by:
allowProfileCreation in interface UserService
Parameters:
user - a User object that contains the data for the new user. If null, then the request is being made for an unknown future user. For example, the system may request this with an null user if it needs to know if the system should even present the option to create a new user
authentication - the user's authentication information, if known
authType - the type of authentication information being provided
reqSource - the source from which the request was made (eg web, api)
Returns:
a boolean indicating whether new user profile can be created through ITracker
Throws:
AuthenticatorException - an exception if an error occurs

allowProfileUpdates

public boolean allowProfileUpdates(User user,
                                   Object authentication,
                                   int authType,
                                   int reqSource)
                            throws AuthenticatorException
Description copied from interface: UserService
This method checks to see if the given user's core user profile information can be updated locally.

Specified by:
allowProfileUpdates in interface UserService
Parameters:
user - a User object that contains the data the user submitted
authentication - the user's authentication information, if known
authType - the type of authentication information being provided
reqSource - the source from which the request was made (eg web, api)
Returns:
a boolean whether the user's core profile information can be updated
Throws:
AuthenticatorException - an exception if an error occurs

allowPasswordUpdates

public boolean allowPasswordUpdates(User user,
                                    Object authentication,
                                    int authType,
                                    int reqSource)
                             throws AuthenticatorException
Description copied from interface: UserService
This method checks to see if the given user's password can be updated locally.

Specified by:
allowPasswordUpdates in interface UserService
Parameters:
user - a User object that contains the data the user submitted
authentication - the user's authentication information, if known
authType - the type of authentication information being provided
reqSource - the source from which the request was made (eg web, api)
Returns:
a boolean whether the user's core profile information can be updated
Throws:
AuthenticatorException - an exception if an error occurs

allowPermissionUpdates

public boolean allowPermissionUpdates(User user,
                                      Object authentication,
                                      int authType,
                                      int reqSource)
                               throws AuthenticatorException
Description copied from interface: UserService
This method checks to see if the given user's permission information can be updated locally.

Specified by:
allowPermissionUpdates in interface UserService
Parameters:
user - a User object that contains the data the user submitted
authentication - the user's authentication information, if known
authType - the type of authentication information being provided
reqSource - the source from which the request was made (eg web, api)
Returns:
a boolean whether the user's core profile information can be updated
Throws:
AuthenticatorException - an exception if an error occurs

allowPreferenceUpdates

public boolean allowPreferenceUpdates(User user,
                                      Object authentication,
                                      int authType,
                                      int reqSource)
                               throws AuthenticatorException
Description copied from interface: UserService
This method checks to see if the given user's preference information can be updated locally.

Specified by:
allowPreferenceUpdates in interface UserService
Parameters:
user - a User object that contains the data the user submitted
authentication - the user's authentication information, if known
authType - the type of authentication information being provided
reqSource - the source from which the request was made (eg web, api)
Returns:
a boolean whether the user's core profile information can be updated
Throws:
AuthenticatorException - an exception if an error occurs


Copyright © 2002-2012 itracker. All Rights Reserved.