/** * Prepare peer entity saml endpoint. * * @param outboundContext the outbound context * @param adaptor the adaptor * @throws SamlException the saml exception */ public static void preparePeerEntitySamlEndpointContext( final MessageContext outboundContext, final SamlRegisteredServiceServiceProviderMetadataFacade adaptor) throws SamlException { final List<AssertionConsumerService> assertionConsumerServices = adaptor.getAssertionConsumerServices(); if (assertionConsumerServices.isEmpty()) { throw new SamlException( SamlException.CODE, "No assertion consumer service could be found for entity " + adaptor.getEntityId()); } final SAMLPeerEntityContext peerEntityContext = outboundContext.getSubcontext(SAMLPeerEntityContext.class, true); if (peerEntityContext == null) { throw new SamlException( SamlException.CODE, "SAMLPeerEntityContext could not be defined for entity " + adaptor.getEntityId()); } final SAMLEndpointContext endpointContext = peerEntityContext.getSubcontext(SAMLEndpointContext.class, true); if (endpointContext == null) { throw new SamlException( SamlException.CODE, "SAMLEndpointContext could not be defined for entity " + adaptor.getEntityId()); } final Endpoint endpoint = assertionConsumerServices.get(0); if (StringUtils.isBlank(endpoint.getBinding()) || StringUtils.isBlank(endpoint.getLocation())) { throw new SamlException( SamlException.CODE, "Assertion consumer service does not define a binding or location for " + adaptor.getEntityId()); } LOGGER.debug( "Configured peer entity endpoint to be [{}] with binding [{}]", endpoint.getLocation(), endpoint.getBinding()); endpointContext.setEndpoint(endpoint); }