use of org.apache.cxf.jaxrs.provider.json.JsonMapObjectProvider in project cxf by apache.
the class OIDCDynamicRegistrationTest method testRegisterClientNoInitialAccessToken.
@org.junit.Test
public void testRegisterClientNoInitialAccessToken() throws Exception {
URL busFile = OIDCDynamicRegistrationTest.class.getResource("client.xml");
String address = "https://localhost:" + DYNREG_SERVER.getPort() + "/services/dynamic/register";
WebClient wc = WebClient.create(address, Collections.singletonList(new JsonMapObjectProvider()), busFile.toString());
wc.accept("application/json").type("application/json");
assertEquals(401, wc.post(newClientRegistrationCodeGrant()).getStatus());
}
use of org.apache.cxf.jaxrs.provider.json.JsonMapObjectProvider 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:" + DYNREG_SERVER.getPort() + "/services/dynamicWithAt/register";
WebClient wc = WebClient.create(address, Collections.singletonList(new JsonMapObjectProvider()), busFile.toString()).accept("application/json").type("application/json").authorization(new ClientAccessToken(OAuthConstants.BEARER_AUTHORIZATION_SCHEME, ACCESS_TOKEN));
ClientRegistration reg = new ClientRegistration();
reg.setClientName("dynamic_client");
reg.setGrantTypes(Collections.singletonList(OAuthConstants.RESOURCE_OWNER_GRANT));
reg.setTokenEndpointAuthMethod(OAuthConstants.TOKEN_ENDPOINT_AUTH_NONE);
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);
ClientRegistration clientRegResp = wc.path(resp.getClientId()).authorization(new ClientAccessToken(OAuthConstants.BEARER_AUTHORIZATION_SCHEME, regAccessToken)).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.jaxrs.provider.json.JsonMapObjectProvider 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:" + DYNREG_SERVER.getPort() + "/services/dynamicWithAt/register";
WebClient wc = WebClient.create(address, Collections.singletonList(new JsonMapObjectProvider()), busFile.toString()).accept("application/json").type("application/json").authorization(new ClientAccessToken(OAuthConstants.BEARER_AUTHORIZATION_SCHEME, ACCESS_TOKEN));
ClientRegistration reg = newClientRegistrationCodeGrant();
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.path(resp.getClientId());
assertEquals(401, wc.get().getStatus());
ClientRegistration clientRegResp = wc.authorization(new ClientAccessToken(OAuthConstants.BEARER_AUTHORIZATION_SCHEME, regAccessToken)).get(ClientRegistration.class);
testCommonRegCodeGrantProperties(clientRegResp);
assertNull(clientRegResp.getTokenEndpointAuthMethod());
assertEquals(200, wc.delete().getStatus());
}
use of org.apache.cxf.jaxrs.provider.json.JsonMapObjectProvider in project testcases by coheigea.
the class HybridFlowTest method setupProviders.
private static List<Object> setupProviders() {
List<Object> providers = new ArrayList<Object>();
JSONProvider<OAuthAuthorizationData> jsonP = new JSONProvider<OAuthAuthorizationData>();
jsonP.setNamespaceMap(Collections.singletonMap("http://org.apache.cxf.rs.security.oauth", "ns2"));
providers.add(jsonP);
providers.add(new OAuthJSONProvider());
providers.add(new JsonWebKeysProvider());
providers.add(new JsonMapObjectProvider());
return providers;
}
use of org.apache.cxf.jaxrs.provider.json.JsonMapObjectProvider in project testcases by coheigea.
the class AuthorizationCodeFlowTest method setupProviders.
private static List<Object> setupProviders() {
List<Object> providers = new ArrayList<Object>();
JSONProvider<OAuthAuthorizationData> jsonP = new JSONProvider<OAuthAuthorizationData>();
jsonP.setNamespaceMap(Collections.singletonMap("http://org.apache.cxf.rs.security.oauth", "ns2"));
providers.add(jsonP);
providers.add(new OAuthJSONProvider());
providers.add(new JsonWebKeysProvider());
providers.add(new JsonMapObjectProvider());
return providers;
}
Aggregations