-
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.
Merged in SHIBUI-367 (pull request #47)
SHIBUI-367 * [SHIBUI-365,SHIBUI-366,SHIBUI-383] Approved-by: Jonathan Johnson <jj@scaldingspoon.com>
- Loading branch information
Bill Smith
authored and
Jonathan Johnson
committed
Apr 4, 2018
1 parent
de29dd8
commit a1b2724
Showing
11 changed files
with
295 additions
and
35 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
68 changes: 68 additions & 0 deletions
68
...a/edu/internet2/tier/shibboleth/admin/ui/configuration/MetadataResolverConfiguration.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,68 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.configuration; | ||
|
||
import edu.internet2.tier.shibboleth.admin.ui.opensaml.OpenSamlObjects; | ||
import net.shibboleth.utilities.java.support.component.ComponentInitializationException; | ||
import net.shibboleth.utilities.java.support.resolver.ResolverException; | ||
import org.apache.http.impl.client.HttpClients; | ||
import org.apache.lucene.document.Document; | ||
import org.apache.lucene.document.Field; | ||
import org.apache.lucene.document.StringField; | ||
import org.apache.lucene.document.TextField; | ||
import org.apache.lucene.index.IndexWriter; | ||
import org.opensaml.saml.metadata.resolver.ChainingMetadataResolver; | ||
import org.opensaml.saml.metadata.resolver.MetadataResolver; | ||
import org.opensaml.saml.metadata.resolver.impl.FileBackedHTTPMetadataResolver; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* this is a temporary class until a better way of doing this is found. | ||
*/ | ||
@Configuration | ||
public class MetadataResolverConfiguration { | ||
private static final Logger logger = LoggerFactory.getLogger(MetadataResolverConfiguration.class); | ||
|
||
@Autowired | ||
OpenSamlObjects openSamlObjects; | ||
|
||
@Autowired | ||
IndexWriter indexWriter; | ||
|
||
@Bean | ||
public MetadataResolver metadataResolver() throws ResolverException, ComponentInitializationException { | ||
MetadataResolver metadataResolver = new ChainingMetadataResolver(); | ||
|
||
FileBackedHTTPMetadataResolver incommonMR = new FileBackedHTTPMetadataResolver(HttpClients.createMinimal(), "http://md.incommon.org/InCommon/InCommon-metadata.xml", "/tmp/incommon.xml"){ | ||
@Override | ||
protected void initMetadataResolver() throws ComponentInitializationException { | ||
super.initMetadataResolver(); | ||
|
||
for (String entityId: this.getBackingStore().getIndexedDescriptors().keySet()) { | ||
Document document = new Document(); | ||
document.add(new StringField("id", entityId, Field.Store.YES)); | ||
document.add(new TextField("content", entityId, Field.Store.YES)); // TODO: change entityId to be content of entity descriptor block | ||
try { | ||
indexWriter.addDocument(document); | ||
} catch (IOException e) { | ||
logger.error(e.getMessage(), e); | ||
} | ||
} | ||
try { | ||
indexWriter.commit(); | ||
} catch (IOException e) { | ||
throw new ComponentInitializationException(e); | ||
} | ||
} | ||
}; | ||
incommonMR.setId("incommonmd"); | ||
incommonMR.setParserPool(openSamlObjects.getParserPool()); | ||
incommonMR.initialize(); | ||
|
||
return metadataResolver; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...c/main/java/edu/internet2/tier/shibboleth/admin/ui/configuration/SearchConfiguration.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,63 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.configuration; | ||
|
||
import org.apache.lucene.analysis.Analyzer; | ||
import org.apache.lucene.analysis.LowerCaseFilter; | ||
import org.apache.lucene.analysis.StopFilter; | ||
import org.apache.lucene.analysis.TokenFilter; | ||
import org.apache.lucene.analysis.ngram.NGramTokenFilter; | ||
import org.apache.lucene.analysis.standard.StandardAnalyzer; | ||
import org.apache.lucene.analysis.standard.StandardTokenizer; | ||
import org.apache.lucene.index.IndexWriter; | ||
import org.apache.lucene.index.IndexWriterConfig; | ||
import org.apache.lucene.store.Directory; | ||
import org.apache.lucene.store.RAMDirectory; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.io.IOException; | ||
|
||
@Configuration | ||
public class SearchConfiguration { | ||
@Bean | ||
Directory directory() { | ||
return new RAMDirectory(); | ||
} | ||
|
||
@Bean | ||
Analyzer analyzer() { | ||
return new Analyzer() { | ||
@Override | ||
protected TokenStreamComponents createComponents(String fieldName) { | ||
final StandardTokenizer src = new StandardTokenizer(); | ||
src.setMaxTokenLength(255); | ||
TokenFilter tokenFilter; | ||
tokenFilter = new NGramTokenFilter(src, 3, 10); | ||
tokenFilter = new LowerCaseFilter(tokenFilter); | ||
tokenFilter = new StopFilter(tokenFilter, StandardAnalyzer.STOP_WORDS_SET); | ||
return new TokenStreamComponents(src, tokenFilter); | ||
} | ||
}; | ||
} | ||
|
||
@Bean | ||
Analyzer fullTokenAnalyzer() { | ||
return new Analyzer() { | ||
@Override | ||
protected TokenStreamComponents createComponents(String fieldName) { | ||
final StandardTokenizer src = new StandardTokenizer(); | ||
src.setMaxTokenLength(255); | ||
TokenFilter tokenFilter; | ||
tokenFilter = new LowerCaseFilter(src); | ||
tokenFilter = new StopFilter(tokenFilter, StandardAnalyzer.STOP_WORDS_SET); | ||
return new TokenStreamComponents(src, tokenFilter); | ||
} | ||
}; | ||
} | ||
|
||
@Bean | ||
IndexWriter indexWriter() throws IOException { | ||
IndexWriterConfig indexWriterConfig = new IndexWriterConfig(analyzer()); | ||
indexWriterConfig.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND); | ||
return new IndexWriter(directory(), indexWriterConfig); | ||
} | ||
} |
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
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
Oops, something went wrong.