public MessageContext toMessageContext(final Object message) {
        val messageContext = new MessageContext();
        messageContext.setMessage(message);
        if (contexts.containsKey(SAMLBindingContext.class.getName())) {
            val binding = contexts.get(SAMLBindingContext.class.getName());
            val subcontext = messageContext.ensureSubcontext(SAMLBindingContext.class);
            subcontext.setHasBindingSignature((boolean) binding.properties.get("hasBindingSignature"));
            subcontext.setRelayState((String) binding.properties.get("relayState"));
        }
        if (contexts.containsKey(SAMLProtocolContext.class.getName())) {
            val binding = contexts.get(SAMLProtocolContext.class.getName());
            val subcontext = messageContext.ensureSubcontext(SAMLProtocolContext.class);
            subcontext.setProtocol((String) binding.properties.get("protocol"));
        }
        if (contexts.containsKey(SAMLPeerEntityContext.class.getName())) {
            val binding = contexts.get(SAMLPeerEntityContext.class.getName());
            val subcontext = messageContext.ensureSubcontext(SAMLPeerEntityContext.class);
            subcontext.setEntityId((String) binding.properties.get("entityId"));
        }
        return messageContext;
    }
To message context.

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