@Override
    public Envelope build(final SamlProfileBuilderContext context) throws Exception {

        val body = SamlUtils.newSoapObject(Body.class);
        val fault = SamlUtils.newSoapObject(Fault.class);

        val faultCode = SamlUtils.newSoapObject(FaultCode.class);
        faultCode.setValue(FaultCode.SERVER);
        fault.setCode(faultCode);

        val faultActor = SamlUtils.newSoapObject(FaultActor.class);
        faultActor.setURI(SamlIdPUtils.getIssuerFromSamlObject(context.getSamlRequest()));
        fault.setActor(faultActor);

        val faultString = SamlUtils.newSoapObject(FaultString.class);
        val error = context.getHttpRequest().getAttribute(SamlIdPConstants.REQUEST_ATTRIBUTE_ERROR);
        if (error != null) {
            faultString.setValue(error.toString());
        } else {
            faultString.setValue("SOAP failure");
        }
        fault.setMessage(faultString);
        body.getUnknownXMLObjects().add(fault);
        
        val envelope = SamlUtils.newSoapObject(Envelope.class);
        val header = SamlUtils.newSoapObject(Header.class);
        envelope.setHeader(header);
        envelope.setBody(body);
        val ctx = context.getMessageContext().ensureSubcontext(SOAP11Context.class);
        Objects.requireNonNull(ctx).setHTTPResponseStatus(HttpStatus.SC_OK);
        encodeFinalResponse(context, envelope);
        context.getHttpRequest().setAttribute(FaultString.class.getSimpleName(), error);
        return envelope;
    }
The {@link SamlProfileSamlSoap11FaultResponseBuilder} is responsible for
building the final SAML assertion for the relying party.

@author Misagh Moayyed
@since 4.2
support/cas-server-support-saml-idp-web/src/main/java/org/apereo/cas/support/saml/web/idp/profile/builders/response/soap/SamlProfileSamlSoap11FaultResponseBuilder.java