keycloak-service
公開メンバ関数 | 静的公開メンバ関数 | 静的公開変数類 | 静的限定公開メンバ関数 | 静的限定公開変数類 | 静的関数 | 静的非公開変数類 | 全メンバ一覧
org.keycloak.social.microsoft.MicrosoftUserAttributeMapper クラス
org.keycloak.social.microsoft.MicrosoftUserAttributeMapper の継承関係図
Inheritance graph
org.keycloak.social.microsoft.MicrosoftUserAttributeMapper 連携図
Collaboration graph

公開メンバ関数

String [] getCompatibleProviders ()
 
String getId ()
 
List< ProviderConfigProperty > getConfigProperties ()
 
String getDisplayCategory ()
 
String getDisplayType ()
 
String getHelpText ()
 
void preprocessFederatedIdentity (KeycloakSession session, RealmModel realm, IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)
 
void updateBrokeredUser (KeycloakSession session, RealmModel realm, UserModel user, IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)
 

静的公開メンバ関数

static void storeUserProfileForMapper (BrokeredIdentityContext user, JsonNode profile, String provider)
 
static Object getJsonValue (JsonNode baseNode, String fieldPath)
 

静的公開変数類

static final String CONF_JSON_FIELD = "jsonField"
 
static final String CONF_USER_ATTRIBUTE = "userAttribute"
 
static final String CONTEXT_JSON_NODE = OIDCIdentityProvider.USER_INFO
 

静的限定公開メンバ関数

static Object getJsonValue (IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)
 

静的限定公開変数類

static final Logger logger = Logger.getLogger(AbstractJsonUserAttributeMapper.class)
 
static final Logger LOGGER_DUMP_USER_PROFILE = Logger.getLogger("org.keycloak.social.user_profile_dump")
 

静的関数

 [static initializer]
 

静的非公開変数類

static final String [] cp = new String[] { MicrosoftIdentityProviderFactory.PROVIDER_ID }
 

詳解

User attribute mapper.

著者
Vlastimil Elias (velias at redhat dot com)

関数詳解

◆ [static initializer]()

org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper.[static initializer] ( )
inlinestaticpackageinherited

◆ getCompatibleProviders()

String [] org.keycloak.social.microsoft.MicrosoftUserAttributeMapper.getCompatibleProviders ( )
inline
31  {
32  return cp;
33  }
static final String [] cp
Definition: MicrosoftUserAttributeMapper.java:28

◆ getConfigProperties()

List<ProviderConfigProperty> org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper.getConfigProperties ( )
inlineinherited
100  {
101  return configProperties;
102  }
static final List< ProviderConfigProperty > configProperties
Definition: AbstractJsonUserAttributeMapper.java:64

◆ getDisplayCategory()

String org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper.getDisplayCategory ( )
inlineinherited
105  {
106  return "Attribute Importer";
107  }

◆ getDisplayType()

String org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper.getDisplayType ( )
inlineinherited
110  {
111  return "Attribute Importer";
112  }

◆ getHelpText()

String org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper.getHelpText ( )
inlineinherited
115  {
116  return "Import user profile information if it exists in Social provider JSON data into the specified user attribute.";
117  }

◆ getId()

String org.keycloak.social.microsoft.MicrosoftUserAttributeMapper.getId ( )
inline
36  {
37  return "microsoft-user-attribute-mapper";
38  }

◆ getJsonValue() [1/2]

