@SuppressWarnings("unchecked")
    static <T extends SAMLObject> MessageContext<T> toSamlObject(
            AggregatedHttpRequest req, String name,
            Map<String, SamlIdentityProviderConfig> idpConfigs,
            @Nullable SamlIdentityProviderConfig defaultIdpConfig,
            boolean signatureRequired) {
        requireNonNull(req, "req");
        requireNonNull(name, "name");
        requireNonNull(idpConfigs, "idpConfigs");

        final SamlParameters parameters = new SamlParameters(req);
        final T message = (T) fromDeflatedBase64(parameters.getFirstValue(name));

        final MessageContext<T> messageContext = new MessageContext<>();
        messageContext.setMessage(message);

        final Issuer issuer;
        if (message instanceof RequestAbstractType) {
            issuer = ((RequestAbstractType) message).getIssuer();
        } else if (message instanceof StatusResponseType) {
            issuer = ((StatusResponseType) message).getIssuer();
        } else {
            throw new InvalidSamlRequestException(
                    "invalid message type: " + message.getClass().getSimpleName());
        }

        // Use the default identity provider config if there's no issuer.
        final SamlIdentityProviderConfig config;
        if (issuer != null) {
            final String idpEntityId = issuer.getValue();
            config = idpConfigs.get(idpEntityId);
            if (config == null) {
                throw new InvalidSamlRequestException(
                        "a message from unknown identity provider: " + idpEntityId);
            }
        } else {
            if (defaultIdpConfig == null) {
                throw new InvalidSamlRequestException("failed to get an Issuer element");
            }
            config = defaultIdpConfig;
        }

        // If this message is sent via HTTP-redirect binding protocol, its signature parameter should
        // be validated.
        validateSignature(config.signingCredential(), parameters, name, signatureRequired);

        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/HttpRedirectBindingUtil.java