Search in sources :

Example 21 with FSException

use of com.sun.identity.federation.common.FSException in project OpenAM by OpenRock.

the class LibertyManagerClient method getDiscoveryResourceOffering.

/**
     * Returns the discovery service bootstrap resource offering. 
     * @param token Single Sign On Token.
     * @param hostProviderID Hosted <code>ProviderID</code>.
     * @return <code>ResourceOffering</code> Discovery Service bootstrap
     *  resource offering.
     * @exception FSException if any failure.
     */
public ResourceOffering getDiscoveryResourceOffering(Object token, String hostProviderID) throws FSException {
    try {
        SessionProvider sessionProvider = SessionManager.getProvider();
        String tokenID = sessionProvider.getSessionID(token);
        String cacheKey = tokenID + DISCO_RO;
        ResourceOffering ro = (ResourceOffering) bootStrapCache.get(cacheKey);
        if (ro != null) {
            return ro;
        }
        String[] objs = { tokenID, hostProviderID };
        String resourceOffering = (String) client.send("getDiscoveryResourceOffering", objs, null, null);
        if ((resourceOffering == null) || (resourceOffering.length() == 0)) {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("LibertyManagerClient.getDiscovery" + "ResourceOffering: ResouceOffering is null or empty");
            }
            return null;
        }
        Document doc = XMLUtils.toDOMDocument(resourceOffering, FSUtils.debug);
        ro = new ResourceOffering(doc.getDocumentElement());
        sessionProvider.addListener(token, new LibertyClientSSOTokenListener());
        bootStrapCache.put(cacheKey, ro);
        return ro;
    } catch (SessionException se) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("LibertyManagerClient.getDiscovery" + "ResourceOffering: InvalidSessionToken", se);
        }
        throw new FSException(FSUtils.bundle.getString("invalidSSOToken"));
    } catch (DiscoveryException de) {
        FSUtils.debug.error("LibertyManagerClient.getDiscovery" + "ResourceOffering: Invalid ResourceOffering", de);
        throw new FSException(FSUtils.bundle.getString("invalidResourceOffering"));
    } catch (Exception ex) {
        FSUtils.debug.error("LibertyManagerClient.getDiscovery" + "ResourceOffering: SOAPClient Exception", ex);
        throw new FSException(FSUtils.bundle.getString("soapException"));
    }
}
Also used : ResourceOffering(com.sun.identity.liberty.ws.disco.ResourceOffering) FSException(com.sun.identity.federation.common.FSException) SessionException(com.sun.identity.plugin.session.SessionException) Document(org.w3c.dom.Document) DiscoveryException(com.sun.identity.liberty.ws.disco.DiscoveryException) DiscoveryException(com.sun.identity.liberty.ws.disco.DiscoveryException) SessionException(com.sun.identity.plugin.session.SessionException) FSException(com.sun.identity.federation.common.FSException) SessionProvider(com.sun.identity.plugin.session.SessionProvider)

Example 22 with FSException

use of com.sun.identity.federation.common.FSException in project OpenAM by OpenRock.

the class FSProcessLogoutServlet method doRequestProcessing.

/**
     * Initiates logout request processing. It is called when a logout request
     * is received from a remote provider.
     * @param request <code>HTTPServletRequest</code> object received via a
     *  HTTP Redirect
     * @param response <code>HTTPServletResponse</code> object to be sent back
     *  to user agent
     * @param hostedDescriptor the provider for whom request is received
     * @param hostedConfig hosted provider's extended meta config
     * @param hostedRole hosted provider's role
     * @param realm the realm in which the entity resides
     * @param hostedEntityId hosted provider's entity id
     * @param metaAlias hosted provider's meta alias
     * @param reqLogout the single logout request
     * @param commonErrorPage where to go if an error occurred
     * @param userID user id
     * @param ssoToken user session object
     */
