Class DefaultUserService
- All Implemented Interfaces:
UserService,Serializable,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.InitializingBean
- Direct Known Subclasses:
BackofficeUserService,SecureUserService
- Since:
- 4.0
- See Also:
-
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, txManagerFields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
tenant -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidassurePasswordCompliance(UserModel user, String plainPassword, String encoding) Returns always the admin user.Returns always the admin user group.Returns allTitleModels in the system.Gets all user groups for the given user.<T extends UserGroupModel>
Set<T>getAllUserGroupsForUser(UserModel user, Class<T> clazz) Gets all user groups for the given user and specified (result) class.<T extends UserGroupModel>
Set<T>getAllUserGroupsForUserGroup(UserGroupModel userGroup, Class<T> clazz) Gets all user groups for the given user group and specified (result) class.Returns always the anonymous user.Returns the current user from theSession.getPassword(UserModel user) Returns for the given user the decoded password if this is possible.getPassword(String userId) If possible returns the decoded password from the given user.protected StringgetRealEncoding(String optionalEncoding) getTitleForCode(String code) Returns theTitleModelfor the specifiedcode.Deprecated, for removal: This API element is subject to removal in a future version.since 6.1.0getUserAudits(UserModel user) Gets audit information about user previous password hashes.getUserForUID(String userId) Returns theUserModelfor the specifieduserId<T extends UserModel>
TgetUserForUID(String userId, Class<T> clazz) Returns for the specifieduserIdand the specified (result) class the found user in the specified class.getUserGroup(String groupId) Deprecated, for removal: This API element is subject to removal in a future version.since 6.1.0getUserGroupForUID(String uid) Returns theUserGroupModelfor the specifieduid.<T extends UserGroupModel>
TgetUserGroupForUID(String uid, Class<T> clazz) Returns theUserGroupModelfor the specifieduidand the specified (result) class.booleanChecks if the given user has the admin role.booleanisAdminEmployee(UserModel user) Checks if the given user has the is the admin employee.booleanisAdminGroup(UserGroupModel userGroup) Checks if the given user group or it's super groups have the admin role.booleanisAnonymousUser(UserModel user) Checks if the given user is the anonymous customer.booleanisMemberOfGroup(UserGroupModel member, UserGroupModel groupToCheckFor) Checks if the givenuser group is a memberof the specifiedgroupToCheckForor its super groups.booleanisMemberOfGroup(UserGroupModel member, UserGroupModel groupToCheckFor, boolean includeSuperGroups) Checks if the givenuser group is a memberof the specifiedgroupToCheckForor its super groups ifincludeSubGroupsis set totrue.booleanisMemberOfGroup(UserModel member, UserGroupModel groupToCheckFor) Checks if the givenuser is a memberof the specifiedgroupToCheckForor its super groups.booleanisMemberOfGroup(UserModel member, UserGroupModel groupToCheckFor, boolean includeSuperGroups) Checks if the givenuser is a memberof the specifiedgroupToCheckForor its super groups ifincludeSubGroupsis set totrue.booleanisPasswordIdenticalToAudited(UserModel user, String plainPassword, UserPasswordChangeAuditModel audit) Checks if password is the same as the previous password.booleanisUserExisting(String uid) Checks if for the specifieduida user exists in the system.voidsetCurrentUser(UserModel user) Sets the given user as current user on theSession.voidsetDefaultPasswordEncoding(String defaultPasswordEncoding) voidsetEncodedPassword(UserModel user, String encodedPassword) Sets the encoded password to the given user.voidsetEncodedPassword(UserModel user, String encodedPassword, String encoding) Sets the encoded password to the given user.voidsetEventService(EventService eventService) voidsetPassword(UserModel user, 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.voidsetPassword(UserModel user, String plainPassword, String encoding) Encodes the given plain text password with the given password encoding and set the encoded password to the given user.voidsetPassword(String userId, String password) Encodes the given plain text password with the default password encoding and set the encoded password to the given user.voidsetPassword(String userId, String password, String encoding) Sets the password according to the givenencodingfor the given user id.voidsetPasswordEncoderService(PasswordEncoderService passwordEncoderService) voidsetPasswordPolicyService(PasswordPolicyService passwordPolicyService) voidsetPasswordWithDefaultEncoding(UserModel user, String plainPassword) Encodes the given plain text password with the default password encoding and set the encoded password to the given user.voidsetSearchRestrictionService(SearchRestrictionService searchRestrictionService) voidsetTitleDao(TitleDao titleDao) voidsetUserAuditDao(UserAuditDao userAuditDao) voidsetUserDao(UserDao userDao) voidsetUserGroupDao(UserGroupDao userGroupDao) Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
getModelService, getSessionService, getTxManager, setModelService, setSessionService, setTxManagerMethods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
afterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, writeReplace
-
Constructor Details
-
DefaultUserService
public DefaultUserService()
-
-
Method Details
-
getUser
Deprecated, for removal: This API element is subject to removal in a future version.since 6.1.0Description copied from interface:UserServiceReturns theUserModelby the specifieduserId- Specified by:
getUserin interfaceUserService- Parameters:
uid- the specified userId- Returns:
- the
UserModel
-
getUserForUID
Description copied from interface:UserServiceReturns theUserModelfor the specifieduserId- Specified by:
getUserForUIDin interfaceUserService- Parameters:
userId- the unique userId of the user- Returns:
- the
UserModelor a subtype of it.
-
getUserForUID
Description copied from interface:UserServiceReturns for the specifieduserIdand the specified (result) class the found user in the specified class. Throws exception otherwise.- Specified by:
getUserForUIDin 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 aUserModelor any subtype of it.
-
isUserExisting
Description copied from interface:UserServiceChecks if for the specifieduida user exists in the system.- Specified by:
isUserExistingin interfaceUserService- Parameters:
uid- of the user- Returns:
trueif a user exists, otherwisefalse
-
getUserGroup
Deprecated, for removal: This API element is subject to removal in a future version.since 6.1.0Description copied from interface:UserServiceReturns theUserGroupModelby the specified userGroupId- Specified by:
getUserGroupin interfaceUserService- Parameters:
groupId- the specified userGroupId- Returns:
- the
UserGroupModel
-
getCurrentUser
Description copied from interface:UserServiceReturns the current user from theSession.- Specified by:
getCurrentUserin interfaceUserService- Returns:
- the current
UserModel
-
setCurrentUser
Description copied from interface:UserServiceSets the given user as current user on theSession.After changing the user current user a
AfterSessionUserChangeEventis 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:
setCurrentUserin interfaceUserService- Parameters:
user- the user to set as current
-
getPassword
public String getPassword(UserModel user) throws CannotDecodePasswordException, PasswordEncoderNotFoundException Description copied from interface:UserServiceReturns for the given user the decoded password if this is possible.- Specified by:
getPasswordin 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
Description copied from interface:UserServiceEncodes the given plain text password with the given password encoding and set the encoded password to the given user.- Specified by:
setPasswordin 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
-
getRealEncoding
-
setPasswordWithDefaultEncoding
public void setPasswordWithDefaultEncoding(UserModel user, String plainPassword) throws PasswordEncoderNotFoundException Description copied from interface:UserServiceEncodes the given plain text password with the default password encoding and set the encoded password to the given user.- Specified by:
setPasswordWithDefaultEncodingin interfaceUserService- Parameters:
user- the encoded password is set toUserModel.setEncodedPassword(String)plainPassword- the plain text password for the user- Throws:
PasswordEncoderNotFoundException
-
getPassword
public String getPassword(String userId) throws CannotDecodePasswordException, PasswordEncoderNotFoundException Description copied from interface:UserServiceIf possible returns the decoded password from the given user. Throws exception if decoding is not possible.- Specified by:
getPasswordin 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
Description copied from interface:UserServiceEncodes the given plain text password with the default password encoding and set the encoded password to the given user.- Specified by:
setPasswordin 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(String userId, String password, String encoding) throws PasswordEncoderNotFoundException Description copied from interface:UserServiceSets the password according to the givenencodingfor the given user id.- Specified by:
setPasswordin 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
Description copied from interface:UserServiceReturns theUserGroupModelfor the specifieduid.- Specified by:
getUserGroupForUIDin interfaceUserService- Parameters:
uid- the uniqueuidof the group- Returns:
- the found
UserGroupModel(or a subtype of it).
-
getUserGroupForUID
Description copied from interface:UserServiceReturns theUserGroupModelfor the specifieduidand the specified (result) class.The found user group must be an instance of the given class, otherwise an exception is thrown.
- Specified by:
getUserGroupForUIDin interfaceUserService- Parameters:
uid- The uniqueuidof the user group to be searched for.clazz- The user group must match the given class. Can be aUserGroupModelor any subtype of it.- Returns:
- the found
UserGroupModel
-
getAllUserGroupsForUser
Description copied from interface:UserServiceGets all user groups for the given user.The
Setof user groups is collected recursively.- Specified by:
getAllUserGroupsForUserin interfaceUserService- Parameters:
user- the given user- Returns:
Setofuser groups
-
getAllUserGroupsForUser
Description copied from interface:UserServiceGets 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 givenclazzthen this group is not in the result set. UseUserService.getUserGroupForUID(String)if all groups are needed.The
Setof user groups is collected recursively.- Specified by:
getAllUserGroupsForUserin interfaceUserService- Parameters:
user- the given userclazz- the user group must match the given class. Can be aUserGroupModelor any subtype of it.- Returns:
Setof user groups which must be instances of the specified result class
-
getAllUserGroupsForUserGroup
public <T extends UserGroupModel> Set<T> getAllUserGroupsForUserGroup(UserGroupModel userGroup, Class<T> clazz) Description copied from interface:UserServiceGets 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 givenclazzthen this group is not in the result set. UseUserService.getUserGroupForUID(String)if all groups are needed.The
Setof user groups is collected recursively.- Specified by:
getAllUserGroupsForUserGroupin interfaceUserService- Parameters:
userGroup- the given user groupclazz- the user group must match the given class. Can be aUserGroupModelor any subtype of it.- Returns:
Setof user groups which must be instances of the specified result class
-
getUserAudits
Description copied from interface:UserServiceGets audit information about user previous password hashes. Can be used to implement password policy that does not allow to reuse previous passwords.- Specified by:
getUserAuditsin interfaceUserService- Returns:
-
isPasswordIdenticalToAudited
public boolean isPasswordIdenticalToAudited(UserModel user, String plainPassword, UserPasswordChangeAuditModel audit) Description copied from interface:UserServiceChecks 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:
isPasswordIdenticalToAuditedin interfaceUserService- Returns:
trueif password is the same as audit, otherwisefalse
-
isMemberOfGroup
Description copied from interface:UserServiceChecks if the givenuser is a memberof the specifiedgroupToCheckForor its super groups.The super groups are collected recursively.
- Specified by:
isMemberOfGroupin interfaceUserService- Parameters:
member- the user to checkgroupToCheckFor- the group(s) to be checked for- Returns:
trueif the user is a member of this group, otherwisefalse
-
isMemberOfGroup
public boolean isMemberOfGroup(UserModel member, UserGroupModel groupToCheckFor, boolean includeSuperGroups) Description copied from interface:UserServiceChecks if the givenuser is a memberof the specifiedgroupToCheckForor its super groups ifincludeSubGroupsis set totrue.The super groups are collected recursively.
- Specified by:
isMemberOfGroupin interfaceUserService- Parameters:
member- the user to checkgroupToCheckFor- the group(s) to be checked forincludeSuperGroups- should include super groups in search- Returns:
trueif the user is a member of this group, otherwisefalse
-
isMemberOfGroup
Description copied from interface:UserServiceChecks if the givenuser group is a memberof the specifiedgroupToCheckForor its super groups.The super groups are collected recursively.
- Specified by:
isMemberOfGroupin interfaceUserService- Parameters:
member- the user group to checkgroupToCheckFor- the group(s) to be checked for- Returns:
trueif the user group is a member of this group, otherwisefalse
-
isMemberOfGroup
public boolean isMemberOfGroup(UserGroupModel member, UserGroupModel groupToCheckFor, boolean includeSuperGroups) Description copied from interface:UserServiceChecks if the givenuser group is a memberof the specifiedgroupToCheckForor its super groups ifincludeSubGroupsis set totrue.The super groups are collected recursively.
- Specified by:
isMemberOfGroupin interfaceUserService- Parameters:
member- the user group to checkgroupToCheckFor- the group(s) to be checked forincludeSuperGroups- should include super groups in search- Returns:
trueif the user group is a member of this group, otherwisefalse
-
getAllTitles
Description copied from interface:UserServiceReturns allTitleModels in the system.- Specified by:
getAllTitlesin interfaceUserService- Returns:
- an empty collection if no
TitleModelwas found.
-
getTitleForCode
Description copied from interface:UserServiceReturns theTitleModelfor the specifiedcode.- Specified by:
getTitleForCodein interfaceUserService- Parameters:
code- the uniquecodeof the title
-
getAdminUser
Description copied from interface:UserServiceReturns always the admin user. Search restrictions are disabled for this call.- Specified by:
getAdminUserin interfaceUserService- Returns:
- the system admin user as
EmployeeModel
-
getAdminUserGroup
Description copied from interface:UserServiceReturns always the admin user group. Search restrictions are disabled for this call.- Specified by:
getAdminUserGroupin interfaceUserService- Returns:
- the admin user group as
UserGroupModel
-
isAdmin
Description copied from interface:UserServiceChecks 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:
isAdminin interfaceUserService- Parameters:
user- user to check- Returns:
trueif the user is an admin, otherwisefalse
-
isAdminGroup
Description copied from interface:UserServiceChecks if the given user group or it's super groups have the admin role.- Specified by:
isAdminGroupin interfaceUserService- Parameters:
userGroup- user to check- Returns:
trueif the user is an admin, otherwisefalse
-
isAdminEmployee
Description copied from interface:UserServiceChecks if the given user has the is the admin employee.- Specified by:
isAdminEmployeein interfaceUserService- Parameters:
user- user to check- Returns:
trueif the user is an admin employee, otherwisefalse
-
getAnonymousUser
Description copied from interface:UserServiceReturns always the anonymous user. Search restrictions are disabled for this call.- Specified by:
getAnonymousUserin interfaceUserService- Returns:
- the anonymous user as
CustomerModel
-
isAnonymousUser
Description copied from interface:UserServiceChecks if the given user is the anonymous customer.- Specified by:
isAnonymousUserin interfaceUserService- Parameters:
user- the user to check- Returns:
trueif the user is the anonymous customer, otherwisefalse
-
setEncodedPassword
Description copied from interface:UserServiceSets the encoded password to the given user.The encoding is taken form user or if
nullthe system default encoding is used.- Specified by:
setEncodedPasswordin interfaceUserService- Parameters:
user- the encoded password is set toUserModel.setEncodedPassword(String)encodedPassword- encoded password for the user
-
setEncodedPassword
Description copied from interface:UserServiceSets the encoded password to the given user.- Specified by:
setEncodedPasswordin interfaceUserService- Parameters:
user- the encoded password is set toUserModel.setEncodedPassword(String)encodedPassword- encoded password for the userencoding- the password encoding
-
setUserDao
-
setUserGroupDao
-
setTitleDao
-
setSearchRestrictionService
-
setEventService
-
setPasswordEncoderService
-
getDefaultPasswordEncoding
-
setDefaultPasswordEncoding
-
setPassword
public void setPassword(UserModel user, String plainPassword) throws PasswordEncoderNotFoundException Description copied from interface:UserServiceEncodes 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:
setPasswordin 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
-
setUserAuditDao
-