use of org.opensaml.saml2.metadata.EntityDescriptor in project ddf by codice.
the class SamlProtocolTest method testCreateIdpMetadata.
@Test
public void testCreateIdpMetadata() {
EntityDescriptor entityDescriptor = SamlProtocol.createIdpMetadata("myid", "mysigningcert", "myencryptioncert", Arrays.asList("mynameid"), "redirectlocation", "postlocation", "soaplocation", "logoutlocation");
assertEquals("myid", entityDescriptor.getEntityID());
assertEquals("mysigningcert", entityDescriptor.getIDPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getKeyDescriptors().get(0).getKeyInfo().getX509Datas().get(0).getX509Certificates().get(0).getValue());
assertEquals("myencryptioncert", entityDescriptor.getIDPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getKeyDescriptors().get(1).getKeyInfo().getX509Datas().get(0).getX509Certificates().get(0).getValue());
assertEquals("mynameid", entityDescriptor.getIDPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getNameIDFormats().get(0).getFormat());
assertEquals("logoutlocation", entityDescriptor.getIDPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getSingleLogoutServices().get(0).getLocation());
List<SingleSignOnService> ssoServices = entityDescriptor.getIDPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getSingleSignOnServices();
assertTrue(ssoServices.stream().filter(service -> service.getBinding().equals(REDIRECT_BINDING) && service.getLocation().equals("redirectlocation")).findFirst().isPresent());
assertTrue(ssoServices.stream().filter(service -> service.getBinding().equals(POST_BINDING) && service.getLocation().equals("postlocation")).findFirst().isPresent());
assertTrue(ssoServices.stream().filter(service -> service.getBinding().equals(SOAP_BINDING) && service.getLocation().equals("soaplocation")).findFirst().isPresent());
assertNotNull(entityDescriptor.getCacheDuration());
}
use of org.opensaml.saml2.metadata.EntityDescriptor in project cas by apereo.
the class AuthnRequestRequestedAttributesAttributeReleasePolicy method getAttributesForSamlRegisteredService.
@Override
protected Map<String, List<Object>> getAttributesForSamlRegisteredService(final Map<String, List<Object>> attributes, final ApplicationContext applicationContext, final SamlRegisteredServiceCachingMetadataResolver resolver, final SamlRegisteredServiceServiceProviderMetadataFacade facade, final EntityDescriptor entityDescriptor, final RegisteredServiceAttributeReleasePolicyContext context) {
val releaseAttributes = new HashMap<String, List<Object>>();
getSamlAuthnRequest(applicationContext).ifPresent(authnRequest -> {
if (authnRequest.getExtensions() != null) {
authnRequest.getExtensions().getUnknownXMLObjects().stream().filter(object -> object instanceof RequestedAttribute).map(object -> (RequestedAttribute) object).filter(attr -> {
val name = this.useFriendlyName ? attr.getFriendlyName() : attr.getName();
LOGGER.debug("Checking for requested attribute [{}] in metadata for [{}]", name, context.getRegisteredService().getName());
return attributes.containsKey(name);
}).forEach(attr -> {
val name = this.useFriendlyName ? attr.getFriendlyName() : attr.getName();
LOGGER.debug("Found requested attribute [{}] in metadata for [{}]", name, context.getRegisteredService().getName());
releaseAttributes.put(name, attributes.get(name));
});
}
});
return authorizeReleaseOfAllowedAttributes(context, releaseAttributes);
}
use of org.opensaml.saml2.metadata.EntityDescriptor in project cas by apereo.
the class MetadataRegistrationAuthorityAttributeReleasePolicy method getAttributesForSamlRegisteredService.
@Override
protected Map<String, List<Object>> getAttributesForSamlRegisteredService(final Map<String, List<Object>> attributes, final ApplicationContext applicationContext, final SamlRegisteredServiceCachingMetadataResolver resolver, final SamlRegisteredServiceServiceProviderMetadataFacade facade, final EntityDescriptor entityDescriptor, final RegisteredServiceAttributeReleasePolicyContext context) {
val extensions = Optional.ofNullable(facade.getExtensions()).map(ElementExtensibleXMLObject::getUnknownXMLObjects).orElseGet(List::of);
val matched = extensions.stream().filter(object -> object instanceof RegistrationInfo).map(info -> (RegistrationInfo) info).anyMatch(info -> RegexUtils.find(this.registrationAuthority, info.getRegistrationAuthority()));
if (matched) {
return authorizeReleaseOfAllowedAttributes(context, attributes);
}
return new HashMap<>(0);
}
use of org.opensaml.saml2.metadata.EntityDescriptor in project verify-hub by alphagov.
the class HubIdentityProviderMetadataDtoToEntityDescriptorTransformer method doTransform.
public EntityDescriptor doTransform(HubIdentityProviderMetadataDto dto) {
EntityDescriptor entityDescriptor = openSamlXmlObjectFactory.createEntityDescriptor();
entityDescriptor.setID(idGenerator.getId());
entityDescriptor.setEntityID(dto.getEntityId());
entityDescriptor.setValidUntil(dto.getValidUntil());
IDPSSODescriptor idpSsoDescriptor = openSamlXmlObjectFactory.createIDPSSODescriptor();
idpSsoDescriptor.addSupportedProtocol(SAMLConstants.SAML20P_NS);
transformSingleSignOnServiceEndpoints(idpSsoDescriptor, dto);
List<KeyDescriptor> signingKeyDescriptors = keyDescriptorsUnmarshaller.fromCertificates(List.copyOf(dto.getSigningCertificates()));
idpSsoDescriptor.getKeyDescriptors().addAll(signingKeyDescriptors);
entityDescriptor.getRoleDescriptors().add(idpSsoDescriptor);
return entityDescriptor;
}
use of org.opensaml.saml2.metadata.EntityDescriptor in project verify-hub by alphagov.
the class IdpSingleSignOnServiceHelperTest method setUp.
@BeforeEach
public void setUp() throws ResolverException, MarshallingException, SignatureException {
CriteriaSet criteria = new CriteriaSet(new EntityIdCriterion(idpEntityId));
EntityDescriptor idpEntityDescriptor = anEntityDescriptor().withIdpSsoDescriptor(anIdpSsoDescriptor().withSingleSignOnService(anEndpoint().withLocation(idpSSOUri.toASCIIString()).buildSingleSignOnService()).build()).build();
when(metadataProvider.resolveSingle(eq(criteria))).thenReturn(idpEntityDescriptor);
when(metadataProvider.resolveSingle(not(eq(criteria)))).thenReturn(null);
idpSingleSignOnServiceHelper = new IdpSingleSignOnServiceHelper(metadataProvider);
}
Aggregations