本文整理匯總了Java中org.springframework.security.oauth2.common.DefaultOAuth2AccessToken.setValue方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultOAuth2AccessToken.setValue方法的具體用法?Java DefaultOAuth2AccessToken.setValue怎麽用?Java DefaultOAuth2AccessToken.setValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.security.oauth2.common.DefaultOAuth2AccessToken
的用法示例。
在下文中一共展示了DefaultOAuth2AccessToken.setValue方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: enhance
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
@Override
public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
DefaultOAuth2AccessToken result = new DefaultOAuth2AccessToken(accessToken);
Map<String, Object> info = new LinkedHashMap<>(accessToken.getAdditionalInformation());
String tokenId = result.getValue();
if (!info.containsKey(TOKEN_ID)) {
info.put(TOKEN_ID, tokenId);
}
result.setAdditionalInformation(info);
result.setValue(encode(result, authentication));
return result;
}
示例2: createRefreshToken
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
/**
* Create a refresh token (if supported) by encoding an authentication, so it can be recovered when needed without
* any need for shared storage.
*
* @param authentication the current authentication
* @return a refresh token with a JWT encoded value
*/
private ExpiringOAuth2RefreshToken createRefreshToken(OAuth2Authentication authentication) {
if (!isSupportRefreshToken(authentication.getOAuth2Request())) {
return null;
}
DefaultOAuth2AccessToken accessToken = new DefaultOAuth2AccessToken(getAccessToken(authentication));
int validitySeconds = getRefreshTokenValiditySeconds(authentication.getOAuth2Request());
Date expiration = new Date(System.currentTimeMillis() + (validitySeconds * 1000L));
accessToken.setExpiration(expiration);
accessToken.setValue(encode(accessToken, authentication));
ExpiringOAuth2RefreshToken refreshToken = new DefaultExpiringOAuth2RefreshToken(accessToken.getValue(),
expiration);
return refreshToken;
}
示例3: enhance
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
DefaultOAuth2AccessToken result = new DefaultOAuth2AccessToken(accessToken);
Map<String, Object> info = new LinkedHashMap<String, Object>(accessToken.getAdditionalInformation());
String tokenId = result.getValue();
if (!info.containsKey(TOKEN_ID)) {
info.put(TOKEN_ID, tokenId);
}
result.setAdditionalInformation(info);
return result.setValue(encode(result, authentication));
}