Skip to content

Commit

Permalink
SHIBUI-828: use correct mutable resolvers collection to search from
Browse files Browse the repository at this point in the history
  • Loading branch information
dima767 committed Sep 7, 2018
1 parent 4804797 commit 46bc15b
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
import com.google.common.collect.Collections2;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
import net.shibboleth.utilities.java.support.resolver.ResolverException;
import org.opensaml.saml.metadata.resolver.ChainingMetadataResolver;
import org.opensaml.saml.metadata.resolver.MetadataResolver;
import org.opensaml.saml.metadata.resolver.RefreshableMetadataResolver;
import org.opensaml.saml.saml2.metadata.EntityDescriptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -49,6 +53,26 @@ public List<MetadataResolver> getResolvers() {
return mutableResolvers;
}

@Override
@Nonnull public Iterable<EntityDescriptor> resolve(@Nullable final CriteriaSet criteria) throws ResolverException {
ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);

for (final MetadataResolver resolver : mutableResolvers) {
try {
final Iterable<EntityDescriptor> descriptors = resolver.resolve(criteria);
if (descriptors != null && descriptors.iterator().hasNext()) {
return descriptors;
}
} catch (final ResolverException e) {
log.warn("Error retrieving metadata from resolver of type {}, proceeding to next resolver",
resolver.getClass().getName(), e);
continue;
}
}

return Collections.emptyList();
}

@Override
protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
Expand Down

0 comments on commit 46bc15b

Please sign in to comment.