Search in sources :

Example 1 with EndSessionResponse

use of org.xdi.oxauth.client.EndSessionResponse in project oxTrust by GluuFederation.

the class AuthenticationSessionService method sessionDestroyed.

@PreDestroy
public void sessionDestroyed() {
    OauthData oauthData = identity.getOauthData();
    if ((oauthData == null) || StringHelper.isEmpty(oauthData.getSessionState())) {
        return;
    }
    String userUid = oauthData.getUserUid();
    log.debug("Calling oxAuth logout method at the end of HTTP session. User: '{}'", userUid);
    try {
        String endSessionState = UUID.randomUUID().toString();
        EndSessionRequest endSessionRequest = new EndSessionRequest(oauthData.getIdToken(), appConfiguration.getLogoutRedirectUrl(), endSessionState);
        endSessionRequest.setSessionState(oauthData.getSessionState());
        EndSessionClient endSessionClient = new EndSessionClient(openIdService.getOpenIdConfiguration().getEndSessionEndpoint());
        endSessionClient.setRequest(endSessionRequest);
        EndSessionResponse endSessionResponse = endSessionClient.exec();
        if ((endSessionResponse == null) || (endSessionResponse.getStatus() != 302)) {
            log.error("Invalid response code at oxAuth logout. User: '{}'", userUid);
        }
    } catch (Exception ex) {
        log.error("Exception happened at oxAuth logout. User: '{}'", ex, userUid);
    }
}
Also used : OauthData(org.gluu.oxtrust.security.OauthData) EndSessionClient(org.xdi.oxauth.client.EndSessionClient) EndSessionRequest(org.xdi.oxauth.client.EndSessionRequest) EndSessionResponse(org.xdi.oxauth.client.EndSessionResponse) PreDestroy(javax.annotation.PreDestroy)

Aggregations

PreDestroy (javax.annotation.PreDestroy)1 OauthData (org.gluu.oxtrust.security.OauthData)1 EndSessionClient (org.xdi.oxauth.client.EndSessionClient)1 EndSessionRequest (org.xdi.oxauth.client.EndSessionRequest)1 EndSessionResponse (org.xdi.oxauth.client.EndSessionResponse)1