use of org.xdi.oxauth.client.EndSessionRequest in project oxAuth by GluuFederation.
the class EndSessionAction method exec.
public void exec() {
try {
EndSessionRequest req = new EndSessionRequest(idTokenHint, postLogoutRedirectUri, state);
String authorizationRequest = endSessionEndpoint + "?" + req.getQueryString();
FacesContext.getCurrentInstance().getExternalContext().redirect(authorizationRequest);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
use of org.xdi.oxauth.client.EndSessionRequest in project oxAuth by GluuFederation.
the class EndSessionRestWebServiceEmbeddedTest method requestEndSessionStep3.
@Parameters({ "endSessionPath", "postLogoutRedirectUri" })
@Test(dependsOnMethods = "requestEndSessionStep2")
public void requestEndSessionStep3(final String endSessionPath, final String postLogoutRedirectUri) throws Exception {
String state = UUID.randomUUID().toString();
EndSessionRequest endSessionRequest = new EndSessionRequest(idToken, postLogoutRedirectUri, state);
endSessionRequest.setSessionState(sessionState);
Builder request = ResteasyClientBuilder.newClient().target(url.toString() + endSessionPath + "?" + endSessionRequest.getQueryString()).request();
request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
Response response = request.get();
String entity = response.readEntity(String.class);
showResponse("requestEndSessionStep3", response, entity);
assertEquals(response.getStatus(), 200, "Unexpected response code.");
assertNotNull(entity, "Unexpected html.");
assertTrue(entity.contains(postLogoutRedirectUri));
assertTrue(entity.contains(postLogoutRedirectUri));
}
use of org.xdi.oxauth.client.EndSessionRequest in project oxAuth by GluuFederation.
the class EndSessionRestWebServiceEmbeddedTest method requestEndSessionFail1.
// private void validateNonHttpBasedLogout(EnhancedMockHttpServletResponse
// response) {
// if (response.getLocation() != null) {
// try {
// URI uri = new URI(response.getLocation().toString());
// assertNotNull(uri.getQuery(), "The query string is null");
//
// Map<String, String> params = QueryStringDecoder.decode(uri.getQuery());
//
// assertNotNull(params.get(EndSessionResponseParam.STATE), "The state is
// null");
// assertEquals(params.get(EndSessionResponseParam.STATE), endSessionState);
// } catch (URISyntaxException e) {
// e.printStackTrace();
// fail("Response URI is not well formed");
// } catch (Exception e) {
// e.printStackTrace();
// fail(e.getMessage());
// }
// }
// }
@Parameters({ "endSessionPath" })
@Test
public void requestEndSessionFail1(final String endSessionPath) throws Exception {
EndSessionRequest endSessionRequest = new EndSessionRequest(null, null, null);
Builder request = ResteasyClientBuilder.newClient().target(url.toString() + endSessionPath + "?" + endSessionRequest.getQueryString()).request();
request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
Response response = request.get();
String entity = response.readEntity(String.class);
showResponse("requestEndSessionFail1", 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);
}
}
use of org.xdi.oxauth.client.EndSessionRequest in project oxAuth by GluuFederation.
the class EndSessionRestWebServiceEmbeddedTest method requestEndSessionFail2.
@Parameters({ "endSessionPath", "postLogoutRedirectUri" })
@Test
public void requestEndSessionFail2(final String endSessionPath, final String postLogoutRedirectUri) throws Exception {
String endSessionState = UUID.randomUUID().toString();
EndSessionRequest endSessionRequest = new EndSessionRequest("INVALID_ACCESS_TOKEN", postLogoutRedirectUri, endSessionState);
Builder request = ResteasyClientBuilder.newClient().target(url.toString() + endSessionPath + "?" + endSessionRequest.getQueryString()).request();
request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
Response response = request.get();
String entity = response.readEntity(String.class);
showResponse("requestEndSessionFail2", response, entity);
assertEquals(response.getStatus(), 401, "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);
}
}
Aggregations