【发布时间】:2016-02-14 03:41:25
【问题描述】:
我正在使用 Spring Security SAML 1.0.1,我想知道名为“eduPersonAffiliation”的 SAML 属性的值。我编写了一个实现org.springframework.security.saml.userdetails.SAMLUserDetailsService 接口和loadUserBySAML 方法的类,我正在这样做:
@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);
}
getUser 方法需要一个字符串,该字符串应该是已连接用户的登录名。这个问题听起来很愚蠢,但我怎样才能访问给定属性名称的属性值?我看到一个返回List<XMLObject> 的org.opensaml.saml2.core.getAttributeValues 方法。怎么用?
谢谢!
【问题讨论】:
标签: java spring-security spring-saml