Package de.hybris.platform.jalo.user
Class UserManager
java.lang.Object
de.hybris.platform.jalo.Manager
de.hybris.platform.jalo.user.UserManager
- All Implemented Interfaces:
ItemLifecycleListener,Serializable
The manager for all users and user - related items.
Here you can create and search employees, customer, user groups, addresses and titles.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class de.hybris.platform.jalo.Manager
Manager.GenericManagerSingletonCreator, Manager.ManagerSingletonCreator -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final StringIdentifier of this manager used at core-spring.xml spring configuration.static final Stringstatic final StringSearch property constant denoting the address field name to search in.static final StringSearch property constant denoting the address field value to search for. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckBeforeItemRemoval(SessionContext ctx, Item item) Avoids call to ejb layer except forPrincipals.booleancheckPassword(User user, LoginToken token) booleancheckPassword(User user, String plainPassword) createAddress(PK pkBase, Item item) Creates address for given item.createAddress(PK pkBase, Item item, boolean asCopy) Creates address for given item.protected AddresscreateAddress(PK pkBase, Item owner, Address original, Country country, Region region, Title title, JaloPropertyContainer props) createAddress(Item item) Creates address for given item.createCustomer(PK pk, String login) Creates a newCustomer.createCustomer(String login) Creates a newCustomer.createEmployee(PK pk, String login) Creates a newEmployee.createEmployee(String login) Creates a newEmployee.createTitle(PK pkBase, String code) Creates a newTitle.createTitle(String code) Creates a newTitle.createUser(PK pk, String uid) Creates a newUser.createUser(PK pkBase, String userID, ComposedType type) Creates a newUserwith a specified user type.createUser(String uid) Creates a newUser.createUserGroup(PK pkBase, String groupId) Creates a newUserGroup.createUserGroup(String uid) Creates a newUserGroup.voiddeleteLoginTokenCookie(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Deletes a cookie at given request according tostoreLoginTokenCookie(String, String, String, HttpServletResponse)method.protected StringdoGenerateLoginTokenCookieValue(String uid, String languageISO, String plainTextPassword, User user) Deprecated, for removal: This API element is subject to removal in a future version.protected StringdoGenerateLoginTokenCookieValue(String uid, String languageISO, String plainTextPassword, User user, Integer ttl) findUserGroups(ComposedType type, String groupId, String name, String description) Searches for specific users groups.Collection<? extends UserGroup>findUserGroups(ComposedType type, String groupId, String name, String description, boolean disableRestrictions) Searches for specific users groups.findUsers(ComposedType type, String uid, String name, String description) Searches for specific users.Collection<? extends User>findUsers(ComposedType type, String uid, String name, String description, boolean disableRestrictions) Searches for specific users.Generates a new customer ID using the number series with identifierNumberSeriesConstants.Series#CUSTOMER_ID.generateLoginTokenCookieValue(User user, String languageISO) generateLoginTokenCookieValue(String uid, String languageISO, String plainTextPassword) Deprecated, for removal: This API element is subject to removal in a future version.since 2011, usegenerateLoginTokenCookieValue(String, String, String, Integer)generateLoginTokenCookieValue(String uid, String languageISO, String plainTextPassword, Integer ttl) protected StringReturns the admin employee.Returns the admin user group.Returns all addresses.getAllAddresses(Item owner) Returns all address of the given owner.Finds all customer users.Finds all employees.Returns absolute every user and usergroup stored in the system.Returns all titles.Finds all user groups.Returns all users (excluding all UserGroups).Returns the anonymous customer.getCookieBasedLoginToken(javax.servlet.http.HttpServletRequest request) getCustomerByLogin(String login) Find a customer by its login name.protected ComposedTypegetEmployeeByLogin(String login) Finds an employee by its login name.protected ComposedTypeprotected StringgetEncodedPasswordForLoginCookie(String uid, String plainTextPassword, User user) protected StringgetEncodedPasswordWithSalt(User user, String passwordToEncode, String saltToAdd) static UserManagerGets the instance of this manager.getLoginToken(javax.servlet.http.HttpServletRequest request) Tries to get a login token from request.protected PasswordEncodergetTitleByCode(String code) Returns theTitlewith the specified code.protected StringgetURLBasedLoginToken(javax.servlet.http.HttpServletRequest request) getUserByLogin(String login) Finds a user by its login name.getUserGroupByGroupID(String groupID) Finds a user group by its login name.protected Stringprotected StringGets the code of the User composed type.voidinit()called once for each tenant, so this method fits best to perform some initialization stuffbooleanbooleanbooleanstatic booleanprotected booleanprotected voidnotifyItemRemoval(SessionContext ctx, Item item) Superclass method overridden to avoid calls to ejb layer.voidremoveItem(Item item) voidsetPasswordCheckingStrategy(PasswordCheckingStrategy paramPasswordCheckingStrategy) voidstoreLoginTokenCookie(String name, String uid, String language, String passwd, String path, String domain, boolean secure, int ttl, javax.servlet.http.HttpServletResponse response) voidstoreLoginTokenCookie(String name, String uid, String language, String passwd, String path, javax.servlet.http.HttpServletResponse response) voidstoreLoginTokenCookie(String uid, String language, String passwd, String path, javax.servlet.http.HttpServletResponse response) voidstoreLoginTokenCookie(String uid, String language, String passwd, javax.servlet.http.HttpServletResponse response) Stores given login informations at a cookie of given session.Methods inherited from class de.hybris.platform.jalo.Manager
afterItemCreation, beforeItemCreation, destroy, extractNonRequiredRemoteFromItem, extractRequiredRemoteFromItem, getAllValuesSessionContext, getAttribute, getAttributeMap, getFirstItemByAttribute, getFirstItemByAttribute, getRemote, getRemoteManagerClass, getSession, getSingletonManagerInstance, getTenant, getTransientObject, getTransientObjectMap, setAttribute, setTenant, setTransientObject, wrap
-
Field Details
-
BEAN_NAME
Identifier of this manager used at core-spring.xml spring configuration.- See Also:
-
FIELD_NAME
Search property constant denoting the address field name to search in.- See Also:
-
SEARCH_PATTERN
Search property constant denoting the address field value to search for.- See Also:
-
CONFIG_ALLOW_CUSTOMER_ADMIN
- See Also:
-
ALLOW_CUSTOMER_ADMIN_DEFAULT
public static final boolean ALLOW_CUSTOMER_ADMIN_DEFAULT- See Also:
-
-
Constructor Details
-
UserManager
public UserManager()
-
-
Method Details
-
init
public void init()Description copied from class:Managercalled once for each tenant, so this method fits best to perform some initialization stuff -
getInstance
Gets the instance of this manager.- Returns:
- instance of this manager
-
checkBeforeItemRemoval
protected void checkBeforeItemRemoval(SessionContext ctx, Item item) throws ConsistencyCheckException Avoids call to ejb layer except forPrincipals.- Overrides:
checkBeforeItemRemovalin classManager- Parameters:
ctx- the current session contextitem- the item which should be removed- Throws:
ConsistencyCheckException- thrown to abort removal due to consistency errors- Since:
- 2.10
-
notifyItemRemoval
Superclass method overridden to avoid calls to ejb layer.- Overrides:
notifyItemRemovalin classManager- Parameters:
ctx- the currency session contextitem- the item which is going to be removed- Since:
- 2.10
-
getUserTypeCode
Gets the code of the User composed type. -
getUserGroupTypeCode
-
getTitleTypeCode
-
getAddressTypeCode
-
getCustomerType
-
getEmployeeType
-
getAllUsers
Returns all users (excluding all UserGroups).- Returns:
- a
Collectionof all users.
-
findUsers
Searches for specific users.- Parameters:
type- The ComposedType which restricts the search or null to search all 'User' typesuid- The uid to search or null to search allname- The name to search or null to search alldescription- The description to search or null to search all- Returns:
- collection with users, which fulfills the criteria
-
findUsers
public Collection<? extends User> findUsers(ComposedType type, String uid, String name, String description, boolean disableRestrictions) Searches for specific users.- Parameters:
type- The ComposedType which restricts the search or null to search all 'User' typesuid- The uid to search or null to search allname- The name to search or null to search alldescription- The description to search or null to search alldisableRestrictions- will search restrictions be disabled?- Returns:
- collection with users, which fulfills the criteria
-
getAllPrincipals
Returns absolute every user and usergroup stored in the system. But be warned: this method may be inperformant, especially in larger setups.- Returns:
- a
Collection of all principals.
-
getAllCustomers
Finds all customer users. Please note that this does not include customer subclasses but just the hybris platform core customer user type!- Returns:
- a
Collectionof all customers.
-
getAllEmployees
Finds all employees. Please note that this does not include employee subclasses but just the hybris platform core employee user type!- Returns:
- a
Collectionof all employees.
-
getAllUserGroups
Finds all user groups. Please note that this does not include usergroup subclasses but just the hybris platform core usergroup user type!- Returns:
- a
Collectionof all user groups.
-
findUserGroups
public Collection findUserGroups(ComposedType type, String groupId, String name, String description) Searches for specific users groups.- Parameters:
type- The ComposedType which restricts the search or null to search all 'UserGroup' typesgroupId- The groupid to search or null to search allname- The name to search or null to search alldescription- The description to search or null to search all- Returns:
- collection with user groups, which fulfills the criteria
-
findUserGroups
public Collection<? extends UserGroup> findUserGroups(ComposedType type, String groupId, String name, String description, boolean disableRestrictions) Searches for specific users groups.- Parameters:
type- The ComposedType which restricts the search or null to search all 'UserGroup' typesgroupId- The groupid to search or null to search allname- The name to search or null to search alldescription- The description to search or null to search alldisableRestrictions- will search restrictions be disabled?- Returns:
- collection with user groups, which fulfills the criteria
-
getAllTitles
Returns all titles.- Returns:
- a
Collectionof all titles.
-
getAllAddresses
Returns all addresses.- Returns:
- a
Collectionof all addresses.
-
getCustomerByLogin
Find a customer by its login name.- Returns:
- the
Customerwith the specified login. - Throws:
JaloItemNotFoundException- if there is noCustomerwith the specified login.
-
getEmployeeByLogin
Finds an employee by its login name.- Returns:
- the
Employeewith the specified login. - Throws:
JaloItemNotFoundException- if there is noEmployeewith the specified login.
-
getUserByLogin
Finds a user by its login name.- Returns:
- the
Userwith the specified login. - Throws:
JaloItemNotFoundException- if there is noUserwith the specified login.
-
getUserGroupByGroupID
Finds a user group by its login name.- Returns:
- the
UserGroupwith the specified ID. - Throws:
JaloItemNotFoundException- if there is noUserGroupwith the specified ID.
-
createCustomer
Creates a newCustomer.- Returns:
- the new
Customer - Throws:
ConsistencyCheckException- if this login name is already used
-
createCustomer
Creates a newCustomer.- Parameters:
pk- the pk for the new item; it will be equipped with type code additionally (- ) - Returns:
- the new
Customer - Throws:
ConsistencyCheckException- if this login name is already used
-
createEmployee
Creates a newEmployee.- Returns:
- the new
Employee - Throws:
ConsistencyCheckException- if this login name is already used
-
createEmployee
Creates a newEmployee.- Parameters:
pk- the pk for the new item; it will be equipped with type code additionally (- ) - Returns:
- the new
Employee - Throws:
ConsistencyCheckException- if this login name is already used
-
createUserGroup
Creates a newUserGroup.- Parameters:
uid- the ID of the new UserGroup- Returns:
- the new
UserGroup - Throws:
ConsistencyCheckException- if this login name is already used
-
createUserGroup
Creates a newUserGroup.- Parameters:
pkBase- the pk for the new item; it will be equipped with type code additionally (- ) groupId- the ID of the new UserGroup- Returns:
- the new
UserGroup - Throws:
ConsistencyCheckException- if this login name is already used
-
createUser
Creates a newUser.- Returns:
- the new
User - Throws:
ConsistencyCheckException- if this login name is already used
-
createUser
Creates a newUser.- Parameters:
pk- the pk for the new item; it will be equipped with type code additionally (- ) - Returns:
- the new
User - Throws:
ConsistencyCheckException- if this login name is already used
-
createUser
public User createUser(PK pkBase, String userID, ComposedType type) throws ConsistencyCheckException Creates a newUserwith a specified user type.- Parameters:
pkBase- the pk for the new item; it will be equipped with type code additionally (- ) type- the item type of the new user item- Returns:
- the new
User - Throws:
ConsistencyCheckException- if this login name is already used
-
createTitle
Creates a newTitle.- Parameters:
code- the code.- Returns:
- the new
Title - Throws:
ConsistencyCheckException- if the code is already in use.
-
createTitle
Creates a newTitle.- Parameters:
pkBase- the pk for the new item; it will be equipped with type code additionally (- ) code- the code.- Returns:
- the new
Title - Throws:
ConsistencyCheckException- if the code is already in use.
-
getTitleByCode
Returns theTitlewith the specified code.- Parameters:
code- the searched code- Returns:
- the
Titlewith the specified code - Throws:
JaloItemNotFoundException- if there is noTitlewith the specified code
-
getAdminEmployee
Returns the admin employee. Nevertheless there may be multiple admin employees; these are all members of the admin user group.- Returns:
- the admin employee
- Throws:
JaloInternalException- if admin can not be found
-
isAdmin
-
isAdmin
-
isAdmin
-
isCustomersAllowedAsAdmin
public static boolean isCustomersAllowedAsAdmin() -
getAnonymousCustomer
Returns the anonymous customer.- Returns:
- the anonymous customer
- Throws:
JaloInternalException- if anonymous can not be found
-
getAdminUserGroup
Returns the admin user group. All members automatically have admin permissions.- Returns:
- the admin user group
-
getAllAddresses
Returns all address of the given owner.- Parameters:
owner- the Item whose addresses will be returned.- Returns:
- a
Collectionof all address of the given owner.
-
createAddress
Creates address for given item.- Parameters:
item- - for this item address will be created- Returns:
- created address
-
createAddress
Creates address for given item.- Parameters:
item- - for this item address will be created- Returns:
- created address
-
createAddress
Creates address for given item.- Parameters:
item- - for this item address will be created- Returns:
- created address
-
createAddress
-
generateCustomerID
Generates a new customer ID using the number series with identifierNumberSeriesConstants.Series#CUSTOMER_ID. This number will be unique in relation to all id's generated by this method before.- Returns:
- new customer id
- Since:
- public since 3.1-u6, before protected
-
getLoginToken
Tries to get a login token from request. First it tries to extract it from url, then from cookie. -
getCookieBasedLoginToken
public CookieBasedLoginToken getCookieBasedLoginToken(javax.servlet.http.HttpServletRequest request) -
getURLBasedLoginToken
-
generateLoginTokenCookieValue
@Deprecated(since="2011", forRemoval=true) public String generateLoginTokenCookieValue(String uid, String languageISO, String plainTextPassword) throws EJBPasswordEncoderNotFoundException Deprecated, for removal: This API element is subject to removal in a future version.since 2011, usegenerateLoginTokenCookieValue(String, String, String, Integer)Generates a value entry for a CookieBasedLoginToken instance, which will be used by some web apps (like printcockpit, hmc, ...) for an 'auto' login process All occurrences if possible should be replace withgenerateLoginTokenCookieValue(User, String)- Returns:
- the generated token. format: ${user PK}${language PK}${password} (sample: 11326704420716009013969790041776ee10c315eba2c75b403ea79136f5b38d)
- Throws:
EJBPasswordEncoderNotFoundException
-
generateLoginTokenCookieValue
public String generateLoginTokenCookieValue(User user, String languageISO) throws EJBPasswordEncoderNotFoundException - Returns:
- generated token format: ${user PK}${language PK}
- Throws:
EJBPasswordEncoderNotFoundException
-
generateLoginTokenCookieValue
-
doGenerateLoginTokenCookieValue
@Deprecated(since="2011", forRemoval=true) protected String doGenerateLoginTokenCookieValue(String uid, String languageISO, String plainTextPassword, User user) throws EJBPasswordEncoderNotFoundException Deprecated, for removal: This API element is subject to removal in a future version. -
doGenerateLoginTokenCookieValue
-
getEncodedPasswordForLoginCookie
protected String getEncodedPasswordForLoginCookie(String uid, String plainTextPassword, User user) throws EJBPasswordEncoderNotFoundException -
getEncodedPasswordWithSalt
-
storeLoginTokenCookie
public void storeLoginTokenCookie(String uid, String language, String passwd, javax.servlet.http.HttpServletResponse response) throws EJBPasswordEncoderNotFoundException Stores given login informations at a cookie of given session. The parameters of the cookie can be configured via system properties with keys defined atCookieBasedLoginToken. -
storeLoginTokenCookie
public void storeLoginTokenCookie(String uid, String language, String passwd, String path, javax.servlet.http.HttpServletResponse response) throws EJBPasswordEncoderNotFoundException -
storeLoginTokenCookie
-
storeLoginTokenCookie
-
deleteLoginTokenCookie
public void deleteLoginTokenCookie(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Deletes a cookie at given request according tostoreLoginTokenCookie(String, String, String, HttpServletResponse)method. -
isPlainTextPasswordStored
-
getLoginTokenPasswordEncoder
protected PasswordEncoder getLoginTokenPasswordEncoder(User user) throws EJBPasswordEncoderNotFoundException -
writeReplace
- Specified by:
writeReplacein classManager- Throws:
ObjectStreamException
-
checkPassword
public boolean checkPassword(User user, String plainPassword) throws EJBPasswordEncoderNotFoundException -
checkPassword
public boolean checkPassword(User user, LoginToken token) throws EJBPasswordEncoderNotFoundException -
setPasswordCheckingStrategy
-
getPasswordCheckingStrategy
-
removeItem
- Throws:
ConsistencyCheckException
-
doGenerateLoginTokenCookieValue(String, String, String, User, Integer)