private void doRequestProcessing(HttpServletRequest request, HttpServletResponse response, ProviderDescriptorType hostedDescriptor, BaseConfigType hostedConfig, String hostedRole, String realm, String hostedEntityId, String metaAlias, FSLogoutNotification reqLogout, String commonErrorPage, String userID, Object ssoToken) {
    FSUtils.debug.message("Entered FSProcessLogoutServlet::doRequestProcessing");
    int minorVersion = reqLogout.getMinorVersion();
    String remoteEntityId = reqLogout.getProviderId();
    ProviderDescriptorType remoteDesc = null;
    boolean isIDP = false;
    try {
        if (hostedRole != null) {
            if (hostedRole.equalsIgnoreCase(IFSConstants.IDP)) {
                remoteDesc = metaManager.getSPDescriptor(realm, remoteEntityId);
            } else if (hostedRole.equalsIgnoreCase(IFSConstants.SP)) {
                remoteDesc = metaManager.getIDPDescriptor(realm, remoteEntityId);
                isIDP = true;
            }
        }
        if (remoteDesc == null) {
            throw new IDFFMetaException((String) null);
        }
    } catch (IDFFMetaException e) {
        FSUtils.debug.error("Remote provider metadata not found.");
        String[] data = { remoteEntityId, realm };
        LogUtil.error(Level.INFO, LogUtil.INVALID_PROVIDER, data, ssoToken);
        FSLogoutUtil.returnToSource(response, remoteDesc, IFSConstants.SAML_RESPONDER, commonErrorPage, minorVersion, hostedConfig, hostedEntityId, userID);
        return;
    }
    boolean bVerify = true;
    if (FSServiceUtils.isSigningOn()) {
        try {
            FSUtils.debug.message("Calling verifyLogoutSignature");
            bVerify = verifyLogoutSignature(request, remoteDesc, remoteEntityId, isIDP);
        } catch (FSException e) {
            FSUtils.debug.error("FSProcessLogoutServlet::doRequestProcessing " + "Signature on Logout request is invalid" + "Cannot proceed federation Logout");
            String[] data = { userID };
            LogUtil.error(Level.INFO, LogUtil.INVALID_SIGNATURE, data, ssoToken);
            FSLogoutUtil.returnToSource(response, remoteDesc, IFSConstants.SAML_REQUESTER, commonErrorPage, minorVersion, hostedConfig, hostedEntityId, userID);
            return;
        } catch (SAMLException e) {
            FSUtils.debug.error("FSProcessLogoutServlet::doRequestProcessing(SAML) " + "Signature on Logout request is invalid" + "Cannot proceed federation Logout");
            String[] data = { userID };
            LogUtil.error(Level.INFO, LogUtil.INVALID_SIGNATURE, data, ssoToken);
            FSLogoutUtil.returnToSource(response, remoteDesc, IFSConstants.SAML_REQUESTER, commonErrorPage, minorVersion, hostedConfig, hostedEntityId, userID);
            return;
        }
    }
    String errorStatus = IFSConstants.SAML_RESPONDER;
    if (bVerify) {
        // Check if trusted provider
        if (metaManager.isTrustedProvider(realm, hostedEntityId, remoteEntityId)) {
            //Object ssoToken = getValidToken(request);
            if (ssoToken != null) {
                // session is valid, start single logout
                // Invoke Messaging APIs to get providerid from request
                FSServiceManager instSManager = FSServiceManager.getInstance();
                if (instSManager != null) {
                    FSUtils.debug.message("FSServiceManager Instance not null");
                    // Call SP Adapter preSingleLogoutProcess
                    // for IDP/HTTP case
                    callPreSingleLogoutProcess(request, response, hostedRole, hostedConfig, hostedEntityId, userID, reqLogout);
                    FSPreLogoutHandler handlerObj = instSManager.getPreLogoutHandler();
                    if (handlerObj != null) {
                        handlerObj.setLogoutRequest(reqLogout);
                        handlerObj.setHostedDescriptor(hostedDescriptor);
                        handlerObj.setHostedDescriptorConfig(hostedConfig);
                        handlerObj.setRealm(realm);
                        handlerObj.setHostedEntityId(hostedEntityId);
                        handlerObj.setHostedProviderRole(hostedRole);
                        handlerObj.setMetaAlias(metaAlias);
                        handlerObj.setRemoteEntityId(remoteEntityId);
                        handlerObj.setRemoteDescriptor(remoteDesc);
                        handlerObj.processHttpSingleLogoutRequest(request, response, ssoToken);
                        return;
                    }
                } else {
                    if (FSUtils.debug.messageEnabled()) {
                        FSUtils.debug.message("FSServiceManager Instance null. Cannot" + " continue logout");
                    }
                    String[] data = { userID };
                    LogUtil.error(Level.INFO, LogUtil.LOGOUT_FAILED, data, ssoToken);
                    FSLogoutUtil.returnToSource(response, remoteDesc, IFSConstants.SAML_RESPONDER, commonErrorPage, minorVersion, hostedConfig, hostedEntityId, userID);
                    return;
                }
            } else {
                // ssoToken is null
                if (FSUtils.debug.messageEnabled()) {
                    FSUtils.debug.message("Invalid session in request processing. " + "Nothing to logout");
                }
                //Verify request,getUserDNcall destroyPrincipalSession
                userID = FSLogoutUtil.getUserFromRequest(reqLogout, realm, hostedEntityId, hostedRole, hostedConfig, metaAlias);
                if (userID != null) {
                    FSLogoutUtil.destroyPrincipalSession(userID, metaAlias, reqLogout.getSessionIndex(), request, response);
                    // Here we need to send back to source
                    // provider's return URL
                    FSLogoutUtil.returnToSource(response, remoteDesc, IFSConstants.SAML_RESPONDER, commonErrorPage, minorVersion, hostedConfig, hostedEntityId, userID);
                    return;
                }
            }
        } else {
            FSUtils.debug.error("Remote provider not in trusted list");
        }
    } else {
        FSUtils.debug.error("FSProcessLogoutServlet::doRequestProcesing " + "Signature on Logout request is invalid" + "Cannot proceed federation Logout");
        String[] data = { userID };
        LogUtil.error(Level.INFO, LogUtil.INVALID_SIGNATURE, data, ssoToken);
        errorStatus = IFSConstants.SAML_REQUESTER;
    }
    FSLogoutUtil.returnToSource(response, remoteDesc, errorStatus, commonErrorPage, minorVersion, hostedConfig, hostedEntityId, userID);
    return;
}
Also used : FSServiceManager(com.sun.identity.federation.services.FSServiceManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) ProviderDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType) FSException(com.sun.identity.federation.common.FSException) SAMLException(com.sun.identity.saml.common.SAMLException)

