use of org.apache.cxf.rs.security.oauth2.services.ClientRegistrationResponse in project cxf by apache.
the class JAXRSOAuth2TlsTest method testRegisterClientTwoWayTLSClientIdBoundDynReg.
@Test
public void testRegisterClientTwoWayTLSClientIdBoundDynReg() throws Exception {
String dynRegAddress = "https://localhost:" + PORT + "/oauth2Jwt/register";
WebClient wcDynReg = createDynRegWebClient(dynRegAddress);
wcDynReg.accept("application/json").type("application/json");
ClientRegistration reg = newClientRegistration();
wcDynReg.authorization(new ClientAccessToken("Bearer", "123456789"));
ClientRegistrationResponse resp = wcDynReg.post(reg, ClientRegistrationResponse.class);
doTestTwoWayTLSClientIdBoundJwt(resp.getClientId());
// delete the client
String regAccessToken = resp.getRegistrationAccessToken();
assertNotNull(regAccessToken);
wcDynReg.path(resp.getClientId());
wcDynReg.authorization(new ClientAccessToken("Bearer", regAccessToken));
assertEquals(200, wcDynReg.delete().getStatus());
assertNotNull(regAccessToken);
}
use of org.apache.cxf.rs.security.oauth2.services.ClientRegistrationResponse in project cxf by apache.
the class OIDCDynamicRegistrationTest method testRegisterClientInitialAccessTokenCodeGrant.
@org.junit.Test
public void testRegisterClientInitialAccessTokenCodeGrant() throws Exception {
URL busFile = OIDCDynamicRegistrationTest.class.getResource("client.xml");
String address = "https://localhost:" + PORT + "/services/dynamicWithAt/register";
WebClient wc = WebClient.create(address, Collections.singletonList(new JsonMapObjectProvider()), busFile.toString());
wc.accept("application/json").type("application/json");
ClientRegistration reg = newClientRegistrationCodeGrant();
ClientRegistrationResponse resp = null;
assertEquals(401, wc.post(reg).getStatus());
wc.authorization(new ClientAccessToken("Bearer", "123456789"));
resp = wc.post(reg, ClientRegistrationResponse.class);
assertNotNull(resp.getClientId());
assertNotNull(resp.getClientSecret());
assertEquals(address + "/" + resp.getClientId(), resp.getRegistrationClientUri());
String regAccessToken = resp.getRegistrationAccessToken();
assertNotNull(regAccessToken);
wc.reset();
wc.path(resp.getClientId());
assertEquals(401, wc.get().getStatus());
wc.authorization(new ClientAccessToken("Bearer", regAccessToken));
ClientRegistration clientRegResp = wc.get(ClientRegistration.class);
testCommonRegCodeGrantProperties(clientRegResp);
assertNull(clientRegResp.getTokenEndpointAuthMethod());
assertEquals(200, wc.delete().getStatus());
}
use of org.apache.cxf.rs.security.oauth2.services.ClientRegistrationResponse in project cxf by apache.
the class OIDCDynamicRegistrationTest method testRegisterClientPasswordGrantPublic.
@org.junit.Test
public void testRegisterClientPasswordGrantPublic() throws Exception {
URL busFile = OIDCDynamicRegistrationTest.class.getResource("client.xml");
String address = "https://localhost:" + PORT + "/services/dynamicWithAt/register";
WebClient wc = WebClient.create(address, Collections.singletonList(new JsonMapObjectProvider()), busFile.toString());
wc.accept("application/json").type("application/json");
ClientRegistration reg = new ClientRegistration();
reg.setClientName("dynamic_client");
reg.setGrantTypes(Collections.singletonList(OAuthConstants.RESOURCE_OWNER_GRANT));
reg.setTokenEndpointAuthMethod(OAuthConstants.TOKEN_ENDPOINT_AUTH_NONE);
wc.authorization(new ClientAccessToken("Bearer", "123456789"));
ClientRegistrationResponse resp = wc.post(reg, ClientRegistrationResponse.class);
assertNotNull(resp.getClientId());
assertNull(resp.getClientSecret());
assertEquals(address + "/" + resp.getClientId(), resp.getRegistrationClientUri());
String regAccessToken = resp.getRegistrationAccessToken();
assertNotNull(regAccessToken);
wc.reset();
wc.path(resp.getClientId());
wc.authorization(new ClientAccessToken("Bearer", regAccessToken));
ClientRegistration clientRegResp = wc.get(ClientRegistration.class);
assertEquals("native", clientRegResp.getApplicationType());
assertEquals("dynamic_client", clientRegResp.getClientName());
assertEquals(Collections.singletonList(OAuthConstants.RESOURCE_OWNER_GRANT), clientRegResp.getGrantTypes());
assertEquals(OAuthConstants.TOKEN_ENDPOINT_AUTH_NONE, clientRegResp.getTokenEndpointAuthMethod());
assertNull(clientRegResp.getScope());
assertNull(clientRegResp.getRedirectUris());
assertEquals(200, wc.delete().getStatus());
}
use of org.apache.cxf.rs.security.oauth2.services.ClientRegistrationResponse in project cxf by apache.
the class OIDCDynamicRegistrationTest method testRegisterClientInitialAccessTokenCodeGrantTls.
@org.junit.Test
public void testRegisterClientInitialAccessTokenCodeGrantTls() throws Exception {
URL busFile = OIDCDynamicRegistrationTest.class.getResource("client.xml");
String address = "https://localhost:" + PORT + "/services/dynamicWithAt/register";
WebClient wc = WebClient.create(address, Collections.singletonList(new JsonMapObjectProvider()), busFile.toString());
wc.accept("application/json").type("application/json");
ClientRegistration reg = newClientRegistrationCodeGrant();
reg.setTokenEndpointAuthMethod(OAuthConstants.TOKEN_ENDPOINT_AUTH_TLS);
reg.setProperty(OAuthConstants.TLS_CLIENT_AUTH_SUBJECT_DN, "CN=whateverhost.com,OU=Morpit,O=ApacheTest,L=Syracuse,C=US");
ClientRegistrationResponse resp = null;
assertEquals(401, wc.post(reg).getStatus());
wc.authorization(new ClientAccessToken("Bearer", "123456789"));
resp = wc.post(reg, ClientRegistrationResponse.class);
assertNotNull(resp.getClientId());
assertNull(resp.getClientSecret());
assertEquals(address + "/" + resp.getClientId(), resp.getRegistrationClientUri());
String regAccessToken = resp.getRegistrationAccessToken();
assertNotNull(regAccessToken);
wc.reset();
wc.path(resp.getClientId());
assertEquals(401, wc.get().getStatus());
wc.authorization(new ClientAccessToken("Bearer", regAccessToken));
ClientRegistration clientRegResp = wc.get(ClientRegistration.class);
testCommonRegCodeGrantProperties(clientRegResp);
assertEquals(OAuthConstants.TOKEN_ENDPOINT_AUTH_TLS, clientRegResp.getTokenEndpointAuthMethod());
assertEquals("CN=whateverhost.com,OU=Morpit,O=ApacheTest,L=Syracuse,C=US", clientRegResp.getProperty(OAuthConstants.TLS_CLIENT_AUTH_SUBJECT_DN));
assertEquals(200, wc.delete().getStatus());
}
use of org.apache.cxf.rs.security.oauth2.services.ClientRegistrationResponse in project cxf by apache.
the class OIDCDynamicRegistrationTest method testRegisterClientPasswordGrant.
@org.junit.Test
public void testRegisterClientPasswordGrant() throws Exception {
URL busFile = OIDCDynamicRegistrationTest.class.getResource("client.xml");
String address = "https://localhost:" + PORT + "/services/dynamicWithAt/register";
WebClient wc = WebClient.create(address, Collections.singletonList(new JsonMapObjectProvider()), busFile.toString());
wc.accept("application/json").type("application/json");
ClientRegistration reg = new ClientRegistration();
reg.setClientName("dynamic_client");
reg.setGrantTypes(Collections.singletonList(OAuthConstants.RESOURCE_OWNER_GRANT));
wc.authorization(new ClientAccessToken("Bearer", "123456789"));
ClientRegistrationResponse resp = wc.post(reg, ClientRegistrationResponse.class);
assertNotNull(resp.getClientId());
assertNotNull(resp.getClientSecret());
assertEquals(address + "/" + resp.getClientId(), resp.getRegistrationClientUri());
String regAccessToken = resp.getRegistrationAccessToken();
assertNotNull(regAccessToken);
wc.reset();
wc.path(resp.getClientId());
wc.authorization(new ClientAccessToken("Bearer", regAccessToken));
ClientRegistration clientRegResp = wc.get(ClientRegistration.class);
assertEquals("web", clientRegResp.getApplicationType());
assertEquals("dynamic_client", clientRegResp.getClientName());
assertEquals(Collections.singletonList(OAuthConstants.RESOURCE_OWNER_GRANT), clientRegResp.getGrantTypes());
assertNull(clientRegResp.getTokenEndpointAuthMethod());
assertNull(clientRegResp.getScope());
assertNull(clientRegResp.getRedirectUris());
assertEquals(200, wc.delete().getStatus());
}
Aggregations