public static void preparePeerEntitySamlEndpointContext(final Pair<? extends RequestAbstractType, MessageContext> authnContext,
                                                            final MessageContext outboundContext,
                                                            final SamlRegisteredServiceMetadataAdaptor adaptor,
                                                            final String binding) throws SamlException {
        val entityId = adaptor.getEntityId();
        if (!adaptor.containsAssertionConsumerServices()) {
            throw new SamlException("No assertion consumer service could be found for entity " + entityId);
        }

        val peerEntityContext = outboundContext.ensureSubcontext(SAMLPeerEntityContext.class);
        peerEntityContext.setEntityId(entityId);

        val endpointContext = peerEntityContext.ensureSubcontext(SAMLEndpointContext.class);
        val endpoint = determineEndpointForRequest(authnContext, adaptor, binding);
        LOGGER.debug("Configured peer entity endpoint to be [{}] with binding [{}]", endpoint.getLocation(), endpoint.getBinding());
        endpointContext.setEndpoint(endpoint);
    }
Prepare peer entity saml endpoint.

@param authnContext    the authn context
@param outboundContext the outbound context
@param adaptor         the adaptor
@param binding         the binding
@throws SamlException the saml exception
support/cas-server-support-saml-idp-core/src/main/java/org/apereo/cas/support/saml/SamlIdPUtils.java