Example 23 with FSException

use of com.sun.identity.federation.common.FSException in project OpenAM by OpenRock.

the class FSReturnLogoutServlet method doGetPost.

/**
     * Processes logout response.
     * @param request an <code>HttpServletRequest</code> object that contains 
     *  the request the client has made of the servlet.
     * @param response an <code>HttpServletResponse</code> object that contains
     *  the response the servlet sends to the client.
     * @exception ServletException if an input or output error is detected when
     *                             the servlet handles the request
     * @exception IOException if the request could not be handled
     */
private void doGetPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    FSUtils.debug.message("FSReturnLogoutServlet doGetPost...");
    // Alias processing
    String providerAlias = request.getParameter(IFSConstants.META_ALIAS);
    if (providerAlias == null || providerAlias.length() < 1) {
        providerAlias = FSServiceUtils.getMetaAlias(request);
    }
    if (providerAlias == null || providerAlias.length() < 1) {
        FSUtils.debug.message("Unable to retrieve alias, Hosted" + " Provider. Cannot process request");
        response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString("aliasNotFound"));
        return;
    }
    Object ssoToken = null;
    try {
        SessionProvider sessionProvider = SessionManager.getProvider();
        ssoToken = sessionProvider.getSession(request);
        if ((ssoToken == null) || (!sessionProvider.isValid(ssoToken))) {
            FSUtils.debug.message("FSReturnLogoutRequest: Unable to get principal");
            response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString("nullSSOToken"));
            return;
        }
        univId = sessionProvider.getPrincipalName(ssoToken);
    } catch (SessionException ssoExp) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSReturnLogoutRequest: Unable to get principal", ssoExp);
        }
        response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString("nullSSOToken"));
        return;
    }
    if (metaManager == null) {
        FSUtils.debug.error("Failed to get meta manager");
        response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString(IFSConstants.FEDERATION_FAILED_META_INSTANCE));
        return;
    }
    String realm = IDFFMetaUtils.getRealmByMetaAlias(providerAlias);
    String hostedRole = null;
    String hostedEntityId = null;
    BaseConfigType hostedConfig = null;
    try {
        hostedRole = metaManager.getProviderRoleByMetaAlias(providerAlias);
        hostedEntityId = metaManager.getEntityIDByMetaAlias(providerAlias);
        if (hostedRole != null) {
            if (hostedRole.equalsIgnoreCase(IFSConstants.IDP)) {
                hostedConfig = metaManager.getIDPDescriptorConfig(realm, hostedEntityId);
            } else if (hostedRole.equalsIgnoreCase(IFSConstants.SP)) {
                hostedConfig = metaManager.getSPDescriptorConfig(realm, hostedEntityId);
            }
        }
        if (hostedConfig == null) {
            throw new IDFFMetaException((String) null);
        }
    } catch (IDFFMetaException e) {
        FSUtils.debug.error("Failed to get Hosted Provider");
        response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString(IFSConstants.FAILED_HOSTED_DESCRIPTOR));
        return;
    }
    setLogoutURL(request, hostedConfig, providerAlias);
    // Here we will need to
    //   1. verify response signature
    //   2. verify response status
    //   3. retrieve registration request Id from Map
    //   4. if status success then do locally else not do locally and
    //   5. show status page or LRURL if found in MAP (eg intersiteTransfer)
    FSLogoutResponse logoutResponse = null;
    try {
        logoutResponse = FSLogoutResponse.parseURLEncodedRequest(request);
    } catch (FSMsgException e) {
        FSServiceUtils.showErrorPage(response, COMMON_ERROR_PAGE, IFSConstants.LOGOUT_REQUEST_IMPROPER, IFSConstants.LOGOUT_FAILED);
        return;
    } catch (SAMLException e) {
        FSServiceUtils.showErrorPage(response, COMMON_ERROR_PAGE, IFSConstants.LOGOUT_REQUEST_IMPROPER, IFSConstants.LOGOUT_FAILED);
        return;
    }
    String remoteEntityId = logoutResponse.getProviderId();
    ProviderDescriptorType remoteDesc = null;
    boolean isRemoteIDP = false;
    try {
        if (hostedRole.equalsIgnoreCase(IFSConstants.IDP)) {
            remoteDesc = metaManager.getSPDescriptor(realm, remoteEntityId);
        } else if (hostedRole.equalsIgnoreCase(IFSConstants.SP)) {
            remoteDesc = metaManager.getIDPDescriptor(realm, remoteEntityId);
            isRemoteIDP = true;
        }
    } catch (IDFFMetaException e) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSLogoutReturnServlet.doGetPost:", e);
        }
    }
    if (remoteDesc == null) {
        FSServiceUtils.showErrorPage(response, COMMON_ERROR_PAGE, IFSConstants.LOGOUT_REQUEST_IMPROPER, IFSConstants.LOGOUT_FAILED);
        return;
    }
    boolean bVerify = true;
    if (FSServiceUtils.isSigningOn()) {
        try {
            bVerify = verifyResponseSignature(request, remoteDesc, remoteEntityId, isRemoteIDP);
        } catch (SAMLException e) {
            bVerify = false;
        } catch (FSException e) {
            bVerify = false;
        }
    }
    Status status = logoutResponse.getStatus();
    String logoutStatus = status.getStatusCode().getValue();
    // remove session partner in case of logout success or this is IDP
    if (logoutStatus.equalsIgnoreCase(IFSConstants.SAML_SUCCESS) || !isRemoteIDP) {
        FSLogoutUtil.removeCurrentSessionPartner(providerAlias, remoteEntityId, ssoToken, univId);
    }
    if (bVerify) {
        // in ReturnSessionManager only if it is failure
        if (!logoutStatus.equalsIgnoreCase(IFSConstants.SAML_SUCCESS)) {
            FSReturnSessionManager localManager = FSReturnSessionManager.getInstance(providerAlias);
            if (localManager != null) {
                if (FSUtils.debug.messageEnabled()) {
                    FSUtils.debug.message("update status of logout to failure " + " in session manager");
                }
                localManager.setLogoutStatus(logoutStatus, univId);
            } else {
                FSUtils.debug.message("Cannot get FSReturnSessionManager");
            }
            FSUtils.debug.error("FSReturnLogoutServlet, failed logout response " + logoutStatus);
            String[] data = { univId };
            LogUtil.error(Level.INFO, LogUtil.LOGOUT_FAILED, data, ssoToken);
            FSLogoutUtil.sendErrorPage(request, response, providerAlias);
            return;
        }
    } else {
        FSUtils.debug.error("FSReturnLogoutServlet " + "Signature on logout response is invalid" + "Cannot proceed logout");
        String[] data = { univId };
        LogUtil.error(Level.INFO, LogUtil.INVALID_SIGNATURE, data, ssoToken);
        FSServiceUtils.showErrorPage(response, COMMON_ERROR_PAGE, IFSConstants.LOGOUT_REQUEST_IMPROPER, IFSConstants.LOGOUT_FAILED);
        return;
    }
    StringBuffer processLogout = new StringBuffer();
    request.setAttribute("logoutSource", "remote");
    processLogout.append(IFSConstants.SLO_VALUE).append("/").append(IFSConstants.META_ALIAS).append(providerAlias);
    if (FSUtils.debug.messageEnabled()) {
        FSUtils.debug.message("About to get RequestDispatcher for " + processLogout.toString());
    }
    RequestDispatcher dispatcher = getServletConfig().getServletContext().getRequestDispatcher(processLogout.toString());
    if (dispatcher == null) {
        FSUtils.debug.message("RequestDispatcher is null");
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("Unable to find " + processLogout + "\ncalling sendErrorPage ");
        }
        FSLogoutUtil.sendErrorPage(request, response, providerAlias);
        return;
    }
    dispatcher.forward(request, response);
    return;
}
Also used : Status(com.sun.identity.saml.protocol.Status) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) ProviderDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType) SessionException(com.sun.identity.plugin.session.SessionException) FSLogoutResponse(com.sun.identity.federation.message.FSLogoutResponse) SAMLException(com.sun.identity.saml.common.SAMLException) RequestDispatcher(javax.servlet.RequestDispatcher) BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) FSException(com.sun.identity.federation.common.FSException) SessionProvider(com.sun.identity.plugin.session.SessionProvider)

