Search in sources :

Example 6 with FSServiceManager

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

the class FSSSOAndFedService method handleAuthnRequest.

private void handleAuthnRequest(HttpServletRequest request, HttpServletResponse response, FSAuthnRequest authnRequest, boolean bPostAuthn, boolean bLECP, String realm, String hostEntityId, String metaAlias, IDPDescriptorType hostedDesc, BaseConfigType hostedConfig) {
    FSUtils.debug.message("FSSSOAndFedService.handleAuthnRequest: Called");
    Object session = null;
    try {
        SessionProvider provider = SessionManager.getProvider();
        session = provider.getSession(request);
        if ((session != null) && (provider.isValid(session))) {
            MultiProtocolUtils.addFederationProtocol(session, SingleLogoutManager.IDFF);
        }
    } catch (SessionException e) {
        FSUtils.debug.warning("FSSSOFedService.handleAuthnRequest: hub", e);
    }
    try {
        if (!bPostAuthn && !authnRequest.getIsPassive()) {
            FSSessionManager sessionService = FSSessionManager.getInstance(metaAlias);
            sessionService.setAuthnRequest(authnRequest.getRequestID(), authnRequest);
        } else {
            // remove it from authn request map
            FSSessionManager sessionService = FSSessionManager.getInstance(metaAlias);
            sessionService.removeAuthnRequest(authnRequest.getRequestID());
        }
        // handle sso
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSSSOAndFedService.handleAuthnRequest: " + "Trying to handle AuthnRequest message: " + authnRequest.toXMLString());
            List extensions = authnRequest.getExtensions();
            if ((extensions != null) && (!extensions.isEmpty())) {
                FSUtils.debug.message("FSSSOAndFedService.handleAuthnRequest: " + "AuthnRequest extensions: " + ((Extension) extensions.get(0)).getAttributeMap());
                ;
            }
        }
        FSServiceManager sm = FSServiceManager.getInstance();
        FSSSOAndFedHandler handler = null;
        if (!bLECP) {
            handler = sm.getSSOAndFedHandler(request, response, authnRequest, realm);
        } else {
            handler = sm.getLECPProfileHandler(request, response, authnRequest, realm);
        }
        if (handler == null) {
            FSUtils.debug.error("FSSSOAndFedService.handleAuthnRequest: " + "could not create SSOAndFedHandler");
            String[] data = { FSUtils.bundle.getString("requestProcessingFailed") };
            LogUtil.error(Level.INFO, LogUtil.AUTHN_REQUEST_PROCESSING_FAILED, data, session);
            response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString("requestProcessingFailed"));
            return;
        }
        if ((agent != null) && agent.isRunning() && (idffSvc != null)) {
            idffSvc.incIdAuthnRqt();
        }
        handler.setHostedEntityId(hostEntityId);
        handler.setMetaAlias(metaAlias);
        handler.setHostedDescriptor(hostedDesc);
        handler.setHostedDescriptorConfig(hostedConfig);
        handler.setRealm(realm);
        handler.processAuthnRequest(authnRequest, bPostAuthn);
        return;
    } catch (Exception se) {
        FSUtils.debug.error("FSSSOAndFedService: Exception occured:", se);
        try {
            response.sendError(response.SC_INTERNAL_SERVER_ERROR, se.getMessage());
        } catch (IOException ex) {
            FSUtils.debug.error("FSSSOAndFedService: Exception occured " + ex.getMessage());
        }
        return;
    }
}
Also used : Extension(com.sun.identity.federation.message.common.Extension) FSServiceManager(com.sun.identity.federation.services.FSServiceManager) SessionException(com.sun.identity.plugin.session.SessionException) List(java.util.List) IOException(java.io.IOException) FSSessionManager(com.sun.identity.federation.services.FSSessionManager) ServletException(javax.servlet.ServletException) SOAPException(javax.xml.soap.SOAPException) SessionException(com.sun.identity.plugin.session.SessionException) FSException(com.sun.identity.federation.common.FSException) IOException(java.io.IOException) FSAccountMgmtException(com.sun.identity.federation.accountmgmt.FSAccountMgmtException) SessionProvider(com.sun.identity.plugin.session.SessionProvider)

Example 7 with FSServiceManager

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

the class FSAssertionConsumerService method doPost.

/**
     * Handles post profile.
     * @param request <code>HttpServletRequest</code> object
     * @param response <code>HttpServletResponse</code> object
     * @exception ServletException, IOException if error occurs.
     */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    FSUtils.debug.message("FSAssertionConsumerService.doPost : called");
    Document doc = null;
    if ((request == null) || (response == null)) {
        response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString("nullInputParameter"));
        return;
    }
    String metaAlias = FSServiceUtils.getMetaAlias(request);
    String realm = IDFFMetaUtils.getRealmByMetaAlias(metaAlias);
    String baseURL = FSServiceUtils.getBaseURL(request);
    String framedPageURL = FSServiceUtils.getCommonLoginPageURL(metaAlias, null, null, request, baseURL);
    String hostEntityId = null;
    SPDescriptorType hostDesc = null;
    BaseConfigType hostConfig = null;
    try {
        hostEntityId = metaManager.getEntityIDByMetaAlias(metaAlias);
        hostDesc = metaManager.getSPDescriptor(realm, hostEntityId);
        hostConfig = metaManager.getSPDescriptorConfig(realm, hostEntityId);
    } catch (Exception e) {
        FSUtils.debug.error("FSAssertionConsumerService.doPost: " + "Exception when obtain host meta data:", e);
        FSUtils.forwardRequest(request, response, framedPageURL);
        return;
    }
    // obtain AuthnResponse message
    String encodedAuthnResponse = request.getParameter(IFSConstants.POST_AUTHN_RESPONSE_PARAM);
    if (FSUtils.debug.messageEnabled()) {
        FSUtils.debug.message("FSAssertionConsumerService.doPost: " + "Base64 encoded AuthnResponse: " + encodedAuthnResponse);
    }
    if (encodedAuthnResponse == null) {
        String[] data = { FSUtils.bundle.getString("missingAuthnResponse") };
        LogUtil.error(Level.INFO, LogUtil.MISSING_AUTHN_RESPONSE, data);
        FSUtils.debug.error("FSAssertionConsumerService.doPost: " + FSUtils.bundle.getString("missingAuthnResponse") + " AuthnRequest Processing Failed at the IDP" + " Redirecting to the Framed Login Page");
        FSUtils.forwardRequest(request, response, framedPageURL);
        return;
    }
    encodedAuthnResponse = encodedAuthnResponse.replace(' ', '\n');
    if (FSUtils.debug.messageEnabled()) {
        FSUtils.debug.message("FSAssertionConsumerService.doPost: " + "Base64 encoded AuthnResponse2: " + encodedAuthnResponse);
    }
    FSAuthnResponse authnResponse = null;
    try {
        String decodedAuthnResponse = new String(Base64.decode(encodedAuthnResponse));
        FSUtils.debug.message("Decoded authnResponse" + decodedAuthnResponse);
        doc = XMLUtils.toDOMDocument(decodedAuthnResponse, FSUtils.debug);
        if (doc == null) {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("FSAssertionConsumerService.doPost:Error " + "while parsing input xml string");
            }
            throw new FSMsgException("parseError", null);
        }
        authnResponse = new FSAuthnResponse(doc.getDocumentElement());
        if (authnResponse == null) {
            FSUtils.debug.error("FSAssertionConsumerService.doPost: " + "Invalid AuthnResponse. " + "Can't parse Base64 encoded AuthnResponse");
            String[] data = { FSUtils.bundle.getString("invalidAuthnResponse") };
            LogUtil.error(Level.INFO, LogUtil.INVALID_AUTHN_RESPONSE, data);
            FSUtils.debug.error("FSAssertionConsumerService.doPost: " + FSUtils.bundle.getString("invalidAuthnResponse") + " AuthnRequest Processing Failed at the IDP" + " Redirecting to the Framed Login Page");
            FSUtils.forwardRequest(request, response, framedPageURL);
            return;
        }
    } catch (FSException e) {
        FSUtils.debug.error("FSAssertionConsumerService.doPost: " + "Invalid AuthnResponse. FSException" + " occured while parsing Base64 encoded AuthnResponse: ", e);
        String[] data = { FSUtils.bundle.getString("invalidAuthnResponse") };
        LogUtil.error(Level.INFO, LogUtil.INVALID_AUTHN_RESPONSE, data);
        FSUtils.debug.error("FSAssertionConsumerService.doPost: " + FSUtils.bundle.getString("invalidAuthnResponse") + " AuthnRequest Processing Failed at the IDP" + " Redirecting to the Framed Login Page");
        FSUtils.forwardRequest(request, response, framedPageURL);
        return;
    } catch (SAMLException e) {
        FSUtils.debug.error("FSAssertionConsumerService.doPost: " + "Invalid AuthnResponse. SAMLException" + " occurred while parsing Base64 encoded AuthnResponse: ", e);
        String[] data = { FSUtils.bundle.getString("invalidAuthnResponse") };
        LogUtil.error(Level.INFO, LogUtil.INVALID_AUTHN_RESPONSE, data);
        FSUtils.debug.error("FSAssertionConsumerService.doPost: " + FSUtils.bundle.getString("invalidAuthnResponse") + " AuthnRequest Processing Failed at the IDP" + " Redirecting to the Framed Login Page");
        FSUtils.forwardRequest(request, response, framedPageURL);
        return;
    }
    try {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSAssertionConsumerService.doPost: " + "AuthnResponse received is valid: " + authnResponse.toXMLString());
        }
    } catch (FSException e) {
        FSUtils.debug.error("FSAssertionConsumerService.doPost: " + "Invalid AuthnResponse. FSException" + " occurred while calling AuthnResponse.toXMLString(): ", e);
        String[] data = { FSUtils.bundle.getString("invalidAuthnResponse") };
        LogUtil.error(Level.INFO, LogUtil.INVALID_AUTHN_RESPONSE, data);
        FSUtils.debug.error("FSAssertionConsumerService.doPost: " + FSUtils.bundle.getString("invalidAuthnResponse") + " AuthnRequest Processing Failed at the IDP" + " Redirecting to the Framed Login Page");
        FSUtils.forwardRequest(request, response, framedPageURL);
        return;
    }
    FSAuthnRequest authnRequest = null;
    String requestID = authnResponse.getInResponseTo();
    if (requestID == null) {
        FSUtils.debug.error("FSAssertionConsumerService.doPost: " + "Invalid AuthnResponse. AuthnResponse " + "received does not have inResponseTo attribute");
        String[] data = { FSUtils.bundle.getString("invalidAuthnResponse") };
        LogUtil.error(Level.INFO, LogUtil.INVALID_AUTHN_RESPONSE, data);
        FSUtils.debug.error("FSAssertionConsumerService.doPost: " + FSUtils.bundle.getString("invalidAuthnResponse") + " AuthnRequest Processing Failed at the IDP" + " Redirecting to the Framed Login Page");
        FSUtils.forwardRequest(request, response, framedPageURL);
        return;
    }
    if (FSUtils.debug.messageEnabled()) {
        FSUtils.debug.message("FSAssertionConsumerService.doPost: " + "AuthnResponse received is against requestID: " + requestID);
    }
    authnRequest = getInResponseToRequest(requestID, metaAlias);
    if (authnRequest == null) {
        FSUtils.debug.error("FSAssertionConsumerService.doPost: " + "Invalid AuthnResponse. AuthnResponse" + " received does not have an associated AuthnRequest");
        String[] data = { FSUtils.bundle.getString("invalidAuthnResponse") };
        LogUtil.error(Level.INFO, LogUtil.INVALID_AUTHN_RESPONSE, data);
        FSUtils.debug.error("FSAssertionConsumerService.doPost: " + FSUtils.bundle.getString("invalidAuthnResponse") + " AuthnRequest Processing Failed at the IDP" + " Redirecting to the Framed Login Page");
        FSUtils.forwardRequest(request, response, framedPageURL);
        return;
    }
    String framedLoginPageURL = FSServiceUtils.getCommonLoginPageURL(metaAlias, authnRequest.getRelayState(), null, request, baseURL);
    if (FSUtils.debug.messageEnabled()) {
        FSUtils.debug.message("FSAssertionConsumerService.doPost: " + "inResponseTo validation is successful");
    }
    try {
        String idpEntityId = null;
        IDPDescriptorType idpDescriptor = null;
        if (!authnRequest.getProtocolProfile().equals(IFSConstants.SSO_PROF_LECP)) {
            idpEntityId = getProvider(authnResponse.getInResponseTo(), metaAlias);
            idpDescriptor = metaManager.getIDPDescriptor(realm, idpEntityId);
            if (idpEntityId == null || idpDescriptor == null) {
                FSUtils.debug.error("FSAssertionConsumerService.doPost: " + "Invalid AuthnResponse. Sender information " + "not found for the received AuthnResponse");
                String[] data = { FSUtils.bundle.getString("invalidAuthnResponse") };
                LogUtil.error(Level.INFO, LogUtil.INVALID_AUTHN_RESPONSE, data);
                FSUtils.debug.error("FSAssertionConsumerService.doPost: " + FSUtils.bundle.getString("invalidAuthnResponse") + " AuthnRequest Processing Failed at the IDP" + " Redirecting to the Framed Login Page");
                FSUtils.forwardRequest(request, response, framedLoginPageURL);
                return;
            }
            if ((FSServiceUtils.isSigningOn() || (FSServiceUtils.isSigningOptional() && authnRequest.getProtocolProfile().equals(IFSConstants.SSO_PROF_BROWSER_POST))) && !verifyAuthnResponseSignature(doc, idpDescriptor, idpEntityId)) {
                FSUtils.debug.error("FSAssertionConsumerService.doPost: Signature " + "verification failed");
                FSUtils.forwardRequest(request, response, framedLoginPageURL);
                return;
            }
        } else {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("FSAssertionConsumerService.doPost: " + "LECP Profile identified. IDP info is unknown so far" + "Get providerId from the response");
            }
            idpEntityId = authnResponse.getProviderId();
            idpDescriptor = metaManager.getIDPDescriptor(realm, idpEntityId);
        }
        // handle sso
        FSServiceManager sm = FSServiceManager.getInstance();
        FSAssertionArtifactHandler handler = sm.getAssertionArtifactHandler(request, response, authnRequest, authnResponse, idpDescriptor, idpEntityId);
        if (handler == null) {
            FSUtils.debug.error("FSAssertionConsumerService.doPost: " + "could not create AssertionArtifactHandler");
            String[] data = { FSUtils.bundle.getString("requestProcessingFailed") };
            LogUtil.error(Level.INFO, LogUtil.AUTHN_REQUEST_PROCESSING_FAILED, data);
            FSUtils.debug.error("FSAssertionConsumerService.doPost: " + FSUtils.bundle.getString("requestProcessingFailed") + " AuthnRequest Processing Failed at the IDP" + " Redirecting to the Framed Login Page");
            FSUtils.forwardRequest(request, response, framedLoginPageURL);
            return;
        }
        handler.setHostEntityId(hostEntityId);
        handler.setHostDescriptor(hostDesc);
        handler.setHostDescriptorConfig(hostConfig);
        handler.setMetaAlias(metaAlias);
        handler.setRealm(realm);
        handler.processAuthnResponse(authnResponse);
        return;
    } catch (Exception se) {
        FSUtils.debug.error("FSAssertionConsumerService.doPost: " + "Exception: ", se);
        FSUtils.debug.error("FSAssertionConsumerService.doPost: " + FSUtils.bundle.getString("requestProcessingFailed") + " AuthnRequest Processing Failed at the IDP" + " Redirecting to the Framed Login Page");
        FSUtils.forwardRequest(request, response, framedLoginPageURL);
        return;
    }
}
Also used : FSMsgException(com.sun.identity.federation.message.common.FSMsgException) FSAuthnRequest(com.sun.identity.federation.message.FSAuthnRequest) Document(org.w3c.dom.Document) SPDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.SPDescriptorType) SAMLException(com.sun.identity.saml.common.SAMLException) ServletException(javax.servlet.ServletException) SAMLException(com.sun.identity.saml.common.SAMLException) FSException(com.sun.identity.federation.common.FSException) IOException(java.io.IOException) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) IDPDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType) FSServiceManager(com.sun.identity.federation.services.FSServiceManager) FSAuthnResponse(com.sun.identity.federation.message.FSAuthnResponse) FSException(com.sun.identity.federation.common.FSException)

Example 8 with FSServiceManager

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

the class FSRegistrationInitiationServlet method doRegistrationInitiation.

/**
     * Called when a registration needs to be initiated with a remote provider.
     * @param request <code>HTTPServletRequest</code> object received via a 
     *  HTTP Redirect
     * @param response <code>HTTPServletResponse</code> object to send the 
     *  response back to user agent
     * @param hostedProviderDesc the provider where registration is initiated
     * @param hostedConfig the hosted provider's extended meta
     * @param hostedEntityId the hosted provider's entity id
     * @param hostedRole hosted provider's role
     * @param hostedProviderAlias hosted provider's meta alias
     */
private void doRegistrationInitiation(HttpServletRequest request, HttpServletResponse response, ProviderDescriptorType hostedProviderDesc, BaseConfigType hostedConfig, String hostedEntityId, String hostedRole, String hostedProviderAlias) {
    FSUtils.debug.message("Entered FSRegistrationInitiationServlet::doRegistrationInitiation");
    try {
        Object ssoToken = getValidToken(request);
        if (ssoToken != null) {
            String providerId = request.getParameter(IFSConstants.REGISTRATION_PROVIDER_ID);
            if (providerId == null || providerId.length() < 1) {
                FSUtils.debug.error("Provider Id not found, display error page");
                FSServiceUtils.showErrorPage(response, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_NO_PROVIDER, IFSConstants.CONTACT_ADMIN);
                return;
            }
            // session is valid, ProviderId available
            FSServiceManager instSManager = FSServiceManager.getInstance();
            if (instSManager != null) {
                FSUtils.debug.message("FSServiceManager Instance not null");
                String remoteProviderRole = IFSConstants.SP;
                FSAccountFedInfo fedinfo = null;
                if (hostedRole.equalsIgnoreCase(IFSConstants.SP)) {
                    remoteProviderRole = IFSConstants.IDP;
                    FSSessionManager sessManager = FSSessionManager.getInstance(hostedProviderAlias);
                    FSSession ssoSession = sessManager.getSession(ssoToken);
                    if (ssoSession != null) {
                        if (!ssoSession.getOneTime()) {
                            fedinfo = ssoSession.getAccountFedInfo();
                        }
                    }
                }
                SessionProvider sessionProvider = SessionManager.getProvider();
                FSNameRegistrationHandler handlerObj = instSManager.getNameRegistrationHandler(providerId, remoteProviderRole, sessionProvider.getPrincipalName(ssoToken), hostedEntityId, hostedProviderAlias);
                if (handlerObj != null) {
                    handlerObj.setHostedDescriptor(hostedProviderDesc);
                    handlerObj.setHostedDescriptorConfig(hostedConfig);
                    handlerObj.setMetaAlias(hostedProviderAlias);
                    handlerObj.setHostedProviderRole(hostedRole);
                    handlerObj.setHostedEntityId(hostedEntityId);
                    if (fedinfo != null) {
                        handlerObj.setAccountInfo(fedinfo);
                    }
                    boolean bStatus = handlerObj.handleNameRegistration(request, response, ssoToken);
                    if (FSUtils.debug.messageEnabled()) {
                        FSUtils.debug.message("handleNameRegistration status is : " + bStatus);
                    }
                    return;
                } else {
                    if (FSUtils.debug.messageEnabled()) {
                        FSUtils.debug.message("Unable to get registration " + "handler. User account Not valid");
                    }
                }
            } else {
                FSUtils.debug.message("FSServiceManager Instance null");
            }
            FSServiceUtils.returnLocallyAfterOperation(response, REGISTRATION_DONE_URL, false, IFSConstants.REGISTRATION_SUCCESS, IFSConstants.REGISTRATION_FAILURE);
            return;
        } else {
            FSServiceUtils.redirectForAuthentication(request, response, hostedProviderAlias);
            return;
        }
    } catch (IOException e) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("IOException in doRegistrationInitiation:", e);
        }
    } catch (SessionException ex) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("SessionException in doRegistrationInitiation", ex);
        }
    }
    FSServiceUtils.returnLocallyAfterOperation(response, REGISTRATION_DONE_URL, false, IFSConstants.REGISTRATION_SUCCESS, IFSConstants.REGISTRATION_FAILURE);
}
Also used : FSServiceManager(com.sun.identity.federation.services.FSServiceManager) FSAccountFedInfo(com.sun.identity.federation.accountmgmt.FSAccountFedInfo) FSSession(com.sun.identity.federation.services.FSSession) SessionException(com.sun.identity.plugin.session.SessionException) IOException(java.io.IOException) FSSessionManager(com.sun.identity.federation.services.FSSessionManager) SessionProvider(com.sun.identity.plugin.session.SessionProvider)

Example 9 with FSServiceManager

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

the class FSAssertionConsumerService method doGet.

/**
     * Handles artifact profile.
     * @param request <code>HttpServletRequest</code> object
     * @param response <code>HttpServletResponse</code> object
     * @exception ServletException, IOException if error occurrs.
     */
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    if ((request == null) || (response == null)) {
        response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString("nullInputParameter"));
        return;
    }
    FSUtils.debug.message("FSAssertionConsumerService.doGet(): called");
    String relayState = request.getParameter(IFSConstants.LRURL);
    if (FSUtils.debug.messageEnabled()) {
        FSUtils.debug.message("FSAssertionConsumerService.doGet():Resource URL: " + relayState);
    }
    String metaAlias = FSServiceUtils.getMetaAlias(request);
    String realm = IDFFMetaUtils.getRealmByMetaAlias(metaAlias);
    String baseURL = FSServiceUtils.getBaseURL(request);
    String framedPageURL = FSServiceUtils.getCommonLoginPageURL(metaAlias, relayState, null, request, baseURL);
    if (FSUtils.debug.messageEnabled()) {
        FSUtils.debug.message("FSAssertionConsumerService: CommonLoginPage: " + framedPageURL);
    }
    SPDescriptorType hostDesc = null;
    BaseConfigType hostConfig = null;
    String hostEntityId = null;
    try {
        hostEntityId = metaManager.getEntityIDByMetaAlias(metaAlias);
        hostDesc = metaManager.getSPDescriptor(realm, hostEntityId);
        hostConfig = metaManager.getSPDescriptorConfig(realm, hostEntityId);
    } catch (Exception e) {
        FSUtils.debug.error("FSAssertionConsumerService.doGet: ", e);
        FSUtils.forwardRequest(request, response, framedPageURL);
        return;
    }
    FSRequest samlRequest = null;
    String firstSourceID = null;
    String artifactName = IFSConstants.ARTIFACT_NAME_DEFAULT;
    String[] arti = (String[]) request.getParameterValues(artifactName);
    if ((arti == null) || (arti.length < 0) || (arti[0] == null)) {
        FSUtils.debug.error("FSAssertionConsumerService.doGet: " + "AuthnRequest Processing Failed at the IDP " + "Redirecting to the Framed Login Page");
        FSUtils.forwardRequest(request, response, framedPageURL);
    }
    List al = new ArrayList();
    try {
        FSAssertionArtifact firstArtifact = new FSAssertionArtifact(arti[0]);
        firstSourceID = firstArtifact.getSourceID();
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSAssertionConsumerService.doGet: " + "SourceID within the Artifact is " + firstSourceID);
        }
        al.add(firstArtifact);
        for (int k = 1; k < arti.length; k++) {
            // check all artifacts coming from the same source id
            FSAssertionArtifact assertArtifact = new FSAssertionArtifact(arti[k]);
            String dest = assertArtifact.getSourceID();
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("FSAssertionConsumerService.doGet: " + "SourceID within the Artifact is " + dest);
            }
            if (!dest.equals(firstSourceID)) {
                FSUtils.debug.error("FSAssertionConsumerService.doGet: " + "Received multiple artifacts have different source id");
                FSUtils.forwardRequest(request, response, framedPageURL);
                return;
            }
            al.add(assertArtifact);
        }
        samlRequest = new FSRequest(null, al);
    } catch (SAMLException se) {
        FSUtils.debug.error("FSAssertionConsumerService.doGet: ", se);
        FSUtils.forwardRequest(request, response, framedPageURL);
        return;
    } catch (FSMsgException se) {
        FSUtils.debug.error("FSAssertionConsumerService.doGet: ", se);
        FSUtils.forwardRequest(request, response, framedPageURL);
        return;
    }
    try {
        // handle sso
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSAssertionConsumerService.doGet: " + "Trying to get BrowserArtifactHandler");
        }
        FSServiceManager sm = FSServiceManager.getInstance();
        FSAssertionArtifactHandler handler = sm.getBrowserArtifactHandler(request, response, realm, firstSourceID, samlRequest, relayState);
        if (handler == null) {
            FSUtils.debug.error("FSAssertionConsumerService.doGet: " + FSUtils.bundle.getString("internalError"));
            FSUtils.forwardRequest(request, response, framedPageURL);
            return;
        }
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSAssertionConsumerService.doGet: " + "BrowserArtifactHandler created");
        }
        handler.setRealm(realm);
        handler.setHostEntityId(hostEntityId);
        handler.setMetaAlias(metaAlias);
        handler.setHostDescriptor(hostDesc);
        handler.setHostDescriptorConfig(hostConfig);
        handler.processSAMLRequest();
        return;
    } catch (Exception e) {
        FSUtils.debug.error("FSAssertionConsumerService.doGet: " + "Exception occurred :", e);
        FSUtils.forwardRequest(request, response, framedPageURL);
        return;
    }
}
Also used : FSMsgException(com.sun.identity.federation.message.common.FSMsgException) ArrayList(java.util.ArrayList) SPDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.SPDescriptorType) SAMLException(com.sun.identity.saml.common.SAMLException) ServletException(javax.servlet.ServletException) SAMLException(com.sun.identity.saml.common.SAMLException) FSException(com.sun.identity.federation.common.FSException) IOException(java.io.IOException) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) FSServiceManager(com.sun.identity.federation.services.FSServiceManager) ArrayList(java.util.ArrayList) List(java.util.List) FSAssertionArtifact(com.sun.identity.federation.message.FSAssertionArtifact) FSRequest(com.sun.identity.federation.message.FSRequest)

Aggregations

FSServiceManager (com.sun.identity.federation.services.FSServiceManager)9 FSException (com.sun.identity.federation.common.FSException)6 IOException (java.io.IOException)6 SessionException (com.sun.identity.plugin.session.SessionException)4 SAMLException (com.sun.identity.saml.common.SAMLException)4 ServletException (javax.servlet.ServletException)4 FSSessionManager (com.sun.identity.federation.services.FSSessionManager)3 FSAccountFedInfo (com.sun.identity.federation.accountmgmt.FSAccountFedInfo)2 FSAccountMgmtException (com.sun.identity.federation.accountmgmt.FSAccountMgmtException)2 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)2 FSMsgException (com.sun.identity.federation.message.common.FSMsgException)2 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)2 FSSession (com.sun.identity.federation.services.FSSession)2 ProviderDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType)2 SPDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.SPDescriptorType)2 SessionProvider (com.sun.identity.plugin.session.SessionProvider)2 List (java.util.List)2 SOAPException (javax.xml.soap.SOAPException)2 FSAssertionArtifact (com.sun.identity.federation.message.FSAssertionArtifact)1 FSAuthnRequest (com.sun.identity.federation.message.FSAuthnRequest)1