Package io.jmix.oidc.usermapper
Class SynchronizingOidcUserMapper<T extends JmixOidcUser>
java.lang.Object
io.jmix.oidc.usermapper.BaseOidcUserMapper<T>
io.jmix.oidc.usermapper.SynchronizingOidcUserMapper<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
OidcUserMapper<T>
public abstract class SynchronizingOidcUserMapper<T extends JmixOidcUser>
extends BaseOidcUserMapper<T>
Implementation of the
OidcUserMapper
that not only maps the external user object to the persistent user
entity, but also stores the user and optionally their role assignment to the database.-
Field Summary
Modifier and TypeFieldDescriptionprotected ClaimsRolesMapper
protected UnconstrainedDataManager
protected boolean
protected UserRepository
-
Constructor Summary
ConstructorDescriptionSynchronizingOidcUserMapper
(UnconstrainedDataManager dataManager, UserRepository userRepository, ClaimsRolesMapper claimsRolesMapper) -
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<RoleAssignmentEntity>
buildRoleAssignmentEntities
(String username, Collection<? extends org.springframework.security.core.GrantedAuthority> grantedAuthorities) Returns a class of the user used by the application.protected String
getOidcUserUsername
(org.springframework.security.oauth2.core.oidc.user.OidcUser oidcUser) Extracts username from theoidcUser
protected T
initJmixUser
(org.springframework.security.oauth2.core.oidc.user.OidcUser oidcUser) Method returns an instance of Jmix user, which may be either a new instance or an instance loaded from the user repository.boolean
protected void
performAdditionalModifications
(org.springframework.security.oauth2.core.oidc.user.OidcUser oidcUser, T jmixUser) Performs additional modifications of Jmix user instance.protected void
populateUserAuthorities
(org.springframework.security.oauth2.core.oidc.user.OidcUser oidcUser, T jmixUser) Fills authorities ofjmixUser
based on information from theoidcUser
protected void
saveJmixUserAndRoleAssignments
(org.springframework.security.oauth2.core.oidc.user.OidcUser oidcUser, T jmixUser) void
setSynchronizeRoleAssignments
(boolean synchronizeRoleAssignments) Enables role assignment entities synchronization.Methods inherited from class io.jmix.oidc.usermapper.BaseOidcUserMapper
populateUserAttributes, toJmixUser
-
Field Details
-
dataManager
-
userRepository
-
claimsRolesMapper
-
synchronizeRoleAssignments
protected boolean synchronizeRoleAssignments
-
-
Constructor Details
-
SynchronizingOidcUserMapper
public SynchronizingOidcUserMapper(UnconstrainedDataManager dataManager, UserRepository userRepository, ClaimsRolesMapper claimsRolesMapper)
-
-
Method Details
-
getApplicationUserClass
Returns a class of the user used by the application. This user is set to the security context. -
getOidcUserUsername
protected String getOidcUserUsername(org.springframework.security.oauth2.core.oidc.user.OidcUser oidcUser) Extracts username from theoidcUser
-
initJmixUser
Description copied from class:BaseOidcUserMapper
Method returns an instance of Jmix user, which may be either a new instance or an instance loaded from the user repository. Attributes and authorities will lately be filled in other methods. The responsibility of the current method is just to create or load an existing instance.- Specified by:
initJmixUser
in classBaseOidcUserMapper<T extends JmixOidcUser>
- Parameters:
oidcUser
- OpenID user- Returns:
- new Jmix user instance or Jmix user loaded from user repository
-
populateUserAuthorities
protected void populateUserAuthorities(org.springframework.security.oauth2.core.oidc.user.OidcUser oidcUser, T jmixUser) Description copied from class:BaseOidcUserMapper
Fills authorities ofjmixUser
based on information from theoidcUser
- Specified by:
populateUserAuthorities
in classBaseOidcUserMapper<T extends JmixOidcUser>
-
performAdditionalModifications
protected void performAdditionalModifications(org.springframework.security.oauth2.core.oidc.user.OidcUser oidcUser, T jmixUser) Description copied from class:BaseOidcUserMapper
Performs additional modifications of Jmix user instance. Override this method in case you want to do some additional attribute values computations or if you want to do some operations with Jmix user instance, e.g. to store it in the database, like it is done in theSynchronizingOidcUserMapper
- Overrides:
performAdditionalModifications
in classBaseOidcUserMapper<T extends JmixOidcUser>
-
saveJmixUserAndRoleAssignments
protected void saveJmixUserAndRoleAssignments(org.springframework.security.oauth2.core.oidc.user.OidcUser oidcUser, T jmixUser) -
buildRoleAssignmentEntities
protected Collection<RoleAssignmentEntity> buildRoleAssignmentEntities(String username, Collection<? extends org.springframework.security.core.GrantedAuthority> grantedAuthorities) -
setSynchronizeRoleAssignments
public void setSynchronizeRoleAssignments(boolean synchronizeRoleAssignments) Enables role assignment entities synchronization. If true then role assignment entities will be stored to the database. -
isSynchronizeRoleAssignments
public boolean isSynchronizeRoleAssignments()
-