Search in sources :

Example 1 with FSSingleLogoutHandler

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;
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) FSSingleLogoutHandler(com.sun.identity.federation.services.logout.FSSingleLogoutHandler) FSSessionPartner(com.sun.identity.federation.services.FSSessionPartner) HashMap(java.util.HashMap) ProviderDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType) FSLogoutStatus(com.sun.identity.federation.services.logout.FSLogoutStatus) List(java.util.List) FSSessionManager(com.sun.identity.federation.services.FSSessionManager)

Aggregations

BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)1 FSSessionManager (com.sun.identity.federation.services.FSSessionManager)1 FSSessionPartner (com.sun.identity.federation.services.FSSessionPartner)1 FSLogoutStatus (com.sun.identity.federation.services.logout.FSLogoutStatus)1 FSSingleLogoutHandler (com.sun.identity.federation.services.logout.FSSingleLogoutHandler)1 ProviderDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType)1 HashMap (java.util.HashMap)1 List (java.util.List)1