code: @SneakyThrows
      public final T encode(final RequestAbstractType request, final T samlObject, final String relayState) throws SamlException {
          if (httpResponse != null) {
              val encoder = getMessageEncoderInstance();
              encoder.setHttpServletResponse(httpResponse);
  
              val ctx = getEncoderMessageContext(request, samlObject, relayState);
              encoder.setMessageContext(ctx);
              finalizeEncode(request, encoder, samlObject, relayState);
          }
          return samlObject;
  
      }
docs: Encode.
  
  @param request    the request
  @param samlObject the saml response
  @param relayState the relay state
  @return the response
  @throws SamlException the saml exception