Class PrincipalManagerImpl
java.lang.Object
ch.tocco.nice2.userbase.impl.auth.PrincipalManagerImpl
- All Implemented Interfaces:
PrincipalManager
,PrincipalDetailService
,PrincipalManagerService
,PrincipalService
-
Constructor Summary
ConstructorDescriptionPrincipalManagerImpl
(org.slf4j.Logger log, CommandExecutor executor, PersistenceService persistenceService, ImpliedRolesProvider impliedRolesProvider, BusinessUnitManager businessUnitManager, SecurityManager securityManager, QueryBuilderFactory queryBuilderFactory) -
Method Summary
Modifier and TypeMethodDescriptioncreateUniqueUsernames
(List<Entity> users) Creates a uniqueusername
.getPrincipal
(String name, boolean withRoles) Returns the principal from the underlying store.@Nullable PrincipalDetails
getPrincipalDetails
(String username, Object credentials) Return details of the user specified by username.getPrincipalEntity
(String username) getRolesFor
(String principal) Creates a query to retrieve all roles for a principal according to the business unit currently on the thread.getUserEntity
(String username) void
loginNewlyCreatedUser
(Entity userEntity) Logs in a (newly created) user.void
Logs in a user by username.void
resetPrincipalFields
(Entity principal, PrincipalFields... fields) void
resetPrincipalFields
(String username, PrincipalFields... fields) void
resetTemporaryPassword
(String username) Invalidates the state of the temporary password request mechanism, resettingtemporary_password
tonull
and setting the flag requiring a new password after login tofalse
.void
setNewPassword
(String username, String newPassword, boolean resetRequired) Sets new password and required-flag.void
setTemporaryPassword
(String username, String newPassword) Sets thetemporary_password
for the given principal, which will be valid for login as well until it expires based on thelast_password_dispatch
.void
updatePrincipalFields
(Entity principal, PrincipalFields... fields) void
updatePrincipalFields
(String username, PrincipalFields... fields) void
updateTwoFactorData
(String username, String secret)
-
Constructor Details
-
PrincipalManagerImpl
public PrincipalManagerImpl(org.slf4j.Logger log, CommandExecutor executor, PersistenceService persistenceService, ImpliedRolesProvider impliedRolesProvider, BusinessUnitManager businessUnitManager, SecurityManager securityManager, QueryBuilderFactory queryBuilderFactory)
-
-
Method Details
-
getAnonymousPrincipal
- Specified by:
getAnonymousPrincipal
in interfacePrincipalManager
-
getPrincipal
Description copied from interface:PrincipalManager
Returns the principal from the underlying store. ThewithRoles
argument specifies whether the principal's roles should also be loaded.- Specified by:
getPrincipal
in interfacePrincipalManager
-
getRole
- Specified by:
getRole
in interfacePrincipalManager
-
getAllRoles
- Specified by:
getAllRoles
in interfacePrincipalManager
-
getRolesFor
Creates a query to retrieve all roles for a principal according to the business unit currently on the thread. Roles assigned to a principal with a login role having no related business unit are loaded regardless of the current business unit.- Specified by:
getRolesFor
in interfacePrincipalManager
-
setNewPassword
Description copied from interface:PrincipalService
Sets new password and required-flag.- Specified by:
setNewPassword
in interfacePrincipalService
- Parameters:
username
- the name of the principal to set new password tonewPassword
- the new password to setresetRequired
- value of require-new-password flag
-
setTemporaryPassword
Description copied from interface:PrincipalService
Sets thetemporary_password
for the given principal, which will be valid for login as well until it expires based on thelast_password_dispatch
.- Specified by:
setTemporaryPassword
in interfacePrincipalService
- Parameters:
username
- the name of the principalnewPassword
- thetemporary_password
-
resetTemporaryPassword
Description copied from interface:PrincipalService
Invalidates the state of the temporary password request mechanism, resettingtemporary_password
tonull
and setting the flag requiring a new password after login tofalse
.- Specified by:
resetTemporaryPassword
in interfacePrincipalService
- Parameters:
username
- the name of the principal to modify
-
updatePrincipalFields
- Specified by:
updatePrincipalFields
in interfacePrincipalService
-
resetPrincipalFields
- Specified by:
resetPrincipalFields
in interfacePrincipalService
-
updatePrincipalFields
- Specified by:
updatePrincipalFields
in interfacePrincipalService
-
resetPrincipalFields
- Specified by:
resetPrincipalFields
in interfacePrincipalService
-
getPrincipalDetails
@Nullable public @Nullable PrincipalDetails getPrincipalDetails(String username, Object credentials) Description copied from interface:PrincipalDetailService
Return details of the user specified by username.- Specified by:
getPrincipalDetails
in interfacePrincipalDetailService
-
getCurrentPrincipal
- Specified by:
getCurrentPrincipal
in interfacePrincipalService
-
getCurrentUser
- Specified by:
getCurrentUser
in interfacePrincipalService
-
getPrincipalEntity
- Specified by:
getPrincipalEntity
in interfacePrincipalService
-
getUserEntity
- Specified by:
getUserEntity
in interfacePrincipalService
-
loginNewlyCreatedUser
Description copied from interface:PrincipalService
Logs in a (newly created) user. Takes the related principal (only supported with one principal!). For example used in flows where new users (and thus logins) are created. Use with care!- Specified by:
loginNewlyCreatedUser
in interfacePrincipalService
-
loginUser
Description copied from interface:PrincipalService
Logs in a user by username. Use with care!- Specified by:
loginUser
in interfacePrincipalService
-
createUniqueUsernames
Description copied from interface:PrincipalService
Creates a uniqueusername
. Based on theUser
's email or firstname and lastname.- Specified by:
createUniqueUsernames
in interfacePrincipalService
-
updateTwoFactorData
- Specified by:
updateTwoFactorData
in interfacePrincipalManager
-