use of org.gluu.oxtrust.model.MetadataFilter in project oxTrust by GluuFederation.
the class FilterService method parseFilters.
public void parseFilters(GluuSAMLTrustRelationship trustRelationship) throws SAXException, IOException, ParserConfigurationException, FactoryConfigurationError, XPathExpressionException {
if (trustRelationship.getGluuSAMLMetaDataFilter() != null) {
XPath xPath = XPathFactory.newInstance().newXPath();
for (String filterXML : trustRelationship.getGluuSAMLMetaDataFilter()) {
Document xmlDocument = xmlService.getXmlDocument(filterXML.getBytes());
if (xmlDocument.getFirstChild().getAttributes().getNamedItem("xsi:type").getNodeValue().equals(VALIDATION_TYPE)) {
MetadataFilter filter = createMetadataFilter("validation");
XPathExpression contactCountXPath = xPath.compile("count(/MetadataFilter/ExtensionSchema)");
int schemasNumber = Integer.parseInt(contactCountXPath.evaluate(xmlDocument));
for (int i = 1; i <= schemasNumber; i++) {
contactCountXPath = xPath.compile("/MetadataFilter/ExtensionSchema[" + i + "]");
filter.getExtensionSchemas().add(contactCountXPath.evaluate(xmlDocument));
}
trustRelationship.getMetadataFilters().put("validation", filter);
continue;
}
if (xmlDocument.getFirstChild().getAttributes().getNamedItem("xsi:type").getNodeValue().equals(ENTITY_ROLE_WHITE_LIST_TYPE)) {
MetadataFilter filter = createMetadataFilter("entityRoleWhiteList");
filter.setRemoveRolelessEntityDescriptors(Boolean.parseBoolean(xmlDocument.getFirstChild().getAttributes().getNamedItem("removeRolelessEntityDescriptors").getNodeValue()));
filter.setRemoveEmptyEntitiesDescriptors(Boolean.parseBoolean(xmlDocument.getFirstChild().getAttributes().getNamedItem("removeEmptyEntitiesDescriptors").getNodeValue()));
XPathExpression contactCountXPath = xPath.compile("count(/MetadataFilter/RetainedRole)");
int schemasNumber = Integer.parseInt(contactCountXPath.evaluate(xmlDocument));
for (int i = 1; i <= schemasNumber; i++) {
contactCountXPath = xPath.compile("/MetadataFilter/RetainedRole[" + i + "]");
filter.getRetainedRoles().add(contactCountXPath.evaluate(xmlDocument));
}
trustRelationship.getMetadataFilters().put("entityRoleWhiteList", filter);
continue;
}
if (xmlDocument.getFirstChild().getAttributes().getNamedItem("xsi:type").getNodeValue().equals(VALID_UNTIL_REQUIRED_TYPE)) {
MetadataFilter filter = createMetadataFilter("requiredValidUntil");
filter.setMaxValidityInterval(Integer.parseInt(xmlDocument.getFirstChild().getAttributes().getNamedItem("maxValidityInterval").getNodeValue()));
trustRelationship.getMetadataFilters().put("requiredValidUntil", filter);
continue;
}
if (xmlDocument.getFirstChild().getAttributes().getNamedItem("xsi:type").getNodeValue().equals(SIGNATURE_VALIDATION_TYPE)) {
MetadataFilter filter = createMetadataFilter("signatureValidation");
filter.setFilterCertFileName(StringHelper.removePunctuation(trustRelationship.getInum()));
trustRelationship.getMetadataFilters().put("signatureValidation", filter);
continue;
}
}
}
}
use of org.gluu.oxtrust.model.MetadataFilter in project oxTrust by GluuFederation.
the class FilterService method createMetadataFilter.
private MetadataFilter createMetadataFilter(String filterName) {
MetadataFilter metadataFilter = new MetadataFilter();
metadataFilter.setName(filterName);
metadataFilter.setExtensionSchemas(new ArrayList<String>());
metadataFilter.setRemoveRolelessEntityDescriptors(true);
metadataFilter.setRemoveEmptyEntitiesDescriptors(true);
metadataFilter.setRetainedRoles(new ArrayList<String>());
metadataFilter.setRequireSignedMetadata(false);
return metadataFilter;
}
use of org.gluu.oxtrust.model.MetadataFilter in project oxTrust by GluuFederation.
the class FilterService method getAvailableMetadataFilters.
public List<MetadataFilter> getAvailableMetadataFilters() {
String idpTemplatesLocation = configurationFactory.getIDPTemplatesLocation();
// File filterFolder = new File(configurationFactory.DIR + "shibboleth3" + File.separator + "idp" + File.separator + "MetadataFilter");
File filterFolder = new File(idpTemplatesLocation + "shibboleth3" + File.separator + "idp" + File.separator + "MetadataFilter");
File[] filterTemplates = null;
List<MetadataFilter> metadataFilters = new ArrayList<MetadataFilter>();
if (filterFolder.exists() && filterFolder.isDirectory()) {
filterTemplates = filterFolder.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith("Filter.xml.vm");
}
});
for (File filterTemplate : filterTemplates) {
metadataFilters.add(createMetadataFilter(filterTemplate.getName().split("Filter")[0]));
}
}
return metadataFilters;
}
use of org.gluu.oxtrust.model.MetadataFilter in project oxTrust by GluuFederation.
the class MetadataFiltersAction method initMetadataFilters.
public String initMetadataFilters(GluuSAMLTrustRelationship trustRelationship) {
if (metadataFilters != null) {
return OxTrustConstants.RESULT_SUCCESS;
}
this.trustRelationship = trustRelationship;
try {
filterService.parseFilters(trustRelationship);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
metadataFilters = filterService.getFiltersList(trustRelationship);
availableMetadataFilters = filterService.getAvailableMetadataFilters();
// availableMetadataFilters.removeAll(metadataFilters);
this.metadataFilterSelected = new MetadataFilter();
return OxTrustConstants.RESULT_SUCCESS;
}
Aggregations