private static KeyDescriptor buildKeyDescriptorElement(UsageType type, KeyInfo key) { final KeyDescriptor descriptor = build(KeyDescriptor.DEFAULT_ELEMENT_NAME); descriptor.setUse(type); descriptor.setKeyInfo(key); return descriptor; } }
private static Collection<NameIDFormat> buildNameIdFormatElements(Collection<String> nameIds) { final SAMLObjectBuilder<NameIDFormat> builder = builder(NameIDFormat.DEFAULT_ELEMENT_NAME); final Collection<NameIDFormat> formats = new ArrayList<>(); for (final String value : nameIds) { final NameIDFormat nameIdFormat = builder.buildObject(); nameIdFormat.setFormat(value); formats.add(nameIdFormat); } return formats; }
private EntityDescriptor buildMetadataEntityDescriptorElement( String defaultHostname, SamlPortConfig portConfig) { final EntityDescriptor entityDescriptor = build(EntityDescriptor.DEFAULT_ELEMENT_NAME); entityDescriptor.setEntityID(entityId); spSsoDescriptor.setAuthnRequestsSigned(true); spSsoDescriptor.setWantAssertionsSigned(true); spSsoDescriptor.addSupportedProtocol(SAMLConstants.SAML20P_NS); .map(SamlNameIdFormat::urn) .collect(Collectors.toList()); spSsoDescriptor.getNameIDFormats().addAll(buildNameIdFormatElements(nameIdFormats)); final List<SingleLogoutService> sloList = spSsoDescriptor.getSingleLogoutServices(); singleLogoutEndpoints.forEach(endpoint -> { final SingleLogoutService slo = build(SingleLogoutService.DEFAULT_ELEMENT_NAME); slo.setBinding(endpoint.bindingProtocol().urn()); slo.setLocation(endpoint.toUriString(portConfig.scheme().uriText(), defaultHostname, portConfig.port())); final List<AssertionConsumerService> services = spSsoDescriptor.getAssertionConsumerServices(); for (final SamlAssertionConsumerConfig acs : assertionConsumerConfigs) { services.add(buildAssertionConsumerServiceElement(acs, portConfig, defaultHostname, acsIndex++)); spSsoDescriptor.getKeyDescriptors().add( buildKeyDescriptorElement(UsageType.SIGNING, keyInfoGenerator.generate(signingCredential))); spSsoDescriptor.getKeyDescriptors().add( buildKeyDescriptorElement(UsageType.ENCRYPTION,
final SPSSODescriptor sp = metadata.getSPSSODescriptor(SAMLConstants.SAML20P_NS); assertThat(sp.isAuthnRequestsSigned()).isTrue(); assertThat(sp.getWantAssertionsSigned()).isTrue(); final List<KeyDescriptor> kd = sp.getKeyDescriptors(); assertThat(kd.get(0).getUse().name()).isEqualToIgnoringCase("signing"); assertThat(kd.get(1).getUse().name()).isEqualToIgnoringCase("encryption"); final List<SingleLogoutService> slo = sp.getSingleLogoutServices(); assertThat(slo.get(0).getLocation()) .isEqualTo("http://" + spHostname + ':' + rule.httpPort() + "/saml/slo/post"); assertThat(slo.get(0).getBinding()).isEqualTo(SAMLConstants.SAML2_POST_BINDING_URI); assertThat(slo.get(1).getLocation()) .isEqualTo("http://" + spHostname + ':' + rule.httpPort() + "/saml/slo/redirect"); assertThat(slo.get(1).getBinding()).isEqualTo(SAMLConstants.SAML2_REDIRECT_BINDING_URI); final List<AssertionConsumerService> acs = sp.getAssertionConsumerServices(); assertThat(acs.get(0).getIndex()).isEqualTo(0); assertThat(acs.get(0).isDefault()).isTrue(); assertThat(acs.get(0).getLocation()) .isEqualTo("http://" + spHostname + ':' + rule.httpPort() + "/saml/acs/post"); assertThat(acs.get(0).getBinding()).isEqualTo(SAMLConstants.SAML2_POST_BINDING_URI); assertThat(acs.get(1).getIndex()).isEqualTo(1); assertThat(acs.get(1).isDefault()).isFalse(); assertThat(acs.get(1).getLocation()) .isEqualTo("http://" + spHostname + ':' + rule.httpPort() + "/saml/acs/redirect"); assertThat(acs.get(1).getBinding()).isEqualTo(SAMLConstants.SAML2_REDIRECT_BINDING_URI);
private static AssertionConsumerService buildAssertionConsumerServiceElement( SamlAssertionConsumerConfig config, SamlPortConfig portConfig, String hostname, int index) { final AssertionConsumerService consumer = build(AssertionConsumerService.DEFAULT_ELEMENT_NAME); consumer.setLocation(config.endpoint().toUriString(portConfig.scheme().uriText(), hostname, portConfig.port())); consumer.setBinding(config.endpoint().bindingProtocol().urn()); consumer.setIndex(index); // Add 'isDefault' attribute only when told so. if (config.isDefault()) { consumer.setIsDefault(true); } return consumer; }
/** * Gets entity id. * * @return the entity id */ public String getEntityId() { return this.entityDescriptor.getEntityID(); }
/** {@inheritDoc} */ protected void processElementContent(XMLObject samlObject, String elementContent) { LocalizedName name = (LocalizedName) samlObject; name.setValue(elementContent); } }
/** {@inheritDoc} */ protected void processElementContent(XMLObject samlObject, String elementContent) { AdditionalMetadataLocation aml = (AdditionalMetadataLocation) samlObject; aml.setLocationURI(elementContent); } }
/** {@inheritDoc} */ protected void processElementContent(XMLObject samlObject, String elementContent) { SurName name = (SurName) samlObject; name.setName(elementContent); } }
/** {@inheritDoc} */ protected void processElementContent(XMLObject samlObject, String elementContent) { TelephoneNumber number = (TelephoneNumber) samlObject; number.setNumber(elementContent); } }
/** {@inheritDoc} */ public boolean apply(RoleDescriptor input) { if (input == null) { return false; } return input.isSupportedProtocol(protocol); }
/** {@inheritDoc} */ protected void processElementContent(XMLObject samlObject, String elementContent) { Company company = (Company) samlObject; company.setName(elementContent); } }
/** {@inheritDoc} */ protected void processElementContent(XMLObject samlObject, String elementContent) { GivenName name = (GivenName) samlObject; name.setName(elementContent); } }
/** * Is supported protocol? * * @param protocol the protocol * @return true/false */ public boolean isSupportedProtocol(final String protocol) { return this.ssoDescriptor.isSupportedProtocol(protocol); }
/** {@inheritDoc} */ protected void processElementContent(XMLObject samlObject, String elementContent) { ((AttributeProfile) samlObject).setProfileURI(elementContent); } }
/** {@inheritDoc} */ protected void processElementContent(XMLObject samlObject, String elementContent) { LocalizedURI name = (LocalizedURI) samlObject; name.setValue(elementContent); } }
/** {@inheritDoc} */ protected void processElementContent(XMLObject samlObject, String elementContent) { EmailAddress address = (EmailAddress) samlObject; address.setAddress(elementContent); } }
/** {@inheritDoc} */ protected void processElementContent(XMLObject samlObject, String elementContent) { AffiliateMember member = (AffiliateMember) samlObject; member.setID(elementContent); } }
public Signature getSignature() { return this.ssoDescriptor.getSignature(); }
/** {@inheritDoc} */ protected void processElementContent(XMLObject samlObject, String elementContent) { NameIDFormat format = (NameIDFormat) samlObject; format.setFormat(elementContent); } }