protected String constructServiceUrl(final HttpServletRequest request, final HttpServletResponse response,
                                         final Pair<? extends SignableSAMLObject, MessageContext> pair) throws Exception {
        val authnRequest = (AuthnRequest) pair.getLeft();
        val builder = new URIBuilder(configurationContext.getCallbackService().getId());
        builder.addParameter(SamlIdPConstants.AUTHN_REQUEST_ID, authnRequest.getID());
        builder.addParameter(SamlProtocolConstants.PARAMETER_ENTITY_ID, SamlIdPUtils.getIssuerFromSamlObject(authnRequest));
        storeAuthenticationRequest(request, response, pair);
        val url = builder.build().toURL().toExternalForm();
        LOGGER.trace("Built service callback url [{}]", url);
        return url;
    }
Handle SAML2 exceptions.

@param req the req
@param ex  the ex
@return the model and view
support/cas-server-support-saml-idp-web/src/main/java/org/apereo/cas/support/saml/web/idp/profile/AbstractSamlIdPProfileHandlerController.java