eu.etaxonomy.cdm.api.service
Class UserService

java.lang.Object
  extended by eu.etaxonomy.cdm.api.service.ServiceBase<User,IUserDao>
      extended by eu.etaxonomy.cdm.api.service.UserService
All Implemented Interfaces:
IService<User>, IUserService, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.security.core.userdetails.UserDetailsService, org.springframework.security.provisioning.GroupManager, org.springframework.security.provisioning.UserDetailsManager

@Service
@Transactional(readOnly=true)
public class UserService
extends ServiceBase<User,IUserDao>
implements IUserService

Note: All group related functionality has been refactored into a GroupService. The will be removed in a future version.


Field Summary
protected  IGrantedAuthorityDao grantedAuthorityDao
           
protected  IGroupDao groupDao
           
 
Fields inherited from class eu.etaxonomy.cdm.api.service.ServiceBase
appContext, dao
 
Constructor Summary
UserService()
           
 
Method Summary
 void addGroupAuthority(String groupName, org.springframework.security.core.GrantedAuthority authority)
          Deprecated. 
 void addUserToGroup(String username, String groupName)
          Deprecated. 
 void changePassword(String oldPassword, String newPassword)
           
 void changePasswordForUser(String username, String newPassword)
           
 void createGroup(String groupName, List<org.springframework.security.core.GrantedAuthority> authorities)
          Deprecated. 
protected  org.springframework.security.core.Authentication createNewAuthentication(org.springframework.security.core.Authentication currentAuth, String newPassword)
           
 void createUser(org.springframework.security.core.userdetails.UserDetails user)
           
 UUID delete(User persistentObject)
          Delete an existing persistent object
 void deleteGroup(String groupName)
          Deprecated. 
 void deleteUser(String username)
           
 List<String> findAllGroups()
          Deprecated. 
 List<org.springframework.security.core.GrantedAuthority> findGroupAuthorities(String groupName)
          Deprecated. 
 List<String> findUsersInGroup(String groupName)
          Deprecated. 
 List<User> listByUsername(String queryString, MatchMode matchmode, List<org.hibernate.criterion.Criterion> criteria, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths)
          Return a List of users matching the given query string, optionally filtered by class, optionally with a particular MatchMode
 org.springframework.security.core.userdetails.UserDetails loadUserByUsername(String username)
          DO NOT CALL THIS METHOD IN LONG RUNNING SESSIONS OR CONVERSATIONS A THROWN UsernameNotFoundException WILL RENDER THE CONVERSATION UNUSABLE
 void removeGroupAuthority(String groupName, org.springframework.security.core.GrantedAuthority authority)
          Deprecated. 
 void removeUserFromGroup(String username, String groupName)
          Deprecated. 
 void renameGroup(String oldName, String newName)
          Deprecated. 
 Map<UUID,User> save(Collection<User> newInstances)
          Save a collection containing new entities (persists the entities)
 UUID save(User user)
          Save a new entity (persists the entity)
 UUID saveGrantedAuthority(org.springframework.security.core.GrantedAuthority grantedAuthority)
           
 UUID saveGroup(Group group)
          Deprecated. 
 Map<UUID,User> saveOrUpdate(Collection<User> transientInstances)
          Save new entities or update the persistent state of existing transient entities that have been persisted previously
 UUID saveOrUpdate(User transientObject)
          Save a new entity or update the persistent state of an existing transient entity that has been persisted previously
 void setAuthenticationManager(org.springframework.security.authentication.AuthenticationManager authenticationManager)
           
protected  void setDao(IUserDao dao)
           
 void setGrantedAuthorityDao(IGrantedAuthorityDao grantedAuthorityDao)
           
 void setGroupDao(IGroupDao groupDao)
           
 void setPasswordEncoder(org.springframework.security.authentication.encoding.PasswordEncoder passwordEncoder)
           
 void setSaltSource(org.springframework.security.authentication.dao.SaltSource saltSource)
           
 void setUserCache(org.springframework.security.core.userdetails.UserCache userCache)
           
 UUID update(User user)
          Update the persistent state of an existing transient entity that has been persisted previously
 void updateUser(org.springframework.security.core.userdetails.UserDetails user)
           
 boolean userExists(String username)
           
 
Methods inherited from class eu.etaxonomy.cdm.api.service.ServiceBase
clear, count, exists, find, find, find, findById, getSession, group, list, list, load, load, lock, merge, page, refresh, refresh, rows, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface eu.etaxonomy.cdm.api.service.IService
clear, count, exists, find, find, find, findById, getSession, group, list, list, load, load, lock, merge, page, refresh, refresh, rows
 

Field Detail

groupDao

protected IGroupDao groupDao

grantedAuthorityDao

protected IGrantedAuthorityDao grantedAuthorityDao
Constructor Detail

UserService

public UserService()
Method Detail

