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);
}
}
Aggregations