Skip to content

Commit

Permalink
[JENKINS-71322] NPE on non existing SAML Attribute (#345)
Browse files Browse the repository at this point in the history
* fix: NPE processing custom attributes

* Update src/main/java/org/jenkinsci/plugins/saml/SamlSecurityRealm.java
  • Loading branch information
kuisathaverat authored May 31, 2023
1 parent 51bd50a commit dfa7489
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,12 @@ private boolean modifyUserSamlCustomAttributes(User user, SAML2Profile profile)
for (AttributeEntry attributeEntry : getSamlCustomAttributes()) {
if(attributeEntry instanceof Attribute){
Attribute attr = (Attribute) attributeEntry;
SamlCustomProperty.Attribute item = new SamlCustomProperty.Attribute(attr.getName(),attr.getDisplayName());
item.setValue(profile.getAttribute(attr.getName()).toString());
userProperty.getAttributes().add(item);
Object attrValue = profile.getAttribute(attr.getName());
if (attrValue != null) {
SamlCustomProperty.Attribute item = new SamlCustomProperty.Attribute(attr.getName(),attr.getDisplayName());
item.setValue(attrValue.toString());
userProperty.getAttributes().add(item);
}
}
}
try {
Expand Down

0 comments on commit dfa7489

Please sign in to comment.