setUserCache

@Autowired(required=false)
public void setUserCache(org.springframework.security.core.userdetails.UserCache userCache)

setPasswordEncoder

@Autowired(required=false)
public void setPasswordEncoder(org.springframework.security.authentication.encoding.PasswordEncoder passwordEncoder)

setSaltSource

@Autowired(required=false)
public void setSaltSource(org.springframework.security.authentication.dao.SaltSource saltSource)

setAuthenticationManager

@Autowired(required=false)
public void setAuthenticationManager(org.springframework.security.authentication.AuthenticationManager authenticationManager)

setDao

@Autowired
protected void setDao(IUserDao dao)
Specified by:
setDao in class ServiceBase<User,IUserDao>

setGroupDao

@Autowired
public void setGroupDao(IGroupDao groupDao)

setGrantedAuthorityDao

@Autowired
public void setGrantedAuthorityDao(IGrantedAuthorityDao grantedAuthorityDao)

createNewAuthentication

@Transactional(readOnly=false)
protected org.springframework.security.core.Authentication createNewAuthentication(org.springframework.security.core.Authentication currentAuth,
                                                                                                 String newPassword)

changePassword

@Transactional(readOnly=false)
@PreAuthorize(value="isAuthenticated()")
public void changePassword(String oldPassword,
                                                      String newPassword)
Specified by:
changePassword in interface org.springframework.security.provisioning.UserDetailsManager

changePasswordForUser

@Transactional(readOnly=false)
@PreAuthorize(value="#username == authentication.name or hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public void changePasswordForUser(String username,
                                                             String newPassword)
Specified by:
changePasswordForUser in interface IUserService

createUser

@Transactional(readOnly=false)
@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public void createUser(org.springframework.security.core.userdetails.UserDetails user)
Specified by:
createUser in interface org.springframework.security.provisioning.UserDetailsManager

deleteUser

@Transactional(readOnly=false)
@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public void deleteUser(String username)
Specified by:
deleteUser in interface org.springframework.security.provisioning.UserDetailsManager

updateUser

@Transactional(readOnly=false)
@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public void updateUser(org.springframework.security.core.userdetails.UserDetails user)
Specified by:
updateUser in interface org.springframework.security.provisioning.UserDetailsManager

userExists

public boolean userExists(String username)
Specified by:
userExists in interface org.springframework.security.provisioning.UserDetailsManager

loadUserByUsername

public org.springframework.security.core.userdetails.UserDetails loadUserByUsername(String username)
                                                                             throws org.springframework.security.core.userdetails.UsernameNotFoundException,
                                                                                    org.springframework.dao.DataAccessException
DO NOT CALL THIS METHOD IN LONG RUNNING SESSIONS OR CONVERSATIONS A THROWN UsernameNotFoundException WILL RENDER THE CONVERSATION UNUSABLE

Specified by:
loadUserByUsername in interface org.springframework.security.core.userdetails.UserDetailsService
Throws:
org.springframework.security.core.userdetails.UsernameNotFoundException
org.springframework.dao.DataAccessException
See Also:
UserDetailsService.loadUserByUsername(java.lang.String)

addGroupAuthority

@Deprecated
@Transactional(readOnly=false)
@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public void addGroupAuthority(String groupName,
                                                                    org.springframework.security.core.GrantedAuthority authority)
Deprecated. 

Specified by:
addGroupAuthority in interface org.springframework.security.provisioning.GroupManager

addUserToGroup

@Deprecated
@Transactional(readOnly=false)
@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public void addUserToGroup(String username,
                                                                 String groupName)
Deprecated. 

Specified by:
addUserToGroup in interface org.springframework.security.provisioning.GroupManager

createGroup

@Deprecated
@Transactional(readOnly=false)
@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public void createGroup(String groupName,
                                                              List<org.springframework.security.core.GrantedAuthority> authorities)
Deprecated. 

Specified by:
createGroup in interface org.springframework.security.provisioning.GroupManager

deleteGroup

@Deprecated
@Transactional(readOnly=false)
@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public void deleteGroup(String groupName)
Deprecated. 

Specified by:
deleteGroup in interface org.springframework.security.provisioning.GroupManager

findAllGroups

@Deprecated
@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public List<String> findAllGroups()
Deprecated. 

Specified by:
findAllGroups in interface org.springframework.security.provisioning.GroupManager

findGroupAuthorities

@Deprecated
@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public List<org.springframework.security.core.GrantedAuthority> findGroupAuthorities(String groupName)
Deprecated. 

Specified by:
findGroupAuthorities in interface org.springframework.security.provisioning.GroupManager

findUsersInGroup

@Deprecated
@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public List<String> findUsersInGroup(String groupName)
Deprecated. 

Specified by:
findUsersInGroup in interface org.springframework.security.provisioning.GroupManager

removeGroupAuthority

@Deprecated
@Transactional(readOnly=false)
@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public void removeGroupAuthority(String groupName,
                                                                       org.springframework.security.core.GrantedAuthority authority)
Deprecated. 

Specified by:
removeGroupAuthority in interface org.springframework.security.provisioning.GroupManager

removeUserFromGroup

@Deprecated
@Transactional(readOnly=false)
@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public void removeUserFromGroup(String username,
                                                                      String groupName)
Deprecated. 

Specified by:
removeUserFromGroup in interface org.springframework.security.provisioning.GroupManager

renameGroup

@Deprecated
@Transactional(readOnly=false)
@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public void renameGroup(String oldName,
                                                              String newName)
Deprecated. 

Specified by:
renameGroup in interface org.springframework.security.provisioning.GroupManager

save

@Transactional(readOnly=false)
@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_RUN_AS_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public UUID save(User user)
Description copied from interface: IService
Save a new entity (persists the entity)

Specified by:
save in interface IService<User>
Overrides:
save in class ServiceBase<User,IUserDao>
Parameters:
user - the new entity to be persisted
Returns:
A generated UUID for the new persistent entity

update

@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public UUID update(User user)
Description copied from interface: IService
Update the persistent state of an existing transient entity that has been persisted previously

Specified by:
update in interface IService<User>
Overrides:
update in class ServiceBase<User,IUserDao>
Parameters:
user - the entity to be persisted
Returns:
The unique identifier of the persisted entity

saveGrantedAuthority

@Transactional(readOnly=false)
@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public UUID saveGrantedAuthority(org.springframework.security.core.GrantedAuthority grantedAuthority)
Specified by:
saveGrantedAuthority in interface IUserService

saveGroup

@Deprecated
@Transactional(readOnly=false)
@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public UUID saveGroup(Group group)
Deprecated. 

Specified by:
saveGroup in interface IUserService

listByUsername

@Transactional(readOnly=true)
public List<User> listByUsername(String queryString,
                                               MatchMode matchmode,
                                               List<org.hibernate.criterion.Criterion> criteria,
                                               Integer pageSize,
                                               Integer pageNumber,
                                               List<OrderHint> orderHints,
                                               List<String> propertyPaths)
Description copied from interface: IUserService
Return a List of users matching the given query string, optionally filtered by class, optionally with a particular MatchMode

Specified by:
listByUsername in interface IUserService
Parameters:
queryString - the query string to filter by
matchmode - use a particular type of matching (can be null - defaults to exact matching)
criteria - additional criteria to filter by
pageSize - The maximum number of objects returned (can be null for all objects)
pageNumber - The offset (in pageSize chunks) from the start of the result set (0 - based)
orderHints - Supports path like orderHints.propertyNames which include *-to-one properties like createdBy.username or authorTeam.persistentTitleCache
propertyPaths - properties to initialize - see IBeanInitializer.initialize(Object, List)
Returns:
a list of instances of type User matching the queryString
See Also:
IIdentifiableEntityService#listByTitle(Class, String, MatchMode, List, Integer, Integer, List, List)}

delete

@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public UUID delete(User persistentObject)
Description copied from interface: IService
Delete an existing persistent object

Specified by:
delete in interface IService<User>
Overrides:
delete in class ServiceBase<User,IUserDao>
Parameters:
persistentObject - the object to be deleted
Returns:
the unique identifier of the deleted entity

save

@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public Map<UUID,User> save(Collection<User> newInstances)
Description copied from interface: IService
Save a collection containing new entities (persists the entities)

Specified by:
save in interface IService<User>
Overrides:
save in class ServiceBase<User,IUserDao>
Parameters:
newInstances - the new entities to be persisted
Returns:
A Map containing the new entities, keyed using the generated UUID's of those entities

saveOrUpdate

@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public UUID saveOrUpdate(User transientObject)
Description copied from interface: IService
Save a new entity or update the persistent state of an existing transient entity that has been persisted previously

Specified by:
saveOrUpdate in interface IService<User>
Overrides:
saveOrUpdate in class ServiceBase<User,IUserDao>
Parameters:
transientObject - the entity to be persisted
Returns:
The unique identifier of the persisted entity

saveOrUpdate

@PreAuthorize(value="hasRole(\'ROLE_ADMIN\') or hasRole(\'ROLE_USER_MANAGER\')")
public Map<UUID,User> saveOrUpdate(Collection<User> transientInstances)
Description copied from interface: IService
Save new entities or update the persistent state of existing transient entities that have been persisted previously

Specified by:
saveOrUpdate in interface IService<User>
Overrides:
saveOrUpdate in class ServiceBase<User,IUserDao>
Parameters:
transientInstances - the entities to be persisted
Returns:
The unique identifier of the persisted entity


Copyright © 2007-2013 EDIT. All Rights Reserved.