Example 24 with FSException

use of com.sun.identity.federation.common.FSException in project OpenAM by OpenRock.

the class FSSSOAndFedHandler method getNewAuthnRequest.

/**
     * Constructs new authentication request by using the original request
     * that is sent by the service provider to the proxying IDP.
     * @param origRequest Original Authn Request
     * @return FSAuthnRequest new authn request.
     * @exception FSException for failure in creating new authn request.
     */
private FSAuthnRequest getNewAuthnRequest(FSAuthnRequest origRequest) throws FSException {
    try {
        FSAuthnRequest newRequest = new FSAuthnRequest(null, origRequest.getRespondWith(), hostedEntityId, origRequest.getForceAuthn(), origRequest.getIsPassive(), false, origRequest.getNameIDPolicy(), origRequest.getProtocolProfile(), origRequest.getAuthnContext(), origRequest.getRelayState(), origRequest.getAuthContextCompType());
        newRequest.setMinorVersion(IFSConstants.FF_12_PROTOCOL_MINOR_VERSION);
        FSScoping scoping = origRequest.getScoping();
        if (scoping != null) {
            int proxyCount = scoping.getProxyCount();
            if (proxyCount > 0) {
                FSScoping newScoping = new FSScoping();
                newScoping.setProxyCount(proxyCount - 1);
                newScoping.setIDPList(scoping.getIDPList());
                newRequest.setScoping(newScoping);
            }
        }
        return newRequest;
    } catch (Exception ex) {
        FSUtils.debug.error("FSSSOAndFedHandler.getNewAuthnRequest:" + "Error in creating new authn request.", ex);
        throw new FSException(ex);
    }
}
Also used : FSAuthnRequest(com.sun.identity.federation.message.FSAuthnRequest) FSException(com.sun.identity.federation.common.FSException) FSScoping(com.sun.identity.federation.message.FSScoping) SessionException(com.sun.identity.plugin.session.SessionException) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) FSAccountMgmtException(com.sun.identity.federation.accountmgmt.FSAccountMgmtException) SAMLException(com.sun.identity.saml.common.SAMLException) FSException(com.sun.identity.federation.common.FSException) IOException(java.io.IOException) FSRedirectException(com.sun.identity.federation.common.FSRedirectException)

