I'm using Spring Security SAML 1.0.1, and I want to know the value of the SAML attribute whose name is "eduPersonAffiliation". I've coded a class which implements the org.springframework.security.saml.userdetails.SAMLUserDetailsService
interface and in the loadUserBySAML
method, I'm doing this:
@Override
public Object loadUserBySAML(SAMLCredential credential) throws UsernameNotFoundException {
String eduPersonAffiliationAttributeName = "";
// We need to use the "name" of the attribute to retrieve the value (not the friendly name)
for (Attribute attribute : credential.getAttributes()) {
if ("eduPersonAffiliation".equals(attribute.getFriendlyName())) {
eduPersonAffiliationAttributeName = attribute.getName();
}
}
Person user = usersService.getUser(
credential.getAttribute(eduPersonAffiliationAttributeName).WHAT_TO_CALL_HERE?);
return loadUserByUser(user);
}
The getUser
method expects a String which should be the login of the connected user. The question sounds stupid but how can I access the attribute value given the attribute name? I see a org.opensaml.saml2.core.getAttributeValues
method that returns a List<XMLObject>
. How to use it?
Thanks!