-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'NOJIRA-Chaining-Resolver-Fix' of bitbucket.org:unicon/s…
…hib-idp-ui into bugfix/nojira-ui-duration-backupfileinitnextrefreshdelay
- Loading branch information
Showing
8 changed files
with
130 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
.../tier/shibboleth/admin/ui/domain/resolvers/opensaml/OpenSamlChainingMetadataResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.domain.resolvers.opensaml; | ||
|
||
import com.google.common.base.Predicates; | ||
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.resolver.ResolverException; | ||
import org.opensaml.saml.metadata.resolver.ChainingMetadataResolver; | ||
import org.opensaml.saml.metadata.resolver.MetadataResolver; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* @author Bill Smith (wsmith@unicon.net) | ||
*/ | ||
public class OpenSamlChainingMetadataResolver extends ChainingMetadataResolver { | ||
@Nonnull private final Logger log = LoggerFactory.getLogger(OpenSamlChainingMetadataResolver.class); | ||
|
||
@Nonnull @NonnullElements private List<MetadataResolver> mutableResolvers; | ||
|
||
public OpenSamlChainingMetadataResolver() { | ||
this.mutableResolvers = Collections.emptyList(); | ||
} | ||
|
||
public OpenSamlChainingMetadataResolver(@Nonnull List<MetadataResolver> mutableResolvers) { | ||
this.mutableResolvers = mutableResolvers; | ||
} | ||
|
||
@Override | ||
public void setResolvers(@Nonnull @NonnullElements final List<? extends MetadataResolver> newResolvers) | ||
throws ResolverException { | ||
if (newResolvers == null || newResolvers.isEmpty()) { | ||
mutableResolvers = Collections.emptyList(); | ||
return; | ||
} | ||
|
||
mutableResolvers = new ArrayList<>(Collections2.filter(newResolvers, Predicates.notNull())); | ||
} | ||
|
||
@Nonnull | ||
@NonnullElements | ||
@Override | ||
public List<MetadataResolver> getResolvers() { | ||
return mutableResolvers; | ||
} | ||
|
||
@Override | ||
protected void doInitialize() throws ComponentInitializationException { | ||
super.doInitialize(); | ||
if (mutableResolvers == null) { | ||
log.warn("OpenSamlChainingMetadataResolver was not configured with any member MetadataResolvers"); | ||
mutableResolvers = Collections.emptyList(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
.../main/java/edu/internet2/tier/shibboleth/admin/ui/service/EntityIdsSearchServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.service; | ||
|
||
import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.EntityIdsSearchResultRepresentation; | ||
import edu.internet2.tier.shibboleth.admin.util.LuceneUtility; | ||
import org.apache.lucene.analysis.Analyzer; | ||
import org.apache.lucene.document.Document; | ||
import org.apache.lucene.index.IndexReader; | ||
import org.apache.lucene.queryparser.classic.ParseException; | ||
import org.apache.lucene.queryparser.classic.QueryParser; | ||
import org.apache.lucene.search.IndexSearcher; | ||
import org.apache.lucene.search.ScoreDoc; | ||
import org.apache.lucene.search.TopDocs; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* @author Bill Smith (wsmith@unicon.net) | ||
*/ | ||
public class EntityIdsSearchServiceImpl implements EntityIdsSearchService { | ||
private static final Logger logger = LoggerFactory.getLogger(EntityIdsSearchServiceImpl.class); | ||
private Analyzer fullTokenAnalyzer; | ||
private LuceneUtility luceneUtility; | ||
|
||
public EntityIdsSearchServiceImpl(LuceneUtility luceneUtility, Analyzer fullTokenAnalyzer) { | ||
this.luceneUtility = luceneUtility; | ||
this.fullTokenAnalyzer = fullTokenAnalyzer; | ||
} | ||
|
||
@Override | ||
public EntityIdsSearchResultRepresentation findBySearchTermAndOptionalLimit(String resourceId, | ||
String searchTerm, | ||
int limit) { | ||
List<String> entityIds = new ArrayList<>(); | ||
try { | ||
IndexReader indexReader = luceneUtility.getIndexReader(resourceId); | ||
IndexSearcher searcher = new IndexSearcher(indexReader); | ||
QueryParser parser = new QueryParser("content", fullTokenAnalyzer); | ||
TopDocs topDocs = searcher.search(parser.parse(searchTerm.trim()), limit); | ||
for (ScoreDoc scoreDoc : topDocs.scoreDocs) { | ||
Document document = searcher.doc(scoreDoc.doc); | ||
entityIds.add(document.get("id")); | ||
} | ||
} catch (IOException | ParseException e) { | ||
logger.error(e.getMessage(), e); | ||
} | ||
return new EntityIdsSearchResultRepresentation(entityIds); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters