use of org.opensaml.core.criterion.SatisfyAnyCriterion in project cas by apereo.
the class SamlSPUtils method determineEntityIdList.
private static List<String> determineEntityIdList(final AbstractSamlSPProperties sp, final SamlRegisteredServiceCachingMetadataResolver resolver, final SamlRegisteredService service) {
val entityIDList = sp.getEntityIds();
if (entityIDList.isEmpty()) {
val criteriaSet = new CriteriaSet();
criteriaSet.add(new EntityRoleCriterion(SPSSODescriptor.DEFAULT_ELEMENT_NAME));
criteriaSet.add(new SatisfyAnyCriterion());
val metadataResolver = resolver.resolve(service, criteriaSet);
val resolvers = new ArrayList<MetadataResolver>();
if (metadataResolver instanceof ChainingMetadataResolver) {
resolvers.addAll(((ChainingMetadataResolver) metadataResolver).getResolvers());
} else {
resolvers.add(metadataResolver);
}
resolvers.forEach(r -> {
if (r instanceof AbstractBatchMetadataResolver) {
val it = ((AbstractBatchMetadataResolver) r).iterator();
val descriptor = StreamSupport.stream(Spliterators.spliteratorUnknownSize(it, Spliterator.ORDERED), false).filter(e -> e.getSPSSODescriptor(SAMLConstants.SAML20P_NS) != null).findFirst();
if (descriptor.isPresent()) {
entityIDList.add(descriptor.get().getEntityID());
} else {
LOGGER.warn("Skipped registration of [{}] since no entity id could be found", sp.getName());
}
}
});
}
return entityIDList;
}
Aggregations