use of com.sun.identity.federation.services.logout.FSSingleLogoutHandler in project OpenAM by OpenRock.
the class IDFFSingleLogoutHandler method handleSOAPInitiatedSingleLogout.
private int handleSOAPInitiatedSingleLogout(Set userSession, String userID, HttpServletRequest request, HttpServletResponse response, String realm, String idpMetaAlias, String idpEntityId, String relayState, IDFFMetaManager metaManager) throws Exception {
// TODO : verify this works under LB
Object ssoToken = null;
if ((userSession != null) && !userSession.isEmpty()) {
// TODO : handle multiple SSO token case
ssoToken = (Object) userSession.iterator().next();
} else {
FSSessionManager manager = FSSessionManager.getInstance(idpMetaAlias);
List sessions = manager.getSessionList(userID);
if ((sessions != null) && !sessions.isEmpty()) {
// TODO : handle multiple SSO token case
ssoToken = sessions.iterator().next();
} else {
return SingleLogoutManager.LOGOUT_NO_ACTION_STATUS;
}
}
// call Single Logout Handler
FSUtils.debug.message("creating FSSingleLogoutHandler");
HashMap providerMap = FSLogoutUtil.getCurrentProvider(userID, idpEntityId, ssoToken);
if (providerMap != null) {
FSSessionPartner currentSessionProvider = (FSSessionPartner) providerMap.get(IFSConstants.PARTNER_SESSION);
String sessionIndex = (String) providerMap.get(IFSConstants.SESSION_INDEX);
if (currentSessionProvider != null) {
ProviderDescriptorType hostedProviderDesc = metaManager.getIDPDescriptor(realm, idpEntityId);
BaseConfigType hostedConfig = metaManager.getIDPDescriptorConfig(realm, idpEntityId);
FSSingleLogoutHandler handlerObj = new FSSingleLogoutHandler();
handlerObj.setHostedDescriptor(hostedProviderDesc);
handlerObj.setHostedDescriptorConfig(hostedConfig);
handlerObj.setHostedEntityId(idpEntityId);
handlerObj.setHostedProviderRole(IFSConstants.IDP);
handlerObj.setMetaAlias(idpMetaAlias);
handlerObj.setSingleLogoutProtocol(IFSConstants.LOGOUT_IDP_SOAP_PROFILE);
handlerObj.setRelayState(relayState);
handlerObj.setRealm(realm);
FSLogoutStatus logoutStatus = handlerObj.handleSingleLogout(response, request, currentSessionProvider, userID, sessionIndex, false, ssoToken);
if (SingleLogoutManager.debug.messageEnabled()) {
SingleLogoutManager.debug.message("IDFFSLOHandler." + "handleSOAPInitiatedSLO: logout status=" + logoutStatus.toString());
}
if (logoutStatus.getStatus().equalsIgnoreCase(IFSConstants.SAML_SUCCESS)) {
return SingleLogoutManager.LOGOUT_SUCCEEDED_STATUS;
} else {
return SingleLogoutManager.LOGOUT_FAILED_STATUS;
}
}
}
return SingleLogoutManager.LOGOUT_NO_ACTION_STATUS;
}
Aggregations