/** * Executes the call to the REST Service requesting to end session and processes the response. * * @param idTokenHint The issued ID Token. * @param postLogoutRedirectUri The URL to which the RP is requesting that the End-User's User-Agent be redirected * after a logout has been performed. * @param state The state. * @return The service response. */ public EndSessionResponse execEndSession(String idTokenHint, String postLogoutRedirectUri, String state) { setRequest(new EndSessionRequest(idTokenHint, postLogoutRedirectUri, state)); return exec(); }
initClientRequest(); clientRequest.accept(mediaType); clientRequest.setHttpMethod(getHttpMethod()); if (StringUtils.isNotBlank(getRequest().getIdTokenHint())) { clientRequest.queryParameter(EndSessionRequestParam.ID_TOKEN_HINT, getRequest().getIdTokenHint()); if (StringUtils.isNotBlank(getRequest().getPostLogoutRedirectUri())) { clientRequest.queryParameter(EndSessionRequestParam.POST_LOGOUT_REDIRECT_URI, getRequest().getPostLogoutRedirectUri()); if (StringUtils.isNotBlank(getRequest().getState())) { clientRequest.queryParameter(EndSessionRequestParam.STATE, getRequest().getState()); if (StringUtils.isNotBlank(getRequest().getSessionId())) { clientRequest.queryParameter(EndSessionRequestParam.SESSION_ID, getRequest().getSessionId()); setResponse(new EndSessionResponse(status)); String entity = clientResponse.getEntity(String.class); getResponse().setEntity(entity); getResponse().setHeaders(clientResponse.getMetadata()); if (clientResponse.getLocationLink() != null) { String location = clientResponse.getLocationLink().getHref(); getResponse().setLocation(location); Map<String, String> params = QueryStringDecoder.decode(queryString); if (params.containsKey(EndSessionResponseParam.STATE)) { getResponse().setState(params.get(EndSessionResponseParam.STATE)); JSONObject jsonObj = new JSONObject(entity);
endSessionRequest1.setSessionId(authorizationResponse.getSessionId()); EndSessionClient endSessionClient = new EndSessionClient(endSessionEndpoint); endSessionClient.setRequest(endSessionRequest1); EndSessionResponse endSessionResponse1 = endSessionClient.exec(); endSessionRequest2.setSessionId(authorizationResponse.getSessionId()); EndSessionClient endSessionClient2 = new EndSessionClient(endSessionEndpoint); endSessionClient2.setRequest(endSessionRequest2); EndSessionResponse endSessionResponse2 = endSessionClient2.exec();
@Parameters({"postLogoutRedirectUri"}) @Test public void requestEndSessionFail2(final String postLogoutRedirectUri) throws Exception { showTitle("requestEndSessionFail2"); String state = UUID.randomUUID().toString(); EndSessionClient endSessionClient = new EndSessionClient(endSessionEndpoint); EndSessionResponse response = endSessionClient.execEndSession("INVALID_ACCESS_TOKEN", postLogoutRedirectUri, state); showClient(endSessionClient); assertEquals(response.getStatus(), Status.BAD_REQUEST.getStatusCode(), "Unexpected response code. Entity: " + response.getEntity()); assertNotNull(response.getEntity(), "The entity is null"); assertNotNull(response.getErrorType(), "The error type is null"); assertNotNull(response.getErrorDescription(), "The error description is null"); } }
endSessionRequest1.setSessionId(authorizationResponse.getSessionId()); EndSessionClient endSessionClient = new EndSessionClient(endSessionEndpoint); endSessionClient.setRequest(endSessionRequest1); EndSessionResponse endSessionResponse1 = endSessionClient.exec(); endSessionRequest2.setSessionId(authorizationResponse.getSessionId()); EndSessionClient endSessionClient2 = new EndSessionClient(endSessionEndpoint); endSessionClient2.setRequest(endSessionRequest2); EndSessionResponse endSessionResponse2 = endSessionClient2.exec();
@Test public void requestEndSessionFail1() throws Exception { showTitle("requestEndSessionFail1"); EndSessionClient endSessionClient = new EndSessionClient(endSessionEndpoint); EndSessionResponse response = endSessionClient.execEndSession(null, null, null); showClient(endSessionClient); assertEquals(response.getStatus(), 400, "Unexpected response code. Entity: " + response.getEntity()); assertNotNull(response.getEntity(), "The entity is null"); assertNotNull(response.getErrorType(), "The error type is null"); assertNotNull(response.getErrorDescription(), "The error description is null"); }
endSessionRequest.setSessionId(authorizationResponse.getSessionId()); EndSessionClient endSessionClient = new EndSessionClient(endSessionEndpoint); endSessionClient.setRequest(endSessionRequest); EndSessionResponse endSessionResponse = endSessionClient.exec();