add support for number and boolean claims in ClaimToUserSessionNoteMapper

Closes #45022
This commit is contained in:
Diego Ramp 2025-12-19 10:13:47 +01:00
parent 7be37f1e0d
commit dfd0d9daf0

View file

@ -110,20 +110,9 @@ public class ClaimToUserSessionNoteMapper extends AbstractClaimMapper {
Boolean.parseBoolean(mapperModel.getConfig().get(ARE_CLAIM_VALUES_REGEX_PROPERTY_NAME));
for (Map.Entry<String, List<String>> claim : claims.entrySet()) {
Object claimValueObj = getClaimValue(context, claim.getKey());
for (String value : claim.getValue()) {
if (claimValueObj != null) {
if (!(claimValueObj instanceof String)) {
LOG.warnf(
"Claim '%s' does not contain a string value for user with brokerUserId '%s'. "
+ "Actual value is of type '%s': %s",
claim.getKey(),
context.getBrokerUserId(), claimValueObj.getClass(), claimValueObj);
continue;
}
String claimValue = (String) claimValueObj;
String claimValue = getStringCompatibleClaimValue(context, claim.getKey());
if (claimValue != null) {
for (String value : claim.getValue()) {
boolean claimValuesMatch = areClaimValuesRegex ? valueMatchesRegex(value, claimValue)
: valueEquals(value, claimValue);
@ -135,4 +124,17 @@ public class ClaimToUserSessionNoteMapper extends AbstractClaimMapper {
}
}
private String getStringCompatibleClaimValue(BrokeredIdentityContext context, String key) {
Object claimValueObj = getClaimValue(context, key);
if (claimValueObj instanceof String || claimValueObj instanceof Number || claimValueObj instanceof Boolean) {
return claimValueObj.toString();
}
LOG.warnf(
"Claim '%s' does not contain a string-compatible (String/Number/Boolean) value for user with brokerUserId '%s'. "
+ "Actual value is of type '%s': %s",
key,
context.getBrokerUserId(), claimValueObj.getClass(), claimValueObj);
return null;
}
}