static Object org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper.getJsonValue ( IdentityProviderMapperModel  mapperModel,
BrokeredIdentityContext  context 
)
inlinestaticprotectedinherited
143  {
144 
145  String jsonField = mapperModel.getConfig().get(CONF_JSON_FIELD);
146  if (jsonField == null || jsonField.trim().isEmpty()) {
147  logger.warnf("JSON field path is not configured for mapper %s", mapperModel.getName());
148  return null;
149  }
150  jsonField = jsonField.trim();
151 
152  if (jsonField.startsWith(JSON_PATH_DELIMITER) || jsonField.endsWith(JSON_PATH_DELIMITER) || jsonField.startsWith("[")) {
153  logger.warnf("JSON field path is invalid %s", jsonField);
154  return null;
155  }
156 
157  JsonNode profileJsonNode = (JsonNode) context.getContextData().get(CONTEXT_JSON_NODE);
158 
159  Object value = getJsonValue(profileJsonNode, jsonField);
160 
161  if (value == null) {
162  logger.debugf("User profile JSON value '%s' is not available.", jsonField);
163  }
164 
165  return value;
166  }
static Object getJsonValue(IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)
Definition: AbstractJsonUserAttributeMapper.java:143
static final String CONTEXT_JSON_NODE
Definition: AbstractJsonUserAttributeMapper.java:62
static final String CONF_JSON_FIELD
Definition: AbstractJsonUserAttributeMapper.java:53
static final String JSON_PATH_DELIMITER
Definition: AbstractJsonUserAttributeMapper.java:48
static final Logger logger
Definition: AbstractJsonUserAttributeMapper.java:44

◆ getJsonValue() [2/2]

static Object org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper.getJsonValue ( JsonNode  baseNode,
String  fieldPath 
)
inlinestaticinherited
168  {
169  logger.debug("Going to process JsonNode path " + fieldPath + " on data " + baseNode);
170  if (baseNode != null) {
171 
172  int idx = fieldPath.indexOf(JSON_PATH_DELIMITER);
173 
174  String currentFieldName = fieldPath;
175  if (idx > 0) {
176  currentFieldName = fieldPath.substring(0, idx).trim();
177  if (currentFieldName.isEmpty()) {
178  logger.debug("JSON path is invalid " + fieldPath);
179  return null;
180  }
181  }
182 
183  String currentNodeName = currentFieldName;
184  int arrayIndex = -1;
185  if (currentFieldName.endsWith("]")) {
186  int bi = currentFieldName.indexOf("[");
187  if (bi == -1) {
188  logger.debug("Invalid array index construct in " + currentFieldName);
189  return null;
190  }
191  try {
192  String is = currentFieldName.substring(bi+1, currentFieldName.length() - 1).trim();
193  arrayIndex = Integer.parseInt(is);
194  } catch (Exception e) {
195  logger.debug("Invalid array index construct in " + currentFieldName);
196  return null;
197  }
198  currentNodeName = currentFieldName.substring(0,bi).trim();
199  }
200 
201  JsonNode currentNode = baseNode.get(currentNodeName);
202  if (arrayIndex > -1 && currentNode.isArray()) {
203  logger.debug("Going to take array node at index " + arrayIndex);
204  currentNode = currentNode.get(arrayIndex);
205  }
206 
207  if (currentNode == null) {
208  logger.debug("JsonNode not found for name " + currentFieldName);
209  return null;
210  }
211 
212  if (idx < 0) {
213  if (currentNode.isArray()) {
214  List<String> values = new ArrayList<>();
215  for (JsonNode childNode : currentNode) {
216  if (childNode.isTextual()) {
217  values.add(childNode.textValue());
218  } else {
219  logger.warn("JsonNode in array is not text value " + childNode);
220  }
221  }
222  if (values.isEmpty()) {
223  return null;
224  }
225  return arrayIndex == idx? values : null;
226  }
227  if (!currentNode.isValueNode() || currentNode.isNull()) {
228  logger.debug("JsonNode is not value node for name " + currentFieldName);
229  return null;
230  }
231  String ret = currentNode.asText();
232  if (ret != null && !ret.trim().isEmpty())
233  return ret.trim();
234  } else {
235  return getJsonValue(currentNode, fieldPath.substring(idx + 1));
236  }
237  }
238  return null;
239  }
static Object getJsonValue(IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)
Definition: AbstractJsonUserAttributeMapper.java:143
static final String JSON_PATH_DELIMITER
Definition: AbstractJsonUserAttributeMapper.java:48
static final Logger logger
Definition: AbstractJsonUserAttributeMapper.java:44

