本文整理汇总了Java中org.springframework.security.openid.OpenIDAuthenticationToken.getAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java OpenIDAuthenticationToken.getAttributes方法的具体用法?Java OpenIDAuthenticationToken.getAttributes怎么用?Java OpenIDAuthenticationToken.getAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.security.openid.OpenIDAuthenticationToken
的用法示例。
在下文中一共展示了OpenIDAuthenticationToken.getAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTemporaryUser
import org.springframework.security.openid.OpenIDAuthenticationToken; //导入方法依赖的package包/类
private User createTemporaryUser(OpenIDAuthenticationToken token,
final String openId) {
final List<OpenIDAttribute> attributes = token.getAttributes();
String email = null;
String firstName = null;
String lastName = null;
String displayName = null;
for (OpenIDAttribute attribute : attributes) {
if ("email".equals(attribute.getName())
&& !attribute.getValues().isEmpty()) {
email = attribute.getValues().get(0);
} else if ("firstname".equals(attribute.getName())
&& !attribute.getValues().isEmpty()) {
firstName = attribute.getValues().get(0);
} else if ("lastname".equals(attribute.getName())
&& !attribute.getValues().isEmpty()) {
lastName = attribute.getValues().get(0);
} else if ("fullname".equals(attribute.getName())
&& !attribute.getValues().isEmpty()) {
displayName = attribute.getValues().get(0);
}
}
User user = new UserImpl();
String username = StringUtils.substringAfter(openId, "://").replace("/", "");
if (username.length() > 35) {
username = username.substring(0, 35);
}
if (displayName == null && firstName != null && lastName != null) {
displayName = firstName + " " + lastName;
}
user.setUsername(username);
user.setEmail(email);
user.setGivenName(firstName);
user.setFamilyName(lastName);
user.setDisplayName(displayName);
user.setOpenId(openId);
return user;
}
示例2: setUpEmailAddress
import org.springframework.security.openid.OpenIDAuthenticationToken; //导入方法依赖的package包/类
private String setUpEmailAddress(OpenIDAuthenticationToken openIdAuthenticationToken) {
for (OpenIDAttribute openIDAttribute : openIdAuthenticationToken.getAttributes()) {
if (setContainsAndAttributeHasValue(emailAddressAttributeNames, openIDAttribute)) {
return openIDAttribute.getValues().get(0);
}
}
return null;
}
示例3: getAttributeValue
import org.springframework.security.openid.OpenIDAuthenticationToken; //导入方法依赖的package包/类
private String getAttributeValue(OpenIDAuthenticationToken openIdAuthenticationToken, Set<String> stringSet) {
for (OpenIDAttribute openIDAttribute : openIdAuthenticationToken.getAttributes()) {
if (attributeHasValue(openIDAttribute)) {
if (stringSet.contains(openIDAttribute.getName())) {
return openIDAttribute.getValues().get(0);
}
}
}
return null;
}