本文整理匯總了Java中org.springframework.security.oauth2.common.DefaultOAuth2AccessToken.setScope方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultOAuth2AccessToken.setScope方法的具體用法?Java DefaultOAuth2AccessToken.setScope怎麽用?Java DefaultOAuth2AccessToken.setScope使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.security.oauth2.common.DefaultOAuth2AccessToken
的用法示例。
在下文中一共展示了DefaultOAuth2AccessToken.setScope方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convert
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
private OAuth2AccessToken convert(io.gravitee.am.repository.oauth2.model.OAuth2AccessToken _oAuth2AccessToken) {
DefaultOAuth2AccessToken oAuth2AccessToken = new DefaultOAuth2AccessToken(_oAuth2AccessToken.getValue());
oAuth2AccessToken.setAdditionalInformation(_oAuth2AccessToken.getAdditionalInformation());
oAuth2AccessToken.setExpiration(_oAuth2AccessToken.getExpiration());
oAuth2AccessToken.setScope(_oAuth2AccessToken.getScope());
oAuth2AccessToken.setTokenType(_oAuth2AccessToken.getTokenType());
// refresh token
io.gravitee.am.repository.oauth2.model.OAuth2RefreshToken _oAuth2RefreshToken = _oAuth2AccessToken.getRefreshToken();
if (_oAuth2RefreshToken != null) {
DefaultExpiringOAuth2RefreshToken oAuth2RefreshToken =
new DefaultExpiringOAuth2RefreshToken(_oAuth2AccessToken.getRefreshToken().getValue(), _oAuth2AccessToken.getRefreshToken().getExpiration());
oAuth2AccessToken.setRefreshToken(oAuth2RefreshToken);
}
return oAuth2AccessToken;
}
示例2: extractAccessToken
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
public OAuth2AccessToken extractAccessToken(String value, Map<String, ?> map) {
DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(value);
Map<String, Object> info = new HashMap<String, Object>(map);
info.remove(EXP);
info.remove(AUD);
info.remove(CLIENT_ID);
info.remove(SCOPE);
if (map.containsKey(EXP)) {
token.setExpiration(new Date((Integer) map.get(EXP) * 1000L));
}
if (map.containsKey(JTI)) {
info.put(JTI, map.get(JTI));
}
@SuppressWarnings("unchecked")
Collection<String> scope = (Collection<String>) map.get(SCOPE);
if (scope != null) {
token.setScope(new HashSet<String>(scope));
}
token.setAdditionalInformation(info);
return token;
}
示例3: setUpMocks
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
private void setUpMocks() {
DefaultOAuth2AccessToken accessToken = new DefaultOAuth2AccessToken("testTokenValue");
accessToken.setScope(new HashSet<>());
CloudSpace space = new CloudSpace(null, SPACE, new CloudOrganization(null, ORG));
List<CloudSpace> spaces = new ArrayList<>();
if (hasAccess) {
spaces.add(space);
}
userInfo = new UserInfo(USER_ID, USERNAME, accessToken);
List<String> spaceDevelopersList = new ArrayList<>();
if (hasPermissions) {
spaceDevelopersList.add(USER_ID);
}
when(client.getSpaces()).thenReturn(spaces);
when(client.getSpaceDevelopers2(ORG, SPACE)).thenReturn(spaceDevelopersList);
when(clientProvider.getCloudFoundryClient(userInfo.getToken())).thenReturn(client);
}
示例4: oAuth2AccessTokenMapper
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
/**
* Convert IDN_OAUTH2_ACCESS_TOKEN table
* @return
*/
public static RowMapper<OAuth2AccessToken> oAuth2AccessTokenMapper() {
return new RowMapper<OAuth2AccessToken>() {
@Override
public OAuth2AccessToken mapRow(final ResultSet rs, int rowNum) throws SQLException {
DefaultOAuth2AccessToken defaultOAuth2AccessToken = new DefaultOAuth2AccessToken(rs.getString(1));
defaultOAuth2AccessToken.setRefreshToken(new DefaultOAuth2RefreshToken(rs.getString(3)));
Set<String> scope = new HashSet<String>();
scope.add(rs.getString(2));
defaultOAuth2AccessToken.setScope(scope);
Timestamp date = rs.getTimestamp(4);
Calendar calendar = new GregorianCalendar();
calendar.setTimeInMillis(date.getTime());
calendar.add(Calendar.MILLISECOND, rs.getInt(5));
defaultOAuth2AccessToken.setExpiration(calendar.getTime());
return defaultOAuth2AccessToken;
}
};
}
示例5: readAccessToken
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
@Override
public OAuth2AccessToken readAccessToken(String token) {
AccessToken accessToken = validateAccessToken(token);
Set<String> scopes = new HashSet<>();
for (Scope scope : accessToken.getScopes()) {
scopes.add(scope.toString());
}
DefaultOAuth2AccessToken oAuth2AccessToken = new DefaultOAuth2AccessToken(token);
oAuth2AccessToken.setScope(scopes);
oAuth2AccessToken.setExpiration(accessToken.getExpiresAt());
oAuth2AccessToken.setTokenType(DefaultOAuth2AccessToken.BEARER_TYPE);
return oAuth2AccessToken;
}
示例6: createAccessToken
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
private OAuth2AccessToken createAccessToken(
OAuth2Authentication authentication, OAuth2RefreshToken refreshToken) {
DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(UUID
.randomUUID().toString());
int validitySeconds = getAccessTokenValiditySeconds(authentication
.getOAuth2Request());
if (validitySeconds > 0) {
token.setExpiration(new Date(System.currentTimeMillis()
+ (validitySeconds * 1000L)));
}
token.setRefreshToken(refreshToken);
token.setScope(authentication.getOAuth2Request().getScope());
return accessTokenEnhancer != null ? accessTokenEnhancer.enhance(token,
authentication) : token;
}
示例7: createAccessToken
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
private OAuth2AccessToken createAccessToken(OAuth2Authentication authentication, OAuth2RefreshToken refreshToken) {
DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(UUID.randomUUID().toString());
int validitySeconds = getAccessTokenValiditySeconds(authentication);
if (validitySeconds > 0) {
token.setExpiration(new Date(System.currentTimeMillis() + (validitySeconds * 1000L)));
}
token.setRefreshToken(refreshToken);
token.setScope(authentication.getOAuth2Request().getScope());
return accessTokenEnhancer != null ? accessTokenEnhancer.enhance(token, authentication) : token;
}
示例8: createToken
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public static OAuth2AccessToken createToken(String tokenString) {
Map<String, Object> tokenInfo = getTokenInfo(tokenString);
List<String> scope = (List<String>) tokenInfo.get("scope");
Integer exp = (Integer) tokenInfo.get("exp");
if (scope == null || exp == null) {
return null;
}
DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(tokenString);
token.setExpiration(new Date(exp.longValue() * 1000));
token.setScope(new HashSet<String>(scope));
token.setAdditionalInformation(tokenInfo);
return token;
}
示例9: createDummyToken
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
public static OAuth2AccessToken createDummyToken(String userName, String clientId) {
List<String> scope = Arrays.asList(SCOPE_CC_READ, SCOPE_CC_WRITE, SCOPE_CC_ADMIN, SCOPE_SCIM_USERIDS, SCOPE_PASSWORD_WRITE,
SCOPE_OPENID);
Map<String, Object> tokenInfo = new HashMap<>();
tokenInfo.put("scope", scope);
tokenInfo.put("exp", Long.MAX_VALUE / 1000);
tokenInfo.put("user_name", userName);
tokenInfo.put("user_id", DUMMY_UUID.toString());
tokenInfo.put("client_id", clientId);
DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(DUMMY_TOKEN);
token.setExpiration(new Date(Long.MAX_VALUE));
token.setScope(new HashSet<String>(scope));
token.setAdditionalInformation(tokenInfo);
return token;
}
示例10: build
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
public OAuth2AccessToken build() {
final DefaultOAuth2AccessToken oAuth2AccessToken = new DefaultOAuth2AccessToken(token);
oAuth2AccessToken.setExpiration(expiration.toDate());
oAuth2AccessToken.setRefreshToken(oAuth2RefreshToken);
oAuth2AccessToken.setScope(scope);
oAuth2AccessToken.setAdditionalInformation(additionalInformation);
return oAuth2AccessToken;
}