本文整理匯總了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();
}