Skip to content

Commit

Permalink
fix to return a single value from pac4j for certain attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
jj committed Sep 9, 2021
1 parent 11664ec commit 1609b6c
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,26 @@ public BetterSAML2Profile(final SimpleProfileMapping simpleProfileMapping) {
this.profileMapping = simpleProfileMapping;
}

private String getSingleAttributeValue(Object attribute) {
if (attribute instanceof Collection) {
return (String) ((Collection)attribute).toArray()[0];
}
return (String) attribute;
}

@Override
public String getEmail() {
return (String) getAttribute(profileMapping.getEmail());
return getSingleAttributeValue(getAttribute(profileMapping.getEmail()));
}

@Override
public String getFamilyName() {
return (String) getAttribute(profileMapping.getLastName());
return getSingleAttributeValue(getAttribute(profileMapping.getLastName()));
}

@Override
public String getFirstName() {
return (String) getAttribute(profileMapping.getFirstName());
return getSingleAttributeValue(getAttribute(profileMapping.getFirstName()));
}

public List<String> getGroups() {
Expand All @@ -42,4 +49,4 @@ public String getUsername() {
}
}

}
}

0 comments on commit 1609b6c

Please sign in to comment.