public EncryptedAssertion encode(final Assertion samlObject,
                                     final SamlRegisteredService service,
                                     final SamlRegisteredServiceMetadataAdaptor adaptor) {

        try {
            val encrypter = buildEncrypterForSamlObject(samlObject, service, adaptor);
            if (encrypter != null) {
                return encrypter.encrypt(samlObject);
            }
        } catch (final Exception e) {
            handleEncryptionFailure(service, adaptor);
        }
        return null;
    }
Encode a given saml object by invoking a number of outbound security handlers on the context.

@param samlObject the saml object
@param service    the service
@param adaptor    the adaptor
@return the t
support/cas-server-support-saml-idp-web/src/main/java/org/apereo/cas/support/saml/web/idp/profile/builders/enc/SamlIdPObjectEncrypter.java