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,java.io.Serializable
public class UserManager extends Manager
The manager for all users and user - related items. Here you can create and search employees, customer, user groups, addresses and titles.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classUserManager.UserManagerSerializableDTO-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.Manager
Manager.GenericManagerSingletonCreator, Manager.ManagerSingletonCreator
-
-
Field Summary
Fields Modifier and Type Field Description static booleanALLOW_CUSTOMER_ADMIN_DEFAULTstatic java.lang.StringBEAN_NAMEIdentifier of this manager used at core-spring.xml spring configuration.static java.lang.StringCONFIG_ALLOW_CUSTOMER_ADMINstatic java.lang.StringFIELD_NAMESearch property constant denoting the address field name to search in.static java.lang.StringSEARCH_PATTERNSearch property constant denoting the address field value to search for.
-
Constructor Summary
Constructors Constructor Description UserManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckBeforeItemRemoval(SessionContext ctx, Item item)Avoids call to ejb layer except forPrincipals.booleancheckPassword(User user, LoginToken token)booleancheckPassword(User user, java.lang.String plainPassword)AddresscreateAddress(PK pkBase, Item item)Creates address for given item.AddresscreateAddress(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)AddresscreateAddress(Item item)Creates address for given item.CustomercreateCustomer(PK pk, java.lang.String login)Creates a newCustomer.CustomercreateCustomer(java.lang.String login)Creates a newCustomer.EmployeecreateEmployee(PK pk, java.lang.String login)Creates a newEmployee.EmployeecreateEmployee(java.lang.String login)Creates a newEmployee.TitlecreateTitle(PK pkBase, java.lang.String code)Creates a newTitle.TitlecreateTitle(java.lang.String code)Creates a newTitle.UsercreateUser(PK pk, java.lang.String uid)Creates a newUser.UsercreateUser(PK pkBase, java.lang.String userID, ComposedType type)Creates a newUserwith a specified user type.UsercreateUser(java.lang.String uid)Creates a newUser.UserGroupcreateUserGroup(PK pkBase, java.lang.String groupId)Creates a newUserGroup.UserGroupcreateUserGroup(java.lang.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 java.lang.StringdoGenerateLoginTokenCookieValue(java.lang.String uid, java.lang.String languageISO, java.lang.String plainTextPassword, User user)java.util.CollectionfindUserGroups(ComposedType type, java.lang.String groupId, java.lang.String name, java.lang.String description)Searches for specific users groups.java.util.Collection<? extends UserGroup>findUserGroups(ComposedType type, java.lang.String groupId, java.lang.String name, java.lang.String description, boolean disableRestrictions)Searches for specific users groups.java.util.CollectionfindUsers(ComposedType type, java.lang.String uid, java.lang.String name, java.lang.String description)Searches for specific users.java.util.Collection<? extends User>findUsers(ComposedType type, java.lang.String uid, java.lang.String name, java.lang.String description, boolean disableRestrictions)Searches for specific users.java.lang.StringgenerateCustomerID()Generates a new customer ID using the number series with identifierNumberSeriesConstants.Series#CUSTOMER_ID.java.lang.StringgenerateLoginTokenCookieValue(User user, java.lang.String languageISO)java.lang.StringgenerateLoginTokenCookieValue(java.lang.String uid, java.lang.String languageISO, java.lang.String plainTextPassword)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)protected java.lang.StringgetAddressTypeCode()EmployeegetAdminEmployee()Returns the admin employee.UserGroupgetAdminUserGroup()Returns the admin user group.java.util.CollectiongetAllAddresses()Returns all addresses.java.util.CollectiongetAllAddresses(Item owner)Returns all address of the given owner.java.util.CollectiongetAllCustomers()Finds all customer users.java.util.CollectiongetAllEmployees()Finds all employees.java.util.CollectiongetAllPrincipals()Returns absolute every user and usergroup stored in the system.java.util.CollectiongetAllTitles()Returns all titles.java.util.CollectiongetAllUserGroups()Finds all user groups.java.util.CollectiongetAllUsers()Returns all users (excluding all UserGroups).CustomergetAnonymousCustomer()Returns the anonymous customer.CookieBasedLoginTokengetCookieBasedLoginToken(javax.servlet.http.HttpServletRequest request)CustomergetCustomerByLogin(java.lang.String login)Find a customer by its login name.protected ComposedTypegetCustomerType()EmployeegetEmployeeByLogin(java.lang.String login)Finds an employee by its login name.protected ComposedTypegetEmployeeType()static UserManagergetInstance()Gets the instance of this manager.LoginTokengetLoginToken(javax.servlet.http.HttpServletRequest request)Tries to get a login token from request.protected PasswordEncodergetLoginTokenPasswordEncoder(User user)PasswordCheckingStrategygetPasswordCheckingStrategy()TitlegetTitleByCode(java.lang.String code)Returns theTitlewith the specified code.protected java.lang.StringgetTitleTypeCode()StringBasedLoginTokengetURLBasedLoginToken(javax.servlet.http.HttpServletRequest request)UsergetUserByLogin(java.lang.String login)Finds a user by its login name.UserGroupgetUserGroupByGroupID(java.lang.String groupID)Finds a user group by its login name.protected java.lang.StringgetUserGroupTypeCode()protected java.lang.StringgetUserTypeCode()Gets the code of the User composed type.voidinit()called once for each tenant, so this method fits best to perform some initialization stuffbooleanisAdmin(Customer customer)booleanisAdmin(Employee employee)booleanisAdmin(User user)static booleanisCustomersAllowedAsAdmin()protected booleanisPlainTextPasswordStored(User user)protected voidnotifyItemRemoval(SessionContext ctx, Item item)Superclass method overridden to avoid calls to ejb layer.voidremoveItem(Item item)voidsetPasswordCheckingStrategy(PasswordCheckingStrategy paramPasswordCheckingStrategy)voidstoreLoginTokenCookie(java.lang.String name, java.lang.String uid, java.lang.String language, java.lang.String passwd, java.lang.String path, java.lang.String domain, boolean secure, int ttl, javax.servlet.http.HttpServletResponse response)voidstoreLoginTokenCookie(java.lang.String name, java.lang.String uid, java.lang.String language, java.lang.String passwd, java.lang.String path, javax.servlet.http.HttpServletResponse response)voidstoreLoginTokenCookie(java.lang.String uid, java.lang.String language, java.lang.String passwd, java.lang.String path, javax.servlet.http.HttpServletResponse response)voidstoreLoginTokenCookie(java.lang.String uid, java.lang.String language, java.lang.String passwd, javax.servlet.http.HttpServletResponse response)Stores given login informations at a cookie of given session.java.lang.ObjectwriteReplace()-
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 Detail
-
BEAN_NAME
public static final java.lang.String BEAN_NAME
Identifier of this manager used at core-spring.xml spring configuration.- See Also:
- Constant Field Values
-
FIELD_NAME
public static final java.lang.String FIELD_NAME
Search property constant denoting the address field name to search in.- See Also:
- Constant Field Values
-
SEARCH_PATTERN
public static final java.lang.String SEARCH_PATTERN
Search property constant denoting the address field value to search for.- See Also:
- Constant Field Values
-
CONFIG_ALLOW_CUSTOMER_ADMIN
public static final java.lang.String CONFIG_ALLOW_CUSTOMER_ADMIN
- See Also:
- Constant Field Values
-
ALLOW_CUSTOMER_ADMIN_DEFAULT
public static final boolean ALLOW_CUSTOMER_ADMIN_DEFAULT
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init()
Description copied from class:Managercalled once for each tenant, so this method fits best to perform some initialization stuff
-
getInstance
public static UserManager 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
protected void notifyItemRemoval(SessionContext ctx, Item item)
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
protected java.lang.String getUserTypeCode()
Gets the code of the User composed type.
-
getUserGroupTypeCode
protected java.lang.String getUserGroupTypeCode()
-
getTitleTypeCode
protected java.lang.String getTitleTypeCode()
-
getAddressTypeCode
protected java.lang.String getAddressTypeCode()
-
getCustomerType
protected ComposedType getCustomerType()
-
getEmployeeType
protected ComposedType getEmployeeType()
-
getAllUsers
public java.util.Collection getAllUsers()
Returns all users (excluding all UserGroups).- Returns:
- a
Collectionof all users.
-
findUsers
public java.util.Collection findUsers(ComposedType type, java.lang.String uid, java.lang.String name, java.lang.String description)
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 java.util.Collection<? extends User> findUsers(ComposedType type, java.lang.String uid, java.lang.String name, java.lang.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
public java.util.Collection 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
public java.util.Collection 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
public java.util.Collection 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
public java.util.Collection 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 java.util.Collection findUserGroups(ComposedType type, java.lang.String groupId, java.lang.String name, java.lang.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 java.util.Collection<? extends UserGroup> findUserGroups(ComposedType type, java.lang.String groupId, java.lang.String name, java.lang.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
public java.util.Collection getAllTitles()
Returns all titles.- Returns:
- a
Collectionof all titles.
-
getAllAddresses
public java.util.Collection getAllAddresses()
Returns all addresses.- Returns:
- a
Collectionof all addresses.
-
getCustomerByLogin
public Customer getCustomerByLogin(java.lang.String login) throws JaloItemNotFoundException
Find a customer by its login name.- Returns:
- the
Customerwith the specified login. - Throws:
JaloItemNotFoundException- if there is noCustomerwith the specified login.
-
getEmployeeByLogin
public Employee getEmployeeByLogin(java.lang.String login) throws JaloItemNotFoundException
Finds an employee by its login name.- Returns:
- the
Employeewith the specified login. - Throws:
JaloItemNotFoundException- if there is noEmployeewith the specified login.
-
getUserByLogin
public User getUserByLogin(java.lang.String login) throws JaloItemNotFoundException
Finds a user by its login name.- Returns:
- the
Userwith the specified login. - Throws:
JaloItemNotFoundException- if there is noUserwith the specified login.
-
getUserGroupByGroupID
public UserGroup getUserGroupByGroupID(java.lang.String groupID) throws JaloItemNotFoundException
Finds a user group by its login name.- Returns:
- the
UserGroupwith the specified ID. - Throws:
JaloItemNotFoundException- if there is noUserGroupwith the specified ID.
-
createCustomer
public Customer createCustomer(java.lang.String login) throws ConsistencyCheckException
Creates a newCustomer.- Returns:
- the new
Customer - Throws:
ConsistencyCheckException- if this login name is already used
-
createCustomer
public Customer createCustomer(PK pk, java.lang.String login) throws ConsistencyCheckException
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
public Employee createEmployee(java.lang.String login) throws ConsistencyCheckException
Creates a newEmployee.- Returns:
- the new
Employee - Throws:
ConsistencyCheckException- if this login name is already used
-
createEmployee
public Employee createEmployee(PK pk, java.lang.String login) throws ConsistencyCheckException
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
public UserGroup createUserGroup(java.lang.String uid) throws ConsistencyCheckException
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
public UserGroup createUserGroup(PK pkBase, java.lang.String groupId) throws ConsistencyCheckException
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
public User createUser(java.lang.String uid) throws ConsistencyCheckException
Creates a newUser.- Returns:
- the new
User - Throws:
ConsistencyCheckException- if this login name is already used
-
createUser
public User createUser(PK pk, java.lang.String uid) throws ConsistencyCheckException
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, java.lang.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
public Title createTitle(java.lang.String code) throws ConsistencyCheckException
Creates a newTitle.- Parameters:
code- the code.- Returns:
- the new
Title - Throws:
ConsistencyCheckException- if the code is already in use.
-
createTitle
public Title createTitle(PK pkBase, java.lang.String code) throws ConsistencyCheckException
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
public Title getTitleByCode(java.lang.String code) throws JaloItemNotFoundException
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
public Employee 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
public boolean isAdmin(User user)
-
isAdmin
public boolean isAdmin(Employee employee)
-
isAdmin
public boolean isAdmin(Customer customer)
-
isCustomersAllowedAsAdmin
public static boolean isCustomersAllowedAsAdmin()
-
getAnonymousCustomer
public Customer getAnonymousCustomer()
Returns the anonymous customer.- Returns:
- the anonymous customer
- Throws:
JaloInternalException- if anonymous can not be found
-
getAdminUserGroup
public UserGroup getAdminUserGroup()
Returns the admin user group. All members automatically have admin permissions.- Returns:
- the admin user group
-
getAllAddresses
public java.util.Collection getAllAddresses(Item owner)
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
public Address createAddress(Item item)
Creates address for given item.- Parameters:
item- - for this item address will be created- Returns:
- created address
-
createAddress
public Address createAddress(PK pkBase, Item item, boolean asCopy)
Creates address for given item.- Parameters:
item- - for this item address will be created- Returns:
- created address
-
createAddress
public Address createAddress(PK pkBase, Item item)
Creates address for given item.- Parameters:
item- - for this item address will be created- Returns:
- created address
-
createAddress
protected Address createAddress(PK pkBase, Item owner, Address original, Country country, Region region, Title title, JaloPropertyContainer props)
-
generateCustomerID
public java.lang.String 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
public LoginToken getLoginToken(javax.servlet.http.HttpServletRequest request)
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
public StringBasedLoginToken getURLBasedLoginToken(javax.servlet.http.HttpServletRequest request)
-
generateLoginTokenCookieValue
public java.lang.String generateLoginTokenCookieValue(java.lang.String uid, java.lang.String languageISO, java.lang.String plainTextPassword) throws EJBPasswordEncoderNotFoundExceptionGenerates 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 java.lang.String generateLoginTokenCookieValue(User user, java.lang.String languageISO) throws EJBPasswordEncoderNotFoundException
- Returns:
- generated token format: ${user PK}${language PK}
- Throws:
EJBPasswordEncoderNotFoundException
-
doGenerateLoginTokenCookieValue
protected java.lang.String doGenerateLoginTokenCookieValue(java.lang.String uid, java.lang.String languageISO, java.lang.String plainTextPassword, User user) throws EJBPasswordEncoderNotFoundException
-
storeLoginTokenCookie
public void storeLoginTokenCookie(java.lang.String uid, java.lang.String language, java.lang.String passwd, javax.servlet.http.HttpServletResponse response) throws EJBPasswordEncoderNotFoundExceptionStores 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(java.lang.String uid, java.lang.String language, java.lang.String passwd, java.lang.String path, javax.servlet.http.HttpServletResponse response) throws EJBPasswordEncoderNotFoundException
-
storeLoginTokenCookie
public void storeLoginTokenCookie(java.lang.String name, java.lang.String uid, java.lang.String language, java.lang.String passwd, java.lang.String path, javax.servlet.http.HttpServletResponse response) throws EJBPasswordEncoderNotFoundException
-
storeLoginTokenCookie
public void storeLoginTokenCookie(java.lang.String name, java.lang.String uid, java.lang.String language, java.lang.String passwd, java.lang.String path, java.lang.String domain, boolean secure, int ttl, javax.servlet.http.HttpServletResponse response) throws EJBPasswordEncoderNotFoundException
-
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
protected boolean isPlainTextPasswordStored(User user)
-
getLoginTokenPasswordEncoder
protected PasswordEncoder getLoginTokenPasswordEncoder(User user) throws EJBPasswordEncoderNotFoundException
-
writeReplace
public java.lang.Object writeReplace() throws java.io.ObjectStreamException- Specified by:
writeReplacein classManager- Throws:
java.io.ObjectStreamException
-
checkPassword
public boolean checkPassword(User user, java.lang.String plainPassword) throws EJBPasswordEncoderNotFoundException
-
checkPassword
public boolean checkPassword(User user, LoginToken token) throws EJBPasswordEncoderNotFoundException
-
setPasswordCheckingStrategy
public void setPasswordCheckingStrategy(PasswordCheckingStrategy paramPasswordCheckingStrategy)
-
getPasswordCheckingStrategy
public PasswordCheckingStrategy getPasswordCheckingStrategy()
-
removeItem
public void removeItem(Item item) throws ConsistencyCheckException
- Throws:
ConsistencyCheckException
-
-