Search in sources :

Example 46 with FSSessionManager

use of com.sun.identity.federation.services.FSSessionManager in project OpenAM by OpenRock.

the class FSAssertionConsumerService method getInResponseToRequest.

private FSAuthnRequest getInResponseToRequest(String requestID, String metaAlias) {
    FSUtils.debug.message("FSAssertionConsumerService::getInResponseToRequest: Called");
    FSSessionManager sessionManager = FSSessionManager.getInstance(metaAlias);
    return sessionManager.getAuthnRequest(requestID);
}
Also used : FSSessionManager(com.sun.identity.federation.services.FSSessionManager)

Example 47 with FSSessionManager

use of com.sun.identity.federation.services.FSSessionManager 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)

Example 48 with FSSessionManager

use of com.sun.identity.federation.services.FSSessionManager in project OpenAM by OpenRock.

the class LibertyManager method getAuthnContext.

/**
     * Returns the authentication context used in liberty single sign-on.
     * After single sign-on with an Identity Provider, a service
     * provider may obtain the authentication context used by the identity
     * provider that authenticates the user. It will need to have a valid
     * single sign on token (generated through the liberty SSO).
     *
     * @param request <code>HttpServletRequest</code> associated with a user
     *  session.
     * @param realm the realm in which the provider resides
     * @param entityID Hosted Provider's entity ID
     * @return authentication context string;
     *         <code>null</code> if there is any failure, or no liberty
     *         session is found.
     */
public static String getAuthnContext(HttpServletRequest request, String realm, String entityID) {
    if (request == null || entityID == null) {
        debug.message("LibertyManager.getAuthnContext: null Input params");
        return null;
    }
    try {
        Object token = SessionManager.getProvider().getSession(request);
        FSSessionManager sessionManager = FSSessionManager.getInstance(getMetaAlias(realm, entityID, IFSConstants.SP));
        FSSession session = sessionManager.getSession(token);
        if (session == null) {
            if (debug.messageEnabled()) {
                debug.message("LibertyManager.getAuthnContext" + ": There is no liberty session for this token");
            }
            return null;
        }
        return session.getAuthnContext();
    } catch (Exception ex) {
        FSUtils.debug.error("LibertyManager.getAuthnContext" + " Exception while retrieving authncontext.", ex);
        return null;
    }
}
Also used : FSSession(com.sun.identity.federation.services.FSSession) FSSessionManager(com.sun.identity.federation.services.FSSessionManager) COTException(com.sun.identity.cot.COTException) SessionException(com.sun.identity.plugin.session.SessionException) SAMLException(com.sun.identity.saml.common.SAMLException) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) FSLoginHelperException(com.sun.identity.federation.services.FSLoginHelperException) FSAccountMgmtException(com.sun.identity.federation.accountmgmt.FSAccountMgmtException) FSMsgException(com.sun.identity.federation.message.common.FSMsgException)

Aggregations

FSSessionManager (com.sun.identity.federation.services.FSSessionManager)48 FSSession (com.sun.identity.federation.services.FSSession)30 SessionException (com.sun.identity.plugin.session.SessionException)29 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)19 IOException (java.io.IOException)19 FSAccountMgmtException (com.sun.identity.federation.accountmgmt.FSAccountMgmtException)18 SAMLException (com.sun.identity.saml.common.SAMLException)16 FSSessionPartner (com.sun.identity.federation.services.FSSessionPartner)13 List (java.util.List)13 FSException (com.sun.identity.federation.common.FSException)12 HashMap (java.util.HashMap)11 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)10 FSMsgException (com.sun.identity.federation.message.common.FSMsgException)10 SAMLResponderException (com.sun.identity.saml.common.SAMLResponderException)10 Iterator (java.util.Iterator)10 SessionProvider (com.sun.identity.plugin.session.SessionProvider)9 ServletException (javax.servlet.ServletException)9 FSAccountFedInfo (com.sun.identity.federation.accountmgmt.FSAccountFedInfo)8 IDPDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType)8 COTException (com.sun.identity.cot.COTException)7