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 class
UserManager.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 boolean
ALLOW_CUSTOMER_ADMIN_DEFAULT
static java.lang.String
BEAN_NAME
Identifier of this manager used at core-spring.xml spring configuration.static java.lang.String
CONFIG_ALLOW_CUSTOMER_ADMIN
static java.lang.String
FIELD_NAME
Search property constant denoting the address field name to search in.static java.lang.String
SEARCH_PATTERN
Search 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 void
checkBeforeItemRemoval(SessionContext ctx, Item item)
Avoids call to ejb layer except forPrincipals
.boolean
checkPassword(User user, LoginToken token)
boolean
checkPassword(User user, java.lang.String plainPassword)
Address
createAddress(PK pkBase, Item item)
Creates address for given item.Address
createAddress(PK pkBase, Item item, boolean asCopy)
Creates address for given item.protected Address
createAddress(PK pkBase, Item owner, Address original, Country country, Region region, Title title, JaloPropertyContainer props)
Address
createAddress(Item item)
Creates address for given item.Customer
createCustomer(PK pk, java.lang.String login)
Creates a newCustomer
.Customer
createCustomer(java.lang.String login)
Creates a newCustomer
.Employee
createEmployee(PK pk, java.lang.String login)
Creates a newEmployee
.Employee
createEmployee(java.lang.String login)
Creates a newEmployee
.Title
createTitle(PK pkBase, java.lang.String code)
Creates a newTitle
.Title
createTitle(java.lang.String code)
Creates a newTitle
.User
createUser(PK pk, java.lang.String uid)
Creates a newUser
.User
createUser(PK pkBase, java.lang.String userID, ComposedType type)
Creates a newUser
with a specified user type.User
createUser(java.lang.String uid)
Creates a newUser
.UserGroup
createUserGroup(PK pkBase, java.lang.String groupId)
Creates a newUserGroup
.UserGroup
createUserGroup(java.lang.String uid)
Creates a newUserGroup
.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.protected java.lang.String
doGenerateLoginTokenCookieValue(java.lang.String uid, java.lang.String languageISO, java.lang.String plainTextPassword, User user)
java.util.Collection
findUserGroups(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.Collection
findUsers(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.String
generateCustomerID()
Generates a new customer ID using the number series with identifierNumberSeriesConstants.Series#CUSTOMER_ID
.java.lang.String
generateLoginTokenCookieValue(User user, java.lang.String languageISO)
java.lang.String
generateLoginTokenCookieValue(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.String
getAddressTypeCode()
Employee
getAdminEmployee()
Returns the admin employee.UserGroup
getAdminUserGroup()
Returns the admin user group.java.util.Collection
getAllAddresses()
Returns all addresses.java.util.Collection
getAllAddresses(Item owner)
Returns all address of the given owner.java.util.Collection
getAllCustomers()
Finds all customer users.java.util.Collection
getAllEmployees()
Finds all employees.java.util.Collection
getAllPrincipals()
Returns absolute every user and usergroup stored in the system.java.util.Collection
getAllTitles()
Returns all titles.java.util.Collection
getAllUserGroups()
Finds all user groups.java.util.Collection
getAllUsers()
Returns all users (excluding all UserGroups).Customer
getAnonymousCustomer()
Returns the anonymous customer.CookieBasedLoginToken
getCookieBasedLoginToken(javax.servlet.http.HttpServletRequest request)
Customer
getCustomerByLogin(java.lang.String login)
Find a customer by its login name.protected ComposedType
getCustomerType()
Employee
getEmployeeByLogin(java.lang.String login)
Finds an employee by its login name.protected ComposedType
getEmployeeType()
static UserManager
getInstance()
Gets the instance of this manager.LoginToken
getLoginToken(javax.servlet.http.HttpServletRequest request)
Tries to get a login token from request.protected PasswordEncoder
getLoginTokenPasswordEncoder(User user)
PasswordCheckingStrategy
getPasswordCheckingStrategy()
Title
getTitleByCode(java.lang.String code)
Returns theTitle
with the specified code.protected java.lang.String
getTitleTypeCode()
StringBasedLoginToken
getURLBasedLoginToken(javax.servlet.http.HttpServletRequest request)
User
getUserByLogin(java.lang.String login)
Finds a user by its login name.UserGroup
getUserGroupByGroupID(java.lang.String groupID)
Finds a user group by its login name.protected java.lang.String
getUserGroupTypeCode()
protected java.lang.String
getUserTypeCode()
Gets the code of the User composed type.void
init()
called once for each tenant, so this method fits best to perform some initialization stuffboolean
isAdmin(Customer customer)
boolean
isAdmin(Employee employee)
boolean
isAdmin(User user)
static boolean
isCustomersAllowedAsAdmin()
protected boolean
isPlainTextPasswordStored(User user)
protected void
notifyItemRemoval(SessionContext ctx, Item item)
Superclass method overridden to avoid calls to ejb layer.void
removeItem(Item item)
void
setPasswordCheckingStrategy(PasswordCheckingStrategy paramPasswordCheckingStrategy)
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)
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)
void
storeLoginTokenCookie(java.lang.String uid, java.lang.String language, java.lang.String passwd, java.lang.String path, javax.servlet.http.HttpServletResponse response)
void
storeLoginTokenCookie(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.Object
writeReplace()
-
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:Manager
called 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:
checkBeforeItemRemoval
in 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:
notifyItemRemoval
in 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
Collection
of 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
Collection
of 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
Collection
of 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
Collection
of 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
Collection
of all titles.
-
getAllAddresses
public java.util.Collection getAllAddresses()
Returns all addresses.- Returns:
- a
Collection
of all addresses.
-
getCustomerByLogin
public Customer getCustomerByLogin(java.lang.String login) throws JaloItemNotFoundException
Find a customer by its login name.- Returns:
- the
Customer
with the specified login. - Throws:
JaloItemNotFoundException
- if there is noCustomer
with the specified login.
-
getEmployeeByLogin
public Employee getEmployeeByLogin(java.lang.String login) throws JaloItemNotFoundException
Finds an employee by its login name.- Returns:
- the
Employee
with the specified login. - Throws:
JaloItemNotFoundException
- if there is noEmployee
with the specified login.
-
getUserByLogin
public User getUserByLogin(java.lang.String login) throws JaloItemNotFoundException
Finds a user by its login name.- Returns:
- the
User
with the specified login. - Throws:
JaloItemNotFoundException
- if there is noUser
with the specified login.
-
getUserGroupByGroupID
public UserGroup getUserGroupByGroupID(java.lang.String groupID) throws JaloItemNotFoundException
Finds a user group by its login name.- Returns:
- the
UserGroup
with the specified ID. - Throws:
JaloItemNotFoundException
- if there is noUserGroup
with 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 newUser
with 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 theTitle
with the specified code.- Parameters:
code
- the searched code- Returns:
- the
Title
with the specified code - Throws:
JaloItemNotFoundException
- if there is noTitle
with 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
Collection
of 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 EJBPasswordEncoderNotFoundException
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 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 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(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:
writeReplace
in 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
-
-