KEYCLOAK-7943 NPE when SAML User Property mapper is empty
This commit is contained in:
parent
9e072cb174
commit
59082e0b5f
2 changed files with 10 additions and 4 deletions
|
@ -77,9 +77,11 @@ public class UserPropertyMapper extends AbstractOIDCProtocolMapper implements OI
|
|||
}
|
||||
|
||||
protected void setClaim(IDToken token, ProtocolMapperModel mappingModel, UserSessionModel userSession) {
|
||||
|
||||
UserModel user = userSession.getUser();
|
||||
String propertyName = mappingModel.getConfig().get(ProtocolMapperUtils.USER_ATTRIBUTE);
|
||||
|
||||
if (propertyName == null || propertyName.trim().isEmpty()) return;
|
||||
|
||||
String propertyValue = ProtocolMapperUtils.getUserModelValue(user, propertyName);
|
||||
OIDCAttributeMapperHelper.mapClaim(token, mappingModel, propertyValue);
|
||||
}
|
||||
|
|
|
@ -79,10 +79,14 @@ public class UserPropertyAttributeStatementMapper extends AbstractSAMLProtocolMa
|
|||
public void transformAttributeStatement(AttributeStatementType attributeStatement, ProtocolMapperModel mappingModel, KeycloakSession session, UserSessionModel userSession, AuthenticatedClientSessionModel clientSession) {
|
||||
UserModel user = userSession.getUser();
|
||||
String propertyName = mappingModel.getConfig().get(ProtocolMapperUtils.USER_ATTRIBUTE);
|
||||
String propertyValue = ProtocolMapperUtils.getUserModelValue(user, propertyName);
|
||||
if (propertyValue == null) return;
|
||||
AttributeStatementHelper.addAttribute(attributeStatement, mappingModel, propertyValue);
|
||||
|
||||
if (propertyName == null || propertyName.trim().isEmpty()) return;
|
||||
|
||||
String propertyValue = ProtocolMapperUtils.getUserModelValue(user, propertyName);
|
||||
|
||||
if (propertyValue == null) return;
|
||||
|
||||
AttributeStatementHelper.addAttribute(attributeStatement, mappingModel, propertyValue);
|
||||
}
|
||||
|
||||
public static ProtocolMapperModel createAttributeMapper(String name, String userAttribute,
|
||||
|
|
Loading…
Reference in a new issue