use of org.apache.cxf.rs.security.oauth2.grants.code.AuthorizationCodeRegistration in project cxf by apache.
the class CodeGrantEncryptingDataProvider method createCodeGrant.
@Override
public ServerAuthorizationCodeGrant createCodeGrant(AuthorizationCodeRegistration reg) throws OAuthServiceException {
ServerAuthorizationCodeGrant grant = new ServerAuthorizationCodeGrant(reg.getClient(), 123);
grant.setAudience(reg.getAudience());
String encrypted = ModelEncryptionSupport.encryptCodeGrant(grant, key);
grant.setCode(encrypted);
grants.add(encrypted);
return grant;
}
use of org.apache.cxf.rs.security.oauth2.grants.code.AuthorizationCodeRegistration in project cxf by apache.
the class CryptoUtilsTest method testEncryptDecryptCodeGrant.
@Test
public void testEncryptDecryptCodeGrant() throws Exception {
AuthorizationCodeRegistration codeReg = new AuthorizationCodeRegistration();
codeReg.setAudience("http://bar");
codeReg.setClient(p.getClient("1"));
ServerAuthorizationCodeGrant grant = p.createCodeGrant(codeReg);
ServerAuthorizationCodeGrant grant2 = p.removeCodeGrant(grant.getCode());
assertEquals("http://bar", grant2.getAudience());
assertEquals("1", grant2.getClient().getClientId());
}
use of org.apache.cxf.rs.security.oauth2.grants.code.AuthorizationCodeRegistration in project tesb-rt-se by Talend.
the class OAuthManager method createCodeGrant.
// grant management
public ServerAuthorizationCodeGrant createCodeGrant(AuthorizationCodeRegistration reg) throws OAuthServiceException {
grant = new ServerAuthorizationCodeGrant(client, 3600L);
grant.setRedirectUri(reg.getRedirectUri());
grant.setSubject(reg.getSubject());
List<String> scope = reg.getApprovedScope().isEmpty() ? reg.getRequestedScope() : reg.getApprovedScope();
grant.setApprovedScopes(scope);
return grant;
}
use of org.apache.cxf.rs.security.oauth2.grants.code.AuthorizationCodeRegistration in project cxf by apache.
the class JCacheCodeDataProviderTest method testAddGetDeleteCodeGrants.
@Ignore
@Test
public void testAddGetDeleteCodeGrants() {
Client c = addClient("111", "bob");
AuthorizationCodeRegistration atr = new AuthorizationCodeRegistration();
atr.setClient(c);
atr.setApprovedScope(Collections.singletonList("a"));
atr.setSubject(c.getResourceOwnerSubject());
ServerAuthorizationCodeGrant grant = provider.createCodeGrant(atr);
List<ServerAuthorizationCodeGrant> grants = provider.getCodeGrants(c, c.getResourceOwnerSubject());
assertNotNull(grants);
assertEquals(1, grants.size());
assertEquals(grant.getCode(), grants.get(0).getCode());
grants = provider.getCodeGrants(c, null);
assertNotNull(grants);
assertEquals(1, grants.size());
assertEquals(grant.getCode(), grants.get(0).getCode());
ServerAuthorizationCodeGrant grant2 = provider.removeCodeGrant(grant.getCode());
assertEquals(grant.getCode(), grant2.getCode());
grants = provider.getCodeGrants(c, null);
assertNotNull(grants);
assertEquals(0, grants.size());
}
Aggregations