public static SamlIdPAuthenticationContext from(final MessageContext context) {
        val result = new SamlIdPAuthenticationContext();
        if (context.containsSubcontext(SAMLBindingContext.class)) {
            val binding = Objects.requireNonNull(context.ensureSubcontext(SAMLBindingContext.class));
            result.getSubcontext(SAMLBindingContext.class).put("relayState", binding.getRelayState());
            result.getSubcontext(SAMLBindingContext.class).put("hasBindingSignature", binding.hasBindingSignature());
        }
        if (context.containsSubcontext(SAMLProtocolContext.class)) {
            val protocol = Objects.requireNonNull(context.getSubcontext(SAMLProtocolContext.class));
            result.getSubcontext(SAMLProtocolContext.class).put("protocol", protocol.getProtocol());
        }
        if (context.containsSubcontext(SAMLPeerEntityContext.class)) {
            val peer = Objects.requireNonNull(context.getSubcontext(SAMLPeerEntityContext.class));
            result.getSubcontext(SAMLPeerEntityContext.class).put("entityId", peer.getEntityId());
            result.getSubcontext(SAMLPeerEntityContext.class).put("authenticated", peer.isAuthenticated());
        }
        return result;
    }
From.

@param context the context
@return the saml id p authentication context
support/cas-server-support-saml-idp-core/src/main/java/org/apereo/cas/support/saml/authentication/SamlIdPAuthenticationContext.java