本文整理汇总了Java中org.springframework.security.oauth2.provider.OAuth2Authentication.getName方法的典型用法代码示例。如果您正苦于以下问题:Java OAuth2Authentication.getName方法的具体用法?Java OAuth2Authentication.getName怎么用?Java OAuth2Authentication.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.security.oauth2.provider.OAuth2Authentication
的用法示例。
在下文中一共展示了OAuth2Authentication.getName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enhance
import org.springframework.security.oauth2.provider.OAuth2Authentication; //导入方法依赖的package包/类
private Collection<OAuth2AccessToken> enhance(Collection<OAuth2AccessToken> tokens) {
Collection<OAuth2AccessToken> result = new ArrayList<OAuth2AccessToken>();
for (OAuth2AccessToken prototype : tokens) {
DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(prototype);
OAuth2Authentication authentication = tokenStore.readAuthentication(token);
if (authentication == null) {
continue;
}
String userName = authentication.getName();
if (StringUtils.isEmpty(userName)) {
userName = "Unknown";
}
Map<String, Object> map = new HashMap<String, Object>(token.getAdditionalInformation());
map.put("user_name", userName);
token.setAdditionalInformation(map);
result.add(token);
}
return result;
}
示例2: AuthenticationAccessToken
import org.springframework.security.oauth2.provider.OAuth2Authentication; //导入方法依赖的package包/类
/**
* Create a new OAuth2 Access Token holder.
*
* @param accessToken The Access Token.
* @param authentication The authentication.
* @param authenticationId The id of the authentication.
*/
public AuthenticationAccessToken(final OAuth2AccessToken accessToken,
final OAuth2Authentication authentication,
final String authenticationId) {
this.tokenId = accessToken.getValue();
this.accessToken = accessToken;
this.authenticationId = authenticationId;
this.userName = authentication.getName();
this.clientId = authentication.getOAuth2Request().getClientId();
this.authentication = authentication;
this.refreshToken = accessToken.getRefreshToken().getValue();
}