assertionConsumerService.setIndex(1); assertionConsumerService.setIsDefault(true); assertionConsumerService.setBinding(SAMLConstants.SAML2_POST_BINDING_URI); assertionConsumerService.setLocation(spMetadata.getSsoUrl()); spSSODescriptor.getAssertionConsumerServices().add(assertionConsumerService); assertionConsumerService2.setBinding(SAMLConstants.SAML2_REDIRECT_BINDING_URI); assertionConsumerService2.setLocation(spMetadata.getSsoUrl()); spSSODescriptor.getAssertionConsumerServices().add(assertionConsumerService2);
protected AssertionConsumerService getAssertionConsumerService(String entityBaseURL, String entityAlias, boolean isDefault, int index, String filterURL, String binding) { SAMLObjectBuilder<AssertionConsumerService> builder = (SAMLObjectBuilder<AssertionConsumerService>) builderFactory.getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME); AssertionConsumerService consumer = builder.buildObject(); consumer.setLocation(getServerURL(entityBaseURL, entityAlias, filterURL)); consumer.setBinding(binding); if (isDefault) { consumer.setIsDefault(true); } consumer.setIndex(index); return consumer; }
@Override public SAMLMessageContext sendMessage(SAMLMessageContext samlContext, boolean sign) throws SAMLException, MetadataProviderException, MessageEncodingException { Endpoint endpoint = samlContext.getPeerEntityEndpoint(); SAMLBinding binding = getBinding(endpoint); samlContext.setLocalEntityId(spConfiguration.getEntityId()); samlContext.getLocalEntityMetadata().setEntityID(spConfiguration.getEntityId()); samlContext.getPeerEntityEndpoint().setLocation(spConfiguration.getIdpSSOServiceURL()); SPSSODescriptor roleDescriptor = (SPSSODescriptor) samlContext.getLocalEntityMetadata().getRoleDescriptors().get(0); AssertionConsumerService assertionConsumerService = roleDescriptor.getAssertionConsumerServices().stream().filter(service -> service.isDefault()).findAny().orElseThrow(() -> new RuntimeException("No default ACS")); assertionConsumerService.setBinding(spConfiguration.getProtocolBinding()); assertionConsumerService.setLocation(spConfiguration.getAssertionConsumerServiceURL()); return super.sendMessage(samlContext, spConfiguration.isNeedsSigning(), binding); } }