use of org.apache.cxf.rs.security.oauth2.common.Client in project cxf by apache.
the class JPACodeDataProviderTest method addClient.
private Client addClient(String clientId, String userLogin) {
Client c = new Client();
c.setRedirectUris(Collections.singletonList("http://client/redirect"));
c.setClientId(clientId);
c.setResourceOwnerSubject(new UserSubject(userLogin));
getProvider().setClient(c);
return c;
}
use of org.apache.cxf.rs.security.oauth2.common.Client in project cxf by apache.
the class JPACodeDataProviderTest method testAddGetDeleteCodeGrants.
@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 = getProvider().createCodeGrant(atr);
List<ServerAuthorizationCodeGrant> grants = getProvider().getCodeGrants(c, c.getResourceOwnerSubject());
assertNotNull(grants);
assertEquals(1, grants.size());
assertEquals(grant.getCode(), grants.get(0).getCode());
grants = getProvider().getCodeGrants(c, null);
assertNotNull(grants);
assertEquals(1, grants.size());
assertEquals(grant.getCode(), grants.get(0).getCode());
ServerAuthorizationCodeGrant grant2 = getProvider().removeCodeGrant(grant.getCode());
assertEquals(grant.getCode(), grant2.getCode());
grants = getProvider().getCodeGrants(c, null);
assertNotNull(grants);
assertEquals(0, grants.size());
}
use of org.apache.cxf.rs.security.oauth2.common.Client in project cxf by apache.
the class JPACodeDataProviderTest method testAddGetDeleteCodeGrants2.
@Test
public void testAddGetDeleteCodeGrants2() {
Client c = addClient("111", "bob");
AuthorizationCodeRegistration atr = new AuthorizationCodeRegistration();
atr.setClient(c);
atr.setApprovedScope(Collections.singletonList("a"));
atr.setSubject(c.getResourceOwnerSubject());
getProvider().createCodeGrant(atr);
List<ServerAuthorizationCodeGrant> grants = getProvider().getCodeGrants(c, c.getResourceOwnerSubject());
assertNotNull(grants);
assertEquals(1, grants.size());
getProvider().removeClient(c.getClientId());
grants = getProvider().getCodeGrants(c, c.getResourceOwnerSubject());
assertNotNull(grants);
assertEquals(0, grants.size());
}
use of org.apache.cxf.rs.security.oauth2.common.Client in project cxf by apache.
the class JPACodeDataProviderTest method testResetClient.
@Test
public void testResetClient() {
Client c = addClient("111", "bob");
c.setClientSecret("newSecret");
getProvider().setClient(c);
Client savedClient = getProvider().getClient(c.getClientId());
assertEquals(c.getClientSecret(), savedClient.getClientSecret());
}
use of org.apache.cxf.rs.security.oauth2.common.Client in project cxf by apache.
the class ModelEncryptionSupport method recreateClientInternal.
private static Client recreateClientInternal(String sequence) {
String[] parts = getParts(sequence);
Client c = new Client(parts[0], parts[1], Boolean.parseBoolean(parts[2]), getStringPart(parts[3]), getStringPart(parts[4]));
c.setApplicationDescription(getStringPart(parts[5]));
c.setApplicationLogoUri(getStringPart(parts[6]));
c.setApplicationCertificates(parseSimpleList(parts[7]));
c.setAllowedGrantTypes(parseSimpleList(parts[8]));
c.setRedirectUris(parseSimpleList(parts[9]));
c.setRegisteredScopes(parseSimpleList(parts[10]));
c.setRegisteredAudiences(parseSimpleList(parts[11]));
c.setProperties(parseSimpleMap(parts[12]));
c.setSubject(recreateUserSubject(parts[13]));
return c;
}
Aggregations