◆ preprocessFederatedIdentity()

void org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper.preprocessFederatedIdentity ( KeycloakSession  session,
RealmModel  realm,
IdentityProviderMapperModel  mapperModel,
BrokeredIdentityContext  context 
)
inlineinherited
120  {
121  String attribute = mapperModel.getConfig().get(CONF_USER_ATTRIBUTE);
122  if (attribute == null || attribute.trim().isEmpty()) {
123  logger.warnf("Attribute is not configured for mapper %s", mapperModel.getName());
124  return;
125  }
126  attribute = attribute.trim();
127 
128  Object value = getJsonValue(mapperModel, context);
129  if (value != null) {
130  if (value instanceof List) {
131  context.setUserAttribute(attribute, (List<String>) value);
132  } else {
133  context.setUserAttribute(attribute, value.toString());
134  }
135  }
136  }
static Object getJsonValue(IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)
Definition: AbstractJsonUserAttributeMapper.java:143
static final String CONF_USER_ATTRIBUTE
Definition: AbstractJsonUserAttributeMapper.java:57
static final Logger logger
Definition: AbstractJsonUserAttributeMapper.java:44

◆ storeUserProfileForMapper()

static void org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper.storeUserProfileForMapper ( BrokeredIdentityContext  user,
JsonNode  profile,
String  provider 
)
inlinestaticinherited

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.

引数
usercontext to store profile data into
profileto store into context
provideridentification of social provider to be used in log dump
参照
preprocessFederatedIdentity(KeycloakSession, RealmModel, IdentityProviderMapperModel, BrokeredIdentityContext)
BrokeredIdentityContext::getContextData()
93  {
94  user.getContextData().put(AbstractJsonUserAttributeMapper.CONTEXT_JSON_NODE, profile);
95  if (LOGGER_DUMP_USER_PROFILE.isDebugEnabled())
96  LOGGER_DUMP_USER_PROFILE.debug("User Profile JSON Data for provider "+provider+": " + profile);
97  }
static final Logger LOGGER_DUMP_USER_PROFILE
Definition: AbstractJsonUserAttributeMapper.java:46

◆ updateBrokeredUser()

void org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper.updateBrokeredUser ( KeycloakSession  session,
RealmModel  realm,
UserModel  user,
IdentityProviderMapperModel  mapperModel,
BrokeredIdentityContext  context 
)
inlineinherited
139  {
140  // we do not update user profile from social provider
141  }

メンバ詳解

◆ CONF_JSON_FIELD

final String org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper.CONF_JSON_FIELD = "jsonField"
staticinherited

Config param where name of mapping source JSON User Profile field is stored.

◆ CONF_USER_ATTRIBUTE

final String org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper.CONF_USER_ATTRIBUTE = "userAttribute"
staticinherited

Config param where name of mapping target USer attribute is stored.

◆ CONTEXT_JSON_NODE

final String org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper.CONTEXT_JSON_NODE = OIDCIdentityProvider.USER_INFO
staticinherited

Key in BrokeredIdentityContext#getContextData() where JsonNode with user profile is stored.

◆ cp

final String [] org.keycloak.social.microsoft.MicrosoftUserAttributeMapper.cp = new String[] { MicrosoftIdentityProviderFactory.PROVIDER_ID }
staticprivate

◆ logger

final Logger org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper.logger = Logger.getLogger(AbstractJsonUserAttributeMapper.class)
staticprotectedinherited

◆ LOGGER_DUMP_USER_PROFILE

final Logger org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper.LOGGER_DUMP_USER_PROFILE = Logger.getLogger("org.keycloak.social.user_profile_dump")
staticprotectedinherited

このクラス詳解は次のファイルから抽出されました: