code: static <T extends SAMLObject> MessageContext<T> toSamlObject(AggregatedHttpMessage msg, String name) {
          final SamlParameters parameters = new SamlParameters(msg);
          final byte[] decoded;
          try {
              decoded = Base64.getMimeDecoder().decode(parameters.getFirstValue(name));
          } catch (IllegalArgumentException e) {
              throw new SamlException("failed to decode a base64 string of the parameter: " + name, e);
          }
  
          @SuppressWarnings("unchecked")
          final T message = (T) deserialize(decoded);
  
          final MessageContext<T> messageContext = new MessageContext<>();
          messageContext.setMessage(message);
  
          final String relayState = parameters.getFirstValueOrNull(RELAY_STATE);
          if (relayState != null) {
              final SAMLBindingContext context = messageContext.getSubcontext(SAMLBindingContext.class, true);
              assert context != null;
              context.setRelayState(relayState);
          }
  
          return messageContext;
      }
docs: Converts an {@link AggregatedHttpMessage} which is received from the remote entity to
  a {@link SAMLObject}.