Example 25 with FSException

use of com.sun.identity.federation.common.FSException in project OpenAM by OpenRock.

the class FSSSOAndFedHandler method verifyRequestSignature.

protected boolean verifyRequestSignature(FSAuthnRequest authnRequest) {
    FSUtils.debug.message("FSSSOAndFedHandler.verifyRequestSignature: Called");
    try {
        X509Certificate cert = KeyUtil.getVerificationCert(spDescriptor, spEntityId, false);
        if (cert == null) {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("FSSSOAndFedHandler.verifyRequestSignature: " + "couldn't obtain this site's cert.");
            }
            throw new FSException(IFSConstants.NO_CERT, null);
        }
        if (request.getMethod().equals("GET")) {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("FSSSOAndFedHandler.verifyRequestSignature: " + "Request is sent by GET");
            }
            String sigAlg = request.getParameter("SigAlg");
            String encSig = request.getParameter("Signature");
            if (sigAlg == null || sigAlg.length() == 0 || encSig == null || encSig.length() == 0) {
                return false;
            }
            String algoId = null;
            if (sigAlg.equals(IFSConstants.ALGO_ID_SIGNATURE_DSA)) {
                algoId = IFSConstants.ALGO_ID_SIGNATURE_DSA_JCA;
            } else if (sigAlg.equals(IFSConstants.ALGO_ID_SIGNATURE_RSA)) {
                algoId = IFSConstants.ALGO_ID_SIGNATURE_RSA_JCA;
            } else {
                FSUtils.debug.error("FSSSOAndFedHandler.signAndReturnQueryString: " + "Invalid signature algorithim");
                return false;
            }
            String queryString = request.getQueryString();
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("FSSSOAndFedHandler.verifyRequest" + "Signature: queryString:" + queryString);
            }
            int sigIndex = queryString.indexOf("&Signature");
            String newQueryString = queryString.substring(0, sigIndex);
            byte[] signature = null;
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("FSSSOAndFedHandler.verifyRequestSignature: " + "Signature: " + encSig + "Algorithm: " + algoId);
            }
            signature = Base64.decode(encSig);
            FSSignatureManager fsmanager = FSSignatureManager.getInstance();
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("FSSSOAndFedHandler.verifyRequestSignature: " + "String to be verified: " + newQueryString);
            }
            return fsmanager.verifySignature(newQueryString, signature, algoId, cert);
        } else {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("FSSSOAndFedHandler.verifyRequestSignature: " + "Request is sent by POST ");
            }
            int minorVersion = authnRequest.getMinorVersion();
            if (minorVersion == IFSConstants.FF_11_PROTOCOL_MINOR_VERSION) {
                return SigManager.getSigInstance().verify(authnRequest.getSignedXMLString(), IFSConstants.ID, Collections.singleton(cert));
            } else if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
                return SigManager.getSigInstance().verify(authnRequest.getSignedXMLString(), IFSConstants.REQUEST_ID, Collections.singleton(cert));
            } else {
                FSUtils.debug.message("invalid minor version.");
                return false;
            }
        }
    } catch (Exception e) {
        FSUtils.debug.error("FSSSOAndFedHandler.verifyRequestSignature: " + "Exception occured while verifying SP's signature:", e);
        return false;
    }
}
Also used : FSException(com.sun.identity.federation.common.FSException) X509Certificate(java.security.cert.X509Certificate) FSSignatureManager(com.sun.identity.federation.services.util.FSSignatureManager) SessionException(com.sun.identity.plugin.session.SessionException) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) FSAccountMgmtException(com.sun.identity.federation.accountmgmt.FSAccountMgmtException) SAMLException(com.sun.identity.saml.common.SAMLException) FSException(com.sun.identity.federation.common.FSException) IOException(java.io.IOException) FSRedirectException(com.sun.identity.federation.common.FSRedirectException)

Aggregations

FSException (com.sun.identity.federation.common.FSException)49 SAMLException (com.sun.identity.saml.common.SAMLException)25 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)21 SessionException (com.sun.identity.plugin.session.SessionException)19 IOException (java.io.IOException)13 List (java.util.List)12 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)10 FSAssertion (com.sun.identity.federation.message.FSAssertion)10 FSAccountMgmtException (com.sun.identity.federation.accountmgmt.FSAccountMgmtException)8 FSAuthnRequest (com.sun.identity.federation.message.FSAuthnRequest)8 ArrayList (java.util.ArrayList)8 Iterator (java.util.Iterator)8 Document (org.w3c.dom.Document)8 IDFFMetaManager (com.sun.identity.federation.meta.IDFFMetaManager)7 IDPDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType)7 ProviderDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType)7 NameIdentifier (com.sun.identity.saml.assertion.NameIdentifier)7 Status (com.sun.identity.saml.protocol.Status)7 Map (java.util.Map)7 FSMsgException (com.sun.identity.federation.message.common.FSMsgException)6