MetadataGenerator { public EntityDescriptor generateMetadata() { boolean requestSigned = isRequestSigned(); boolean assertionSigned = isWantAssertionSigned(); Collection<String> includedNameID = getNameID(); String entityId = getEntityId(); String entityBaseURL = getEntityBaseURL(); String entityAlias = getEntityAlias(); validateRequiredAttributes(entityId, entityBaseURL); if (id == null) { id = SAMLUtil.getNCNameString(entityId); } SAMLObjectBuilder<EntityDescriptor> builder = (SAMLObjectBuilder<EntityDescriptor>) builderFactory.getBuilder(EntityDescriptor.DEFAULT_ELEMENT_NAME); EntityDescriptor descriptor = builder.buildObject(); if (id != null) { descriptor.setID(id); } descriptor.setEntityID(entityId); SPSSODescriptor ssoDescriptor = buildSPSSODescriptor(entityBaseURL, entityAlias, requestSigned, assertionSigned, includedNameID); if (ssoDescriptor != null) { descriptor.getRoleDescriptors().add(ssoDescriptor); } return descriptor; } MetadataGenerator(); EntityDescriptor generateMetadata(); ExtendedMetadata generateExtendedMetadata(); @Autowired(required = false) @Qualifier("samlWebSSOProcessingFilter") void setSamlWebSSOFilter(SAMLProcessingFilter samlWebSSOFilter); @Autowired(required = false) @Qualifier("samlWebSSOHoKProcessingFilter") void setSamlWebSSOHoKFilter(SAMLWebSSOHoKProcessingFilter samlWebSSOHoKFilter); @Autowired(required = false) void setSamlLogoutProcessingFilter(SAMLLogoutProcessingFilter samlLogoutProcessingFilter); @Autowired(required = false) void setSamlEntryPoint(SAMLEntryPoint samlEntryPoint); boolean isRequestSigned(); void setRequestSigned(boolean requestSigned); boolean isWantAssertionSigned(); void setWantAssertionSigned(boolean wantAssertionSigned); Collection<String> getNameID(); void setNameID(Collection<String> nameID); String getEntityBaseURL(); void setEntityBaseURL(String entityBaseURL); @Autowired void setKeyManager(KeyManager keyManager); void setId(String id); String getId(); void setEntityId(String entityId); String getEntityId(); Collection<String> getBindingsSSO(); void setBindingsSSO(Collection<String> bindingsSSO); Collection<String> getBindingsSLO(); void setBindingsSLO(Collection<String> bindingsSLO); Collection<String> getBindingsHoKSSO(); void setBindingsHoKSSO(Collection<String> bindingsHoKSSO); boolean isIncludeDiscoveryExtension(); void setIncludeDiscoveryExtension(boolean includeDiscoveryExtension); int getAssertionConsumerIndex(); void setAssertionConsumerIndex(int assertionConsumerIndex); ExtendedMetadata getExtendedMetadata(); void setExtendedMetadata(ExtendedMetadata extendedMetadata); static final Collection<String> defaultNameID; }
@Test public void testGenerateMetadata() { generator.setEntityBaseURL("http: generator.setEntityId("my_entity"); generator.setIncludeDiscoveryExtension(true); EntityDescriptor metadata = generator.generateMetadata(); assertEquals("my_entity", metadata.getEntityID()); assertEquals("my_entity", metadata.getID()); SPSSODescriptor spssoDescriptor = metadata.getSPSSODescriptor(SAMLConstants.SAML20P_NS); assertNotNull(spssoDescriptor); assertNotNull(spssoDescriptor.getExtensions()); assertNotNull(spssoDescriptor.getExtensions().getUnknownXMLObjects()); assertTrue(spssoDescriptor.getExtensions().getUnknownXMLObjects().size() == 1); assertEquals(2, spssoDescriptor.getAssertionConsumerServices().size()); assertEquals(2, spssoDescriptor.getSingleLogoutServices().size()); generator.setBindingsSSO(Arrays.asList("paos", "POst", "POST")); generator.setBindingsSLO(Arrays.asList("soap")); generator.setBindingsHoKSSO(null); generator.setNameID(Arrays.asList("transient", "email", "TRANSIENT")); generator.setAssertionConsumerIndex(1); metadata = generator.generateMetadata(); spssoDescriptor = metadata.getSPSSODescriptor(SAMLConstants.SAML20P_NS); List<AssertionConsumerService> assertionConsumerServices = spssoDescriptor.getAssertionConsumerServices(); assertEquals(2, assertionConsumerServices.size()); assertEquals(SAMLConstants.SAML2_PAOS_BINDING_URI, assertionConsumerServices.get(0).getBinding()); assertEquals("http: assertEquals(SAMLConstants.SAML2_POST_BINDING_URI, assertionConsumerServices.get(1).getBinding()); assertEquals("http: assertEquals(Boolean.TRUE, assertionConsumerServices.get(1).isDefault()); List<SingleLogoutService> logoutServices = spssoDescriptor.getSingleLogoutServices(); assertEquals(1, logoutServices.size()); assertEquals(SAMLConstants.SAML2_SOAP11_BINDING_URI, logoutServices.get(0).getBinding()); assertEquals("http: List<NameIDFormat> nameID = spssoDescriptor.getNameIDFormats(); assertEquals(2, nameID.size()); assertEquals(NameIDType.TRANSIENT, nameID.get(0).getFormat()); assertEquals(NameIDType.EMAIL, nameID.get(1).getFormat()); }