org.keycloak.broker.saml.mappers

## Class AbstractAttributeToRoleMapper

- java.lang.Object
- - org.keycloak.broker.provider.AbstractIdentityProviderMapper
  - - org.keycloak.broker.saml.mappers.AbstractAttributeToRoleMapper

- All Implemented Interfaces:
    IdentityProviderMapper, ConfiguredProvider, Provider, ProviderFactory<IdentityProviderMapper>
  Direct Known Subclasses:
    AdvancedAttributeToRoleMapper, AttributeToRoleMapper

      public abstract class AbstractAttributeToRoleMapper
      extends AbstractIdentityProviderMapper

  Abstract class that handles the logic for importing and updating brokered users for all mappers that map a SAML attribute into a `Keycloak` role.
  Author:
    Stefan Guilhen

- - ### Field Summary

    - ### Fields inherited from interface org.keycloak.broker.provider.IdentityProviderMapper

      `ANY_PROVIDER, DEFAULT_IDENTITY_PROVIDER_MAPPER_SYNC_MODES`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractAttributeToRoleMapper()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract boolean` | `applies(IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)` This method must be implemented by subclasses and they must return `true` if their mapping can be applied (i.e.
    `void` | `importNewUser(KeycloakSession session, RealmModel realm, UserModel user, IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)` Called after UserModel is created for first time for this user.
    `void` | `updateBrokeredUser(KeycloakSession session, RealmModel realm, UserModel user, IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)` Called when this user has logged in before and has already been imported.

    - ### Methods inherited from class org.keycloak.broker.provider.AbstractIdentityProviderMapper

      `close, create, init, postInit, preprocessFederatedIdentity, updateBrokeredUserLegacy`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.keycloak.broker.provider.IdentityProviderMapper

      `getCompatibleProviders, getDisplayCategory, getDisplayType, supportsSyncMode`

    - ### Methods inherited from interface org.keycloak.provider.ProviderFactory

      `getId, order`

    - ### Methods inherited from interface org.keycloak.provider.ConfiguredProvider

      `getConfigProperties, getHelpText`

- - ### Constructor Detail

    - #### AbstractAttributeToRoleMapper

          public AbstractAttributeToRoleMapper()

  - ### Method Detail

    - #### importNewUser

          public void importNewUser(KeycloakSession session,
                                    RealmModel realm,
                                    UserModel user,
                                    IdentityProviderMapperModel mapperModel,
                                    BrokeredIdentityContext context)

      Description copied from interface: `IdentityProviderMapper`
      Called after UserModel is created for first time for this user. Called after "FirstBrokerLogin" flow
      Specified by:
        `importNewUser` in interface `IdentityProviderMapper`
      Overrides:
        `importNewUser` in class `AbstractIdentityProviderMapper`

    - #### updateBrokeredUser

          public void updateBrokeredUser(KeycloakSession session,
                                         RealmModel realm,
                                         UserModel user,
                                         IdentityProviderMapperModel mapperModel,
                                         BrokeredIdentityContext context)

      Description copied from interface: `IdentityProviderMapper`
      Called when this user has logged in before and has already been imported.
      Specified by:
        `updateBrokeredUser` in interface `IdentityProviderMapper`
      Overrides:
        `updateBrokeredUser` in class `AbstractIdentityProviderMapper`

    - #### applies

          protected abstract boolean applies(IdentityProviderMapperModel mapperModel,
                                             BrokeredIdentityContext context)

      This method must be implemented by subclasses and they must return `true` if their mapping can be applied (i.e. user has the SAML attribute that should be mapped) or `false` otherwise.
      Parameters:
        `mapperModel` - a reference to the `IdentityProviderMapperModel`.
        `context` - a reference to the `BrokeredIdentityContext`.
      Returns:
        `true` if the mapping can be applied or `false` otherwise.

Copyright © 2021 JBoss by Red Hat. All rights reserved.