use of org.apache.cxf.rs.security.oauth2.common.Client in project cxf by apache.
the class DefaultEHCacheOAuthDataProvider method getAccessTokens.
@Override
public List<ServerAccessToken> getAccessTokens(Client c, UserSubject sub) {
List<String> keys = CastUtils.cast(accessTokenCache.getKeys());
List<ServerAccessToken> tokens = new ArrayList<>(keys.size());
for (String key : keys) {
ServerAccessToken token = getAccessToken(key);
if (isTokenMatched(token, c, sub)) {
tokens.add(token);
}
}
return tokens;
}
use of org.apache.cxf.rs.security.oauth2.common.Client in project cxf by apache.
the class DefaultEHCacheOAuthDataProvider method getRefreshTokens.
@Override
public List<RefreshToken> getRefreshTokens(Client c, UserSubject sub) {
List<String> keys = CastUtils.cast(refreshTokenCache.getKeys());
List<RefreshToken> tokens = new ArrayList<>(keys.size());
for (String key : keys) {
RefreshToken token = getRefreshToken(key);
if (isTokenMatched(token, c, sub)) {
tokens.add(token);
}
}
return tokens;
}
use of org.apache.cxf.rs.security.oauth2.common.Client in project cxf by apache.
the class AuthorizationCodeGrantService method createAuthorizationData.
@Override
protected OAuthAuthorizationData createAuthorizationData(Client client, MultivaluedMap<String, String> params, String redirectUri, UserSubject subject, List<OAuthPermission> requestedPerms, List<OAuthPermission> alreadyAuthorizedPerms, boolean authorizationCanBeSkipped) {
OAuthAuthorizationData data = super.createAuthorizationData(client, params, redirectUri, subject, requestedPerms, alreadyAuthorizedPerms, authorizationCanBeSkipped);
setCodeChallenge(data, params);
return data;
}
use of org.apache.cxf.rs.security.oauth2.common.Client in project cxf by apache.
the class JCacheOAuthDataProviderTest method testAddGetDeleteAccessToken.
@Ignore
@Test
public void testAddGetDeleteAccessToken() {
Client c = addClient("101", "bob");
AccessTokenRegistration atr = new AccessTokenRegistration();
atr.setClient(c);
atr.setApprovedScope(Collections.singletonList("a"));
atr.setSubject(c.getResourceOwnerSubject());
ServerAccessToken at = provider.createAccessToken(atr);
ServerAccessToken at2 = provider.getAccessToken(at.getTokenKey());
assertEquals(at.getTokenKey(), at2.getTokenKey());
List<OAuthPermission> scopes = at2.getScopes();
assertNotNull(scopes);
assertEquals(1, scopes.size());
OAuthPermission perm = scopes.get(0);
assertEquals("a", perm.getPermission());
List<ServerAccessToken> tokens = provider.getAccessTokens(c, c.getResourceOwnerSubject());
assertNotNull(tokens);
assertEquals(1, tokens.size());
assertEquals(at.getTokenKey(), tokens.get(0).getTokenKey());
tokens = provider.getAccessTokens(c, null);
assertNotNull(tokens);
assertEquals(1, tokens.size());
assertEquals(at.getTokenKey(), tokens.get(0).getTokenKey());
tokens = provider.getAccessTokens(null, c.getResourceOwnerSubject());
assertNotNull(tokens);
assertEquals(1, tokens.size());
assertEquals(at.getTokenKey(), tokens.get(0).getTokenKey());
tokens = provider.getAccessTokens(null, null);
assertNotNull(tokens);
assertEquals(1, tokens.size());
assertEquals(at.getTokenKey(), tokens.get(0).getTokenKey());
provider.revokeToken(c, at.getTokenKey(), OAuthConstants.ACCESS_TOKEN);
assertNull(provider.getAccessToken(at.getTokenKey()));
}
use of org.apache.cxf.rs.security.oauth2.common.Client in project cxf by apache.
the class JCacheOAuthDataProviderTest method testAddGetDeleteAccessToken2.
@Ignore
@Test
public void testAddGetDeleteAccessToken2() {
Client c = addClient("102", "bob");
AccessTokenRegistration atr = new AccessTokenRegistration();
atr.setClient(c);
atr.setApprovedScope(Collections.singletonList("a"));
atr.setSubject(c.getResourceOwnerSubject());
provider.createAccessToken(atr);
List<ServerAccessToken> tokens = provider.getAccessTokens(c, null);
assertNotNull(tokens);
assertEquals(1, tokens.size());
provider.removeClient(c.getClientId());
tokens = provider.getAccessTokens(c, null);
assertNotNull(tokens);
assertEquals(0, tokens.size());
}
Aggregations