code: @SneakyThrows
      public <T extends SAMLObject> T encode(final T samlObject,
                                             final SamlRegisteredService service,
                                             final SamlRegisteredServiceServiceProviderMetadataFacade adaptor,
                                             final HttpServletResponse response,
                                             final HttpServletRequest request,
                                             final String binding,
                                             final RequestAbstractType authnRequest) throws SamlException {
  
          LOGGER.trace("Attempting to encode [{}] for [{}]", samlObject.getClass().getName(), adaptor.getEntityId());
          val outboundContext = new MessageContext<T>();
          prepareOutboundContext(samlObject, adaptor, outboundContext, binding, authnRequest);
          prepareSecurityParametersContext(adaptor, outboundContext, service);
          prepareEndpointURLSchemeSecurityHandler(outboundContext);
          prepareSamlOutboundDestinationHandler(outboundContext);
          prepareSamlOutboundProtocolMessageSigningHandler(outboundContext);
          return samlObject;
  
      }
docs: Encode a given saml object by invoking a number of outbound security handlers on the context.
  
  @param <T>          the type parameter
  @param samlObject   the saml object
  @param service      the service
  @param adaptor      the adaptor
  @param response     the response
  @param request      the request
  @param binding      the binding
  @param authnRequest the authn request
  @return the t
  @throws SamlException the saml exception