code: @SneakyThrows
      protected SAMLObject encryptAssertion(final Assertion assertion,
                                            final HttpServletRequest request,
                                            final HttpServletResponse response,
                                            final SamlRegisteredService service,
                                            final SamlRegisteredServiceServiceProviderMetadataFacade adaptor) throws SamlException {
  
          if (service.isEncryptAssertions()) {
              LOGGER.debug("SAML service [{}] requires assertions to be encrypted", adaptor.getEntityId());
              return samlResponseBuilderConfigurationContext.getSamlObjectEncrypter().encode(assertion, service, adaptor);
          }
          LOGGER.debug("SAML registered service [{}] does not require assertions to be encrypted", adaptor.getEntityId());
          return assertion;
  
      }
docs: Encrypt assertion.
  
  @param assertion the assertion
  @param request   the request
  @param response  the response
  @param service   the service
  @param adaptor   the adaptor
  @return the saml object
  @throws SamlException the saml exception