Class DefaultUserService
- java.lang.Object
-
- de.hybris.platform.servicelayer.internal.service.AbstractService
-
- de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
-
- de.hybris.platform.servicelayer.user.impl.DefaultUserService
-
- All Implemented Interfaces:
UserService
,java.io.Serializable
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanNameAware
,org.springframework.beans.factory.InitializingBean
- Direct Known Subclasses:
SecureUserService
public class DefaultUserService extends AbstractBusinessService implements UserService
Default implementation of the user service interface.- Since:
- 4.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
AbstractService.SerializableDTO
-
-
Field Summary
-
Fields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
modelService, sessionService, txManager
-
Fields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
tenant
-
-
Constructor Summary
Constructors Constructor Description DefaultUserService()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
assurePasswordCompliance(UserModel user, java.lang.String plainPassword, java.lang.String encoding)
EmployeeModel
getAdminUser()
Returns always the admin user.UserGroupModel
getAdminUserGroup()
Returns always the admin user group.java.util.Collection<TitleModel>
getAllTitles()
Returns allTitleModel
s in the system.java.util.Set<UserGroupModel>
getAllUserGroupsForUser(UserModel user)
Gets all user groups for the given user.<T extends UserGroupModel>
java.util.Set<T>getAllUserGroupsForUser(UserModel user, java.lang.Class<T> clazz)
Gets all user groups for the given user and specified (result) class.<T extends UserGroupModel>
java.util.Set<T>getAllUserGroupsForUserGroup(UserGroupModel userGroup, java.lang.Class<T> clazz)
Gets all user groups for the given user group and specified (result) class.CustomerModel
getAnonymousUser()
Returns always the anonymous user.UserModel
getCurrentUser()
Returns the current user from theSession
.java.lang.String
getDefaultPasswordEncoding()
java.lang.String
getPassword(UserModel user)
Returns for the given user the decoded password if this is possible.java.lang.String
getPassword(java.lang.String userId)
If possible returns the decoded password from the given user.protected java.lang.String
getRealEncoding(java.lang.String optionalEncoding)
TitleModel
getTitleForCode(java.lang.String code)
Returns theTitleModel
for the specifiedcode
.UserModel
getUser(java.lang.String uid)
Deprecated.since 6.1.0java.util.List<AbstractUserAuditModel>
getUserAudits(UserModel user)
Gets audit information about user previous password hashes.UserModel
getUserForUID(java.lang.String userId)
Returns theUserModel
for the specifieduserId
<T extends UserModel>
TgetUserForUID(java.lang.String userId, java.lang.Class<T> clazz)
Returns for the specifieduserId
and the specified (result) class the found user in the specified class.UserGroupModel
getUserGroup(java.lang.String groupId)
Deprecated.since 6.1.0UserGroupModel
getUserGroupForUID(java.lang.String uid)
Returns theUserGroupModel
for the specifieduid
.<T extends UserGroupModel>
TgetUserGroupForUID(java.lang.String uid, java.lang.Class<T> clazz)
Returns theUserGroupModel
for the specifieduid
and the specified (result) class.boolean
isAdmin(UserModel user)
Checks if the given user has the admin role.boolean
isAdminEmployee(UserModel user)
Checks if the given user has the is the admin employee.boolean
isAdminGroup(UserGroupModel userGroup)
Checks if the given user group or it's super groups have the admin role.boolean
isAnonymousUser(UserModel user)
Checks if the given user is the anonymous customer.boolean
isMemberOfGroup(UserGroupModel member, UserGroupModel groupToCheckFor)
Checks if the givenuser group is a member
of the specifiedgroupToCheckFor
or its super groups.boolean
isMemberOfGroup(UserGroupModel member, UserGroupModel groupToCheckFor, boolean includeSuperGroups)
Checks if the givenuser group is a member
of the specifiedgroupToCheckFor
or its super groups ifincludeSubGroups
is set totrue
.boolean
isMemberOfGroup(UserModel member, UserGroupModel groupToCheckFor)
Checks if the givenuser is a member
of the specifiedgroupToCheckFor
or its super groups.boolean
isMemberOfGroup(UserModel member, UserGroupModel groupToCheckFor, boolean includeSuperGroups)
Checks if the givenuser is a member
of the specifiedgroupToCheckFor
or its super groups ifincludeSubGroups
is set totrue
.boolean
isPasswordIdenticalToAudited(UserModel user, java.lang.String plainPassword, UserPasswordChangeAuditModel audit)
Checks if password is the same as the previous password.boolean
isUserExisting(java.lang.String uid)
Checks if for the specifieduid
a user exists in the system.void
setCurrentUser(UserModel user)
Sets the given user as current user on theSession
.void
setDefaultPasswordEncoding(java.lang.String defaultPasswordEncoding)
void
setEncodedPassword(UserModel user, java.lang.String encodedPassword)
Sets the encoded password to the given user.void
setEncodedPassword(UserModel user, java.lang.String encodedPassword, java.lang.String encoding)
Sets the encoded password to the given user.void
setEventService(EventService eventService)
void
setPassword(UserModel user, java.lang.String plainPassword)
Encodes the given plain text password with the user's password encoding (using the default encoding if the user doesn't have one) and set the encoded password to the given user.void
setPassword(UserModel user, java.lang.String plainPassword, java.lang.String encoding)
Encodes the given plain text password with the given password encoding and set the encoded password to the given user.void
setPassword(java.lang.String userId, java.lang.String password)
Encodes the given plain text password with the default password encoding and set the encoded password to the given user.void
setPassword(java.lang.String userId, java.lang.String password, java.lang.String encoding)
Sets the password according to the givenencoding
for the given user id.void
setPasswordEncoderService(PasswordEncoderService passwordEncoderService)
void
setPasswordPolicyService(PasswordPolicyService passwordPolicyService)
void
setPasswordWithDefaultEncoding(UserModel user, java.lang.String plainPassword)
Encodes the given plain text password with the default password encoding and set the encoded password to the given user.void
setSearchRestrictionService(SearchRestrictionService searchRestrictionService)
void
setTitleDao(TitleDao titleDao)
void
setUserAuditDao(UserAuditDao userAuditDao)
void
setUserDao(UserDao userDao)
void
setUserGroupDao(UserGroupDao userGroupDao)
-
Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
getModelService, getSessionService, getTxManager, setModelService, setSessionService, setTxManager
-
Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
afterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, writeReplace
-
-
-
-
Method Detail
-
getUser
@Deprecated public UserModel getUser(java.lang.String uid)
Deprecated.since 6.1.0Description copied from interface:UserService
Returns theUserModel
by the specifieduserId
- Specified by:
getUser
in interfaceUserService
- Parameters:
uid
- the specified userId- Returns:
- the
UserModel
-
getUserForUID
public UserModel getUserForUID(java.lang.String userId)
Description copied from interface:UserService
Returns theUserModel
for the specifieduserId
- Specified by:
getUserForUID
in interfaceUserService
- Parameters:
userId
- the unique userId of the user- Returns:
- the
UserModel
or a subtype of it.
-
getUserForUID
public <T extends UserModel> T getUserForUID(java.lang.String userId, java.lang.Class<T> clazz)
Description copied from interface:UserService
Returns for the specifieduserId
and the specified (result) class the found user in the specified class. Throws exception otherwise.- Specified by:
getUserForUID
in interfaceUserService
- Parameters:
userId
- The unique userId of the user to be searched for.clazz
- The user must match the given class (employee, customer, ...). Can be aUserModel
or any subtype of it.
-
isUserExisting
public boolean isUserExisting(java.lang.String uid)
Description copied from interface:UserService
Checks if for the specifieduid
a user exists in the system.- Specified by:
isUserExisting
in interfaceUserService
- Parameters:
uid
- of the user- Returns:
true
if a user exists, otherwisefalse
-
getUserGroup
@Deprecated public UserGroupModel getUserGroup(java.lang.String groupId)
Deprecated.since 6.1.0Description copied from interface:UserService
Returns theUserGroupModel
by the specified userGroupId- Specified by:
getUserGroup
in interfaceUserService
- Parameters:
groupId
- the specified userGroupId- Returns:
- the
UserGroupModel
-
getCurrentUser
public UserModel getCurrentUser()
Description copied from interface:UserService
Returns the current user from theSession
.- Specified by:
getCurrentUser
in interfaceUserService
- Returns:
- the current
UserModel
-
setCurrentUser
public void setCurrentUser(UserModel user)
Description copied from interface:UserService
Sets the given user as current user on theSession
.After changing the user current user a
AfterSessionUserChangeEvent
is fired.Please note: With hybris 4.3 this method doesn't trigger a call of
JaloSessionListener.afterSessionUserChange(de.hybris.platform.jalo.JaloSession, de.hybris.platform.jalo.user.User)
in the jalo-layer!- Specified by:
setCurrentUser
in interfaceUserService
- Parameters:
user
- the user to set as current
-
getPassword
public java.lang.String getPassword(UserModel user) throws CannotDecodePasswordException, PasswordEncoderNotFoundException
Description copied from interface:UserService
Returns for the given user the decoded password if this is possible.- Specified by:
getPassword
in interfaceUserService
- Parameters:
user
- the user where the password should be decoded- Returns:
- the decoded password if possible
- Throws:
CannotDecodePasswordException
- if the encoded passwordUserModel.getEncodedPassword()
cannot be decoded.PasswordEncoderNotFoundException
- is thrown if given encoding does not match any password encoder in the system
-
setPassword
public void setPassword(UserModel user, java.lang.String plainPassword, java.lang.String encoding)
Description copied from interface:UserService
Encodes the given plain text password with the given password encoding and set the encoded password to the given user.- Specified by:
setPassword
in interfaceUserService
- Parameters:
user
- the encoded password is set toUserModel.setEncodedPassword(String)
plainPassword
- the plain text password for the userencoding
- the password encidung, must exist
-
assurePasswordCompliance
protected void assurePasswordCompliance(UserModel user, java.lang.String plainPassword, java.lang.String encoding)
-
getRealEncoding
protected java.lang.String getRealEncoding(java.lang.String optionalEncoding)
-
setPasswordWithDefaultEncoding
public void setPasswordWithDefaultEncoding(UserModel user, java.lang.String plainPassword) throws PasswordEncoderNotFoundException
Description copied from interface:UserService
Encodes the given plain text password with the default password encoding and set the encoded password to the given user.- Specified by:
setPasswordWithDefaultEncoding
in interfaceUserService
- Parameters:
user
- the encoded password is set toUserModel.setEncodedPassword(String)
plainPassword
- the plain text password for the user- Throws:
PasswordEncoderNotFoundException
-
getPassword
public java.lang.String getPassword(java.lang.String userId) throws CannotDecodePasswordException, PasswordEncoderNotFoundException
Description copied from interface:UserService
If possible returns the decoded password from the given user. Throws exception if decoding is not possible.- Specified by:
getPassword
in interfaceUserService
- Parameters:
userId
- the user ID from the user- Returns:
- password text in plain text
- Throws:
CannotDecodePasswordException
- if decode of the password is not possible (example: MD5)PasswordEncoderNotFoundException
- if for the given password encoding (seeUserModel.getPasswordEncoding()
no password encoder was found
-
setPassword
public void setPassword(java.lang.String userId, java.lang.String password) throws PasswordEncoderNotFoundException
Description copied from interface:UserService
Encodes the given plain text password with the default password encoding and set the encoded password to the given user.- Specified by:
setPassword
in interfaceUserService
- Parameters:
userId
- the user ID of the userpassword
- the plain text password- Throws:
PasswordEncoderNotFoundException
- if for the given password encoding (seeUserModel.getPasswordEncoding()
no password encoder was found
-
setPassword
public void setPassword(java.lang.String userId, java.lang.String password, java.lang.String encoding) throws PasswordEncoderNotFoundException
Description copied from interface:UserService
Sets the password according to the givenencoding
for the given user id.- Specified by:
setPassword
in interfaceUserService
- Parameters:
userId
- the user IDpassword
- the plain passwordencoding
- the encoding to encode the given password- Throws:
PasswordEncoderNotFoundException
- is thrown if given encoding does not match any password encoder in the system
-
getUserGroupForUID
public UserGroupModel getUserGroupForUID(java.lang.String uid)
Description copied from interface:UserService
Returns theUserGroupModel
for the specifieduid
.- Specified by:
getUserGroupForUID
in interfaceUserService
- Parameters:
uid
- the uniqueuid
of the group- Returns:
- the found
UserGroupModel
(or a subtype of it).
-
getUserGroupForUID
public <T extends UserGroupModel> T getUserGroupForUID(java.lang.String uid, java.lang.Class<T> clazz)
Description copied from interface:UserService
Returns theUserGroupModel
for the specifieduid
and the specified (result) class.The found user group must be an instance of the given class, otherwise an exception is thrown.
- Specified by:
getUserGroupForUID
in interfaceUserService
- Parameters:
uid
- The uniqueuid
of the user group to be searched for.clazz
- The user group must match the given class. Can be aUserGroupModel
or any subtype of it.- Returns:
- the found
UserGroupModel
-
getAllUserGroupsForUser
public java.util.Set<UserGroupModel> getAllUserGroupsForUser(UserModel user)
Description copied from interface:UserService
Gets all user groups for the given user.The
Set
of user groups is collected recursively.- Specified by:
getAllUserGroupsForUser
in interfaceUserService
- Parameters:
user
- the given user- Returns:
Set
ofuser groups
-
getAllUserGroupsForUser
public <T extends UserGroupModel> java.util.Set<T> getAllUserGroupsForUser(UserModel user, java.lang.Class<T> clazz)
Description copied from interface:UserService
Gets all user groups for the given user and specified (result) class. If the user is in a user group which is not assignable from the givenclazz
then this group is not in the result set. UseUserService.getUserGroupForUID(String)
if all groups are needed.The
Set
of user groups is collected recursively.- Specified by:
getAllUserGroupsForUser
in interfaceUserService
- Parameters:
user
- the given userclazz
- the user group must match the given class. Can be aUserGroupModel
or any subtype of it.- Returns:
Set
of user groups which must be instances of the specified result class
-
getAllUserGroupsForUserGroup
public <T extends UserGroupModel> java.util.Set<T> getAllUserGroupsForUserGroup(UserGroupModel userGroup, java.lang.Class<T> clazz)
Description copied from interface:UserService
Gets all user groups for the given user group and specified (result) class. If the user is in a user group which is not assignable from the givenclazz
then this group is not in the result set. UseUserService.getUserGroupForUID(String)
if all groups are needed.The
Set
of user groups is collected recursively.- Specified by:
getAllUserGroupsForUserGroup
in interfaceUserService
- Parameters:
userGroup
- the given user groupclazz
- the user group must match the given class. Can be aUserGroupModel
or any subtype of it.- Returns:
Set
of user groups which must be instances of the specified result class
-
getUserAudits
public java.util.List<AbstractUserAuditModel> getUserAudits(UserModel user)
Description copied from interface:UserService
Gets audit information about user previous password hashes. Can be used to implement password policy that does not allow to reuse previous passwords.- Specified by:
getUserAudits
in interfaceUserService
- Returns:
-
isPasswordIdenticalToAudited
public boolean isPasswordIdenticalToAudited(UserModel user, java.lang.String plainPassword, UserPasswordChangeAuditModel audit)
Description copied from interface:UserService
Checks if password is the same as the previous password. Password stored in audit information is hashed so this method hashes plain password and compares them.- Specified by:
isPasswordIdenticalToAudited
in interfaceUserService
- Returns:
true
if password is the same as audit, otherwisefalse
-
isMemberOfGroup
public boolean isMemberOfGroup(UserModel member, UserGroupModel groupToCheckFor)
Description copied from interface:UserService
Checks if the givenuser is a member
of the specifiedgroupToCheckFor
or its super groups.The super groups are collected recursively.
- Specified by:
isMemberOfGroup
in interfaceUserService
- Parameters:
member
- the user to checkgroupToCheckFor
- the group(s) to be checked for- Returns:
true
if the user is a member of this group, otherwisefalse
-
isMemberOfGroup
public boolean isMemberOfGroup(UserModel member, UserGroupModel groupToCheckFor, boolean includeSuperGroups)
Description copied from interface:UserService
Checks if the givenuser is a member
of the specifiedgroupToCheckFor
or its super groups ifincludeSubGroups
is set totrue
.The super groups are collected recursively.
- Specified by:
isMemberOfGroup
in interfaceUserService
- Parameters:
member
- the user to checkgroupToCheckFor
- the group(s) to be checked forincludeSuperGroups
- should include super groups in search- Returns:
true
if the user is a member of this group, otherwisefalse
-
isMemberOfGroup
public boolean isMemberOfGroup(UserGroupModel member, UserGroupModel groupToCheckFor)
Description copied from interface:UserService
Checks if the givenuser group is a member
of the specifiedgroupToCheckFor
or its super groups.The super groups are collected recursively.
- Specified by:
isMemberOfGroup
in interfaceUserService
- Parameters:
member
- the user group to checkgroupToCheckFor
- the group(s) to be checked for- Returns:
true
if the user group is a member of this group, otherwisefalse
-
isMemberOfGroup
public boolean isMemberOfGroup(UserGroupModel member, UserGroupModel groupToCheckFor, boolean includeSuperGroups)
Description copied from interface:UserService
Checks if the givenuser group is a member
of the specifiedgroupToCheckFor
or its super groups ifincludeSubGroups
is set totrue
.The super groups are collected recursively.
- Specified by:
isMemberOfGroup
in interfaceUserService
- Parameters:
member
- the user group to checkgroupToCheckFor
- the group(s) to be checked forincludeSuperGroups
- should include super groups in search- Returns:
true
if the user group is a member of this group, otherwisefalse
-
getAllTitles
public java.util.Collection<TitleModel> getAllTitles()
Description copied from interface:UserService
Returns allTitleModel
s in the system.- Specified by:
getAllTitles
in interfaceUserService
- Returns:
- an empty collection if no
TitleModel
was found.
-
getTitleForCode
public TitleModel getTitleForCode(java.lang.String code)
Description copied from interface:UserService
Returns theTitleModel
for the specifiedcode
.- Specified by:
getTitleForCode
in interfaceUserService
- Parameters:
code
- the uniquecode
of the title
-
getAdminUser
public EmployeeModel getAdminUser()
Description copied from interface:UserService
Returns always the admin user. Search restrictions are disabled for this call.- Specified by:
getAdminUser
in interfaceUserService
- Returns:
- the system admin user as
EmployeeModel
-
getAdminUserGroup
public UserGroupModel getAdminUserGroup()
Description copied from interface:UserService
Returns always the admin user group. Search restrictions are disabled for this call.- Specified by:
getAdminUserGroup
in interfaceUserService
- Returns:
- the admin user group as
UserGroupModel
-
isAdmin
public boolean isAdmin(UserModel user)
Description copied from interface:UserService
Checks if the given user has the admin role.The user is an admin if either the user is the admin employee or the user is a member of the admin user group (see
UserService.getAdminUserGroup()
).- Specified by:
isAdmin
in interfaceUserService
- Parameters:
user
- user to check- Returns:
true
if the user is an admin, otherwisefalse
-
isAdminGroup
public boolean isAdminGroup(UserGroupModel userGroup)
Description copied from interface:UserService
Checks if the given user group or it's super groups have the admin role.- Specified by:
isAdminGroup
in interfaceUserService
- Parameters:
userGroup
- user to check- Returns:
true
if the user is an admin, otherwisefalse
-
isAdminEmployee
public boolean isAdminEmployee(UserModel user)
Description copied from interface:UserService
Checks if the given user has the is the admin employee.- Specified by:
isAdminEmployee
in interfaceUserService
- Parameters:
user
- user to check- Returns:
true
if the user is an admin employee, otherwisefalse
-
getAnonymousUser
public CustomerModel getAnonymousUser()
Description copied from interface:UserService
Returns always the anonymous user. Search restrictions are disabled for this call.- Specified by:
getAnonymousUser
in interfaceUserService
- Returns:
- the anonymous user as
CustomerModel
-
isAnonymousUser
public boolean isAnonymousUser(UserModel user)
Description copied from interface:UserService
Checks if the given user is the anonymous customer.- Specified by:
isAnonymousUser
in interfaceUserService
- Parameters:
user
- the user to check- Returns:
true
if the user is the anonymous customer, otherwisefalse
-
setEncodedPassword
public void setEncodedPassword(UserModel user, java.lang.String encodedPassword)
Description copied from interface:UserService
Sets the encoded password to the given user.The encoding is taken form user or if
null
the system default encoding is used.- Specified by:
setEncodedPassword
in interfaceUserService
- Parameters:
user
- the encoded password is set toUserModel.setEncodedPassword(String)
encodedPassword
- encoded password for the user
-
setEncodedPassword
public void setEncodedPassword(UserModel user, java.lang.String encodedPassword, java.lang.String encoding)
Description copied from interface:UserService
Sets the encoded password to the given user.- Specified by:
setEncodedPassword
in interfaceUserService
- Parameters:
user
- the encoded password is set toUserModel.setEncodedPassword(String)
encodedPassword
- encoded password for the userencoding
- the password encoding
-
setUserDao
public void setUserDao(UserDao userDao)
-
setUserGroupDao
public void setUserGroupDao(UserGroupDao userGroupDao)
-
setTitleDao
public void setTitleDao(TitleDao titleDao)
-
setSearchRestrictionService
public void setSearchRestrictionService(SearchRestrictionService searchRestrictionService)
-
setEventService
public void setEventService(EventService eventService)
-
setPasswordEncoderService
public void setPasswordEncoderService(PasswordEncoderService passwordEncoderService)
-
getDefaultPasswordEncoding
public java.lang.String getDefaultPasswordEncoding()
-
setDefaultPasswordEncoding
public void setDefaultPasswordEncoding(java.lang.String defaultPasswordEncoding)
-
setPassword
public void setPassword(UserModel user, java.lang.String plainPassword) throws PasswordEncoderNotFoundException
Description copied from interface:UserService
Encodes the given plain text password with the user's password encoding (using the default encoding if the user doesn't have one) and set the encoded password to the given user.- Specified by:
setPassword
in interfaceUserService
- Parameters:
user
- the encoded password is set toUserModel.setEncodedPassword(String)
plainPassword
- the plain text password for the user- Throws:
PasswordEncoderNotFoundException
- if for the given password encoding (seeUserModel.getPasswordEncoding()
no password encoder was found
-
setPasswordPolicyService
public void setPasswordPolicyService(PasswordPolicyService passwordPolicyService)
-
setUserAuditDao
public void setUserAuditDao(UserAuditDao userAuditDao)
-
-