public String getAssertionConsumerURL(String sp) throws MetadataProviderException { EntityDescriptor entityDescriptor = metadataManager.getEntityDescriptor(sp); SPSSODescriptor spssoDescriptor = entityDescriptor.getSPSSODescriptor(SAMLConstants.SAML20P_NS); List<AssertionConsumerService> assertionConsumerServices = spssoDescriptor.getAssertionConsumerServices(); Optional<AssertionConsumerService> defaultService = assertionConsumerServices.stream().filter(acs -> acs.isDefault()).findFirst(); if (defaultService.isPresent()) { return defaultService.get().getLocation(); } else { return assertionConsumerServices.get(0).getLocation(); } }
@Test public void get_assertion_consumer_service_url() throws Exception { String entityID = "validEntityID"; EntityDescriptor entityDescriptor = mock(EntityDescriptor.class); when(metadataManager.getEntityDescriptor(eq(entityID))).thenReturn(entityDescriptor); SPSSODescriptor spssoDescriptor = mock(SPSSODescriptor.class); when(entityDescriptor.getSPSSODescriptor(eq(SAML20P_NS))).thenReturn(spssoDescriptor); AssertionConsumerService service = mock(AssertionConsumerService.class); when(service.getLocation()).thenReturn("service-location"); when(service.isDefault()).thenReturn(false); AssertionConsumerService defaultService = mock(AssertionConsumerService.class); when(defaultService.getLocation()).thenReturn("default-location"); when(defaultService.isDefault()).thenReturn(true); when(spssoDescriptor.getAssertionConsumerServices()).thenReturn(Arrays.asList(service, defaultService)); String url = controller.getAssertionConsumerURL(entityID); assertEquals("default-location", url); when(defaultService.isDefault()).thenReturn(false); url = controller.getAssertionConsumerURL(entityID); assertEquals("service-location", url); }
private void setAssertionConsumerUrl(SPSSODescriptor spssoDescriptor, SAMLSSOServiceProviderDO samlssoServiceProviderDO){ //Assertion Consumer URL //search for the url with the post binding, if there is no post binding select the default url List<AssertionConsumerService> assertionConsumerServices = spssoDescriptor.getAssertionConsumerServices(); if (assertionConsumerServices!=null && assertionConsumerServices.size()>0) { List<String> acs = new ArrayList<>(); boolean foundAssertionConsumerUrl = false; for (AssertionConsumerService assertionConsumerService : assertionConsumerServices) { acs.add(assertionConsumerService.getLocation()); if (assertionConsumerService.isDefault()) { samlssoServiceProviderDO.setDefaultAssertionConsumerUrl(assertionConsumerService.getLocation());//changed samlssoServiceProviderDO.setAssertionConsumerUrl(assertionConsumerService.getLocation());//changed foundAssertionConsumerUrl = true; } } samlssoServiceProviderDO.setAssertionConsumerUrls(acs); //select atleast one if (!foundAssertionConsumerUrl) { samlssoServiceProviderDO.setDefaultAssertionConsumerUrl(assertionConsumerServices.get(0).getLocation()); } } } private void setIssuer(EntityDescriptor entityDescriptor , SAMLSSOServiceProviderDO samlssoServiceProviderDO){
private void setAssertionConsumerUrl(SPSSODescriptor spssoDescriptor, SAMLSSOServiceProviderDO samlssoServiceProviderDO) throws InvalidMetadataException { //Assertion Consumer URL //search for the url with the post binding, if there is no post binding select the default url List<AssertionConsumerService> assertionConsumerServices = spssoDescriptor.getAssertionConsumerServices(); if (assertionConsumerServices != null && assertionConsumerServices.size() > 0) { List<String> acs = new ArrayList<>(); boolean foundAssertionConsumerUrl = false; for (AssertionConsumerService assertionConsumerService : assertionConsumerServices) { acs.add(assertionConsumerService.getLocation()); if (assertionConsumerService.isDefault()) { samlssoServiceProviderDO.setDefaultAssertionConsumerUrl(assertionConsumerService.getLocation());//changed samlssoServiceProviderDO.setAssertionConsumerUrl(assertionConsumerService.getLocation());//changed foundAssertionConsumerUrl = true; } } samlssoServiceProviderDO.setAssertionConsumerUrls(acs); //select atleast one if (!foundAssertionConsumerUrl) { samlssoServiceProviderDO.setDefaultAssertionConsumerUrl(assertionConsumerServices.get(0).getLocation()); } } else { throw new InvalidMetadataException("Invalid metadata content, no Assertion Consumer URL found"); } }
protected org.opensaml.liberty.paos.Request getPAOSRequest(AssertionConsumerService assertionConsumer) { SAMLObjectBuilder<org.opensaml.liberty.paos.Request> paosRequestBuilder = (SAMLObjectBuilder<org.opensaml.liberty.paos.Request>) builderFactory.getBuilder(org.opensaml.liberty.paos.Request.DEFAULT_ELEMENT_NAME); org.opensaml.liberty.paos.Request paosRequest = paosRequestBuilder.buildObject(); paosRequest.setSOAP11Actor(Request.SOAP11_ACTOR_NEXT); paosRequest.setSOAP11MustUnderstand(true); paosRequest.setResponseConsumerURL(assertionConsumer.getLocation()); paosRequest.setService(SAMLConstants.SAML20ECP_NS); return paosRequest; }
/** * Fills the request with assertion consumer service url and protocol binding based on assertionConsumer * to be used to deliver response from the IDP. * * @param request request * @param service service to deliver response to, building is skipped when null * @throws MetadataProviderException error retrieving metadata information */ protected void buildReturnAddress(AuthnRequest request, AssertionConsumerService service) throws MetadataProviderException { if (service != null) { // AssertionConsumerServiceURL + ProtocolBinding is mutually exclusive with AssertionConsumerServiceIndex, we use the first one here if (service.getResponseLocation() != null) { request.setAssertionConsumerServiceURL(service.getResponseLocation()); } else { request.setAssertionConsumerServiceURL(service.getLocation()); } request.setProtocolBinding(getEndpointBinding(service)); } }
SPSSODescriptor spssoDescriptor = (SPSSODescriptor) context.getLocalEntityRoleMetadata(); for (AssertionConsumerService service : spssoDescriptor.getAssertionConsumerServices()) { if (context.getInboundSAMLProtocol().equals(service.getBinding()) && service.getLocation().equals(data.getRecipient())) { confirmed = true;
if (svc.getBinding().equals(SAMLConstants.SAML2_REDIRECT_BINDING_URI) || svc.getBinding().equals(SAMLConstants.SAML2_POST_BINDING_URI)) { acsUrl = svc.getLocation(); break;
if (svc.getBinding().equals(SAMLConstants.SAML2_REDIRECT_BINDING_URI) || svc.getBinding().equals(SAMLConstants.SAML2_POST_BINDING_URI)) { acsUrl = svc.getLocation(); break;
responseLocation = assertionConsumerService.getResponseLocation(); } else { responseLocation = assertionConsumerService.getLocation();