org.keycloak.broker.oidc.mappers

## Class AbstractJsonUserAttributeMapper

- java.lang.Object
- - org.keycloak.broker.provider.AbstractIdentityProviderMapper
  - - org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper

- All Implemented Interfaces:
    IdentityProviderMapper, ConfiguredProvider, Provider, ProviderFactory<IdentityProviderMapper>
  Direct Known Subclasses:
    FacebookUserAttributeMapper, GitHubUserAttributeMapper, GoogleUserAttributeMapper, LinkedInUserAttributeMapper, MicrosoftUserAttributeMapper, StackoverflowUserAttributeMapper

      public abstract class AbstractJsonUserAttributeMapper
      extends AbstractIdentityProviderMapper

  Abstract class for Social Provider mappers which allow mapping of JSON user profile field into Keycloak user attribute. Concrete mapper classes with own ID and provider mapping must be implemented for each social provider who uses `JsonNode` user profile.
  Author:
    Vlastimil Elias (velias at redhat dot com)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CONF_JSON_FIELD` Config param where name of mapping source JSON User Profile field is stored.
    `static String` | `CONF_USER_ATTRIBUTE` Config param where name of mapping target USer attribute is stored.
    `static String` | `CONTEXT_JSON_NODE` Key in `BrokeredIdentityContext.getContextData()` where `JsonNode` with user profile is stored.
    `protected static org.jboss.logging.Logger` | `logger`
    `protected static org.jboss.logging.Logger` | `LOGGER_DUMP_USER_PROFILE`

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

      `ANY_PROVIDER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractJsonUserAttributeMapper()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<ProviderConfigProperty>` | `getConfigProperties()`
    `String` | `getDisplayCategory()`
    `String` | `getDisplayType()`
    `String` | `getHelpText()`
    `protected static String` | `getJsonValue(IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)`
    `static String` | `getJsonValue(com.fasterxml.jackson.databind.JsonNode baseNode, String fieldPath)`
    `void` | `preprocessFederatedIdentity(KeycloakSession session, RealmModel realm, IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)` Called to determine what keycloak username and email to use to process the login request from the external IDP.
    `static void` | `storeUserProfileForMapper(BrokeredIdentityContext user, com.fasterxml.jackson.databind.JsonNode profile, String provider)` Store used profile JsonNode into user context for later use by this mapper.
    `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, importNewUser, init, postInit`

    - ### 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`

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

      `getId`

- - ### Field Detail

    - #### logger

          protected static final org.jboss.logging.Logger logger

    - #### LOGGER_DUMP_USER_PROFILE

          protected static final org.jboss.logging.Logger LOGGER_DUMP_USER_PROFILE

    - #### CONF_JSON_FIELD

          public static final String CONF_JSON_FIELD

      Config param where name of mapping source JSON User Profile field is stored.
      See Also:
        Constant Field Values

    - #### CONF_USER_ATTRIBUTE

          public static final String CONF_USER_ATTRIBUTE

      Config param where name of mapping target USer attribute is stored.
      See Also:
        Constant Field Values

    - #### CONTEXT_JSON_NODE

          public static final String CONTEXT_JSON_NODE

      Key in `BrokeredIdentityContext.getContextData()` where `JsonNode` with user profile is stored.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### AbstractJsonUserAttributeMapper

          public AbstractJsonUserAttributeMapper()

  - ### Method Detail

    - #### storeUserProfileForMapper

          public static void storeUserProfileForMapper(BrokeredIdentityContext user,
                                                       com.fasterxml.jackson.databind.JsonNode profile,
                                                       String provider)

      Store used profile JsonNode into user context for later use by this mapper. Profile data are dumped into special logger if enabled also to allow investigation of the structure.
      Parameters:
        `user` - context to store profile data into
        `profile` - to store into context
        `provider` - identification of social provider to be used in log dump
      See Also:
        `preprocessFederatedIdentity(KeycloakSession, RealmModel, IdentityProviderMapperModel, BrokeredIdentityContext)`, `BrokeredIdentityContext.getContextData()`

    - #### getConfigProperties

          public List<ProviderConfigProperty> getConfigProperties()

    - #### getDisplayCategory

          public String getDisplayCategory()

    - #### getDisplayType

          public String getDisplayType()

    - #### getHelpText

          public String getHelpText()

    - #### preprocessFederatedIdentity

          public void preprocessFederatedIdentity(KeycloakSession session,
                                                  RealmModel realm,
                                                  IdentityProviderMapperModel mapperModel,
                                                  BrokeredIdentityContext context)

      Description copied from interface: `IdentityProviderMapper`
      Called to determine what keycloak username and email to use to process the login request from the external IDP. It's called before "FirstBrokerLogin" flow, so can be used to map attributes to BrokeredIdentityContext ( BrokeredIdentityContext.setUserAttribute ), which will be available on "Review Profile" page and in authenticators during FirstBrokerLogin flow
      Specified by:
        `preprocessFederatedIdentity` in interface `IdentityProviderMapper`
      Overrides:
        `preprocessFederatedIdentity` 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.

    - #### getJsonValue

          protected static String getJsonValue(IdentityProviderMapperModel mapperModel,
                                               BrokeredIdentityContext context)

    - #### getJsonValue

          public static String getJsonValue(com.fasterxml.jackson.databind.JsonNode baseNode,
                                            String fieldPath)

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