static <T extends SAMLObject> MessageContext<T> toSamlObject(AggregatedHttpRequest req, String name) {
        final SamlParameters parameters = new SamlParameters(req);
        final byte[] decoded;
        try {
            decoded = Base64.getMimeDecoder().decode(parameters.getFirstValue(name));
        } catch (IllegalArgumentException e) {
            throw new InvalidSamlRequestException(
                    "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;
    }
Converts an {@link AggregatedHttpRequest} which is received from the remote entity to
a {@link SAMLObject}.
saml/src/main/java/com/linecorp/armeria/server/saml/HttpPostBindingUtil.java