/** * Executes the call to the REST Service and processes the response. * * @param accessToken The access token obtained from the oxAuth authorization request. * @return The service response. */ public UserInfoResponse execUserInfo(String accessToken) { setRequest(new UserInfoRequest(accessToken)); return exec(); }
public void exec() { try { UserInfoRequest request = new UserInfoRequest(accessToken); request.setAuthorizationMethod(authorizationMethod); UserInfoClient client = new UserInfoClient(userInfoEndpoint); client.setRequest(request); client.exec(); showResults = true; requestString = client.getRequestAsString(); responseString = client.getResponseAsString(); } catch (Exception e) { log.error(e.getMessage(), e); } }
@Parameters({"userInfoPath"}) @Test public void requestUserInfoInvalidRequest(final String userInfoPath) throws Exception { UserInfoRequest userInfoRequest = new UserInfoRequest(null); Builder request = ResteasyClientBuilder.newClient().target(url.toString() + userInfoPath).request(); Response response = request .post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters()))); String entity = response.readEntity(String.class); showResponse("requestUserInfoInvalidRequest", response, entity); assertEquals(response.getStatus(), 400, "Unexpected response code."); assertNotNull(entity, "Unexpected result: " + entity); try { JSONObject jsonObj = new JSONObject(entity); assertTrue(jsonObj.has("error"), "The error type is null"); assertTrue(jsonObj.has("error_description"), "The error description is null"); } catch (JSONException e) { e.printStackTrace(); fail(e.getMessage() + "\nResponse was: " + entity); } }
@Parameters({"userInfoPath"}) @Test public void requestUserInfoInvalidToken(final String userInfoPath) throws Exception { UserInfoRequest userInfoRequest = new UserInfoRequest("INVALID_ACCESS_TOKEN"); userInfoRequest.setAuthorizationMethod(AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER); Builder request = ResteasyClientBuilder.newClient().target(url.toString() + userInfoPath).request(); Response response = request .post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters()))); String entity = response.readEntity(String.class); showResponse("requestUserInfoInvalidToken", response, entity); assertEquals(response.getStatus(), 400, "Unexpected response code."); assertNotNull(entity, "Unexpected result: " + entity); try { JSONObject jsonObj = new JSONObject(entity); assertTrue(jsonObj.has("error"), "The error type is null"); assertTrue(jsonObj.has("error_description"), "The error description is null"); } catch (JSONException e) { e.printStackTrace(); fail(e.getMessage() + "\nResponse was: " + entity); } }
@Parameters({"userInfoPath"}) @Test(dependsOnMethods = "revokeTokensStep4") public void revokeTokensStep5(final String userInfoPath) throws Exception { Builder request = ResteasyClientBuilder.newClient().target(url.toString() + userInfoPath).request(); request.header("Authorization", "Bearer " + accessToken1); UserInfoRequest userInfoRequest = new UserInfoRequest(null); Response response = request .post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters()))); String entity = response.readEntity(String.class); showResponse("revokeTokensStep5", response, entity); assertEquals(response.getStatus(), 400, "Unexpected response code."); assertNotNull(entity, "Unexpected result: " + entity); try { JSONObject jsonObj = new JSONObject(entity); assertTrue(jsonObj.has("error"), "The error type is null"); assertTrue(jsonObj.has("error_description"), "The error description is null"); } catch (JSONException e) { e.printStackTrace(); fail(e.getMessage() + "\nResponse was: " + entity); } }
@Parameters({"userInfoPath"}) @Test public void requestUserInfoInvalidSchema(final String userInfoPath) throws Exception { Builder request = ResteasyClientBuilder.newClient().target(url.toString() + userInfoPath).request(); request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED); UserInfoRequest userInfoRequest = new UserInfoRequest("INVALID_ACCESS_TOKEN"); Map<String, String> userInfoParameters = userInfoRequest.getParameters(); userInfoParameters.put("schema", "INVALID_SCHEMA"); Response response = request .post(Entity.form(new MultivaluedHashMap<String, String>(userInfoRequest.getParameters()))); String entity = response.readEntity(String.class); showResponse("requestUserInfoInvalidSchema", response, entity); assertEquals(response.getStatus(), 400, "Unexpected response code."); assertNotNull(entity, "Unexpected result: " + entity); try { JSONObject jsonObj = new JSONObject(entity); assertTrue(jsonObj.has("error"), "The error type is null"); assertTrue(jsonObj.has("error_description"), "The error description is null"); } catch (JSONException e) { e.printStackTrace(); fail(e.getMessage() + "\nResponse was: " + entity); } }
@Parameters({"userInfoPath"}) @Test(dependsOnMethods = "requestUserInfoStep1ImplicitFlow") public void requestUserInfoStep2GetImplicitFlow(final String userInfoPath) throws Exception { UserInfoRequest userInfoRequest = new UserInfoRequest(null);
request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED); UserInfoRequest userInfoRequest = new UserInfoRequest(accessToken2); userInfoRequest.setAuthorizationMethod(AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER);
UserInfoRequest userInfoRequest = new UserInfoRequest(accessToken1); userInfoRequest.setAuthorizationMethod(AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER);
UserInfoRequest userInfoRequest = new UserInfoRequest(accessToken3); userInfoRequest.setAuthorizationMethod(AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER);
request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED); UserInfoRequest userInfoRequest = new UserInfoRequest(null);
request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED); UserInfoRequest userInfoRequest = new UserInfoRequest(null);
request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED); UserInfoRequest userInfoRequest = new UserInfoRequest(null);
request.header("Authorization", "Bearer " + accessToken6); UserInfoRequest userInfoRequest = new UserInfoRequest(null);
request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED); UserInfoRequest userInfoRequest = new UserInfoRequest(null);
UserInfoRequest userInfoRequest = new UserInfoRequest(accessToken); userInfoRequest.setAuthorizationMethod(AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER);
UserInfoRequest userInfoRequest = new UserInfoRequest(accessToken); UserInfoClient userInfoClient = new UserInfoClient(userInfoEndpoint); userInfoClient.setRequest(userInfoRequest);
PrivateKey privateKey = cryptoProvider.getPrivateKey(keyId); UserInfoRequest userInfoRequest = new UserInfoRequest(accessToken);
UserInfoRequest userInfoRequest = new UserInfoRequest(accessToken);
UserInfoRequest userInfoRequest = new UserInfoRequest(accessToken);