package edu.internet2.middleware.shibboleth.aa.arp;
-import java.io.StringWriter;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.log4j.Logger;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import edu.internet2.middleware.shibboleth.aa.arp.ArpAttributeSet.ArpAttributeIterator;
import edu.internet2.middleware.shibboleth.common.ShibbolethOriginConfig;
+import edu.internet2.middleware.shibboleth.xml.Parser;
/**
* Defines a processing engine for Attribute Release Policies.
log.debug("Creating effective ARP from (" + userPolicies.length + ") polic(y|ies).");
try {
for (int i = 0; userPolicies.length > i; i++) {
- StringWriter writer = new StringWriter();
- OutputFormat format = new OutputFormat();
- format.setIndent(4);
- XMLSerializer serializer = new XMLSerializer(writer, format);
- serializer.serialize(userPolicies[i].unmarshall());
- log.debug("Dumping ARP:" + System.getProperty("line.separator") + writer.toString());
+ String dump=Parser.serialize(userPolicies[i].unmarshall());
+ log.debug("Dumping ARP:" + System.getProperty("line.separator") + dump);
}
} catch (Exception e) {
log.error(
import java.security.Principal;
import org.apache.log4j.Logger;
-import org.apache.xerces.parsers.DOMParser;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
import edu.internet2.middleware.shibboleth.aa.arp.Arp;
import edu.internet2.middleware.shibboleth.aa.arp.ArpRepository;
import edu.internet2.middleware.shibboleth.aa.arp.ArpRepositoryException;
import edu.internet2.middleware.shibboleth.common.ShibResource;
import edu.internet2.middleware.shibboleth.common.ShibbolethOriginConfig;
+import edu.internet2.middleware.shibboleth.xml.Parser;
/**
* Simple <code>ArpRepository</code> implementation that uses a filesystem
return null;
}
- DOMParser parser = new DOMParser();
- parser.setFeature("http://xml.org/sax/features/validation", true);
- parser.setFeature("http://apache.org/xml/features/validation/schema", true);
- parser.setEntityResolver(new EntityResolver() {
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
-
- if (systemId.endsWith("shibboleth-arp-1.0.xsd")) {
- try {
- return new InputSource(
- new ShibResource("/schemas/shibboleth-arp-1.0.xsd", this.getClass()).getInputStream());
- } catch (IOException e) {
- throw new SAXException("Could not load entity: " + e);
- }
- } else {
- return null;
- }
- }
- });
-
- parser.setErrorHandler(new ErrorHandler() {
- public void error(SAXParseException arg0) throws SAXException {
- throw new SAXException("Error parsing xml file: " + arg0);
- }
- public void fatalError(SAXParseException arg0) throws SAXException {
- throw new SAXException("Error parsing xml file: " + arg0);
- }
- public void warning(SAXParseException arg0) throws SAXException {
- throw new SAXException("Error parsing xml file: " + arg0);
- }
- });
+ Parser.DOMParser parser = new Parser.DOMParser(true);
parser.parse(new InputSource(resource.getInputStream()));
return parser.getDocument().getDocumentElement();
initialized = true;
- org.opensaml.XML.parserPool.registerSchema(XML.SHIB_NS, XML.SHIB_SCHEMA_ID, new XML.SchemaResolver());
}
static
import java.util.Map;
import org.apache.log4j.Logger;
-import org.apache.xerces.parsers.DOMParser;
import org.opensaml.SAMLException;
import org.opensaml.SAMLNameIdentifier;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
import edu.internet2.middleware.shibboleth.hs.provider.SharedMemoryShibHandle;
+import edu.internet2.middleware.shibboleth.xml.Parser;
/**
* Facility for managing mappings from SAML Name Identifiers to local {@link AuthNPrincipal}objects. Mappings are
//Load the default mapping
String rawConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<NameMapping format=\"urn:mace:shibboleth:1.0:nameIdentifier\"" + " handleTTL=\"1800\"/>";
- DOMParser parser = new DOMParser();
+ Parser.DOMParser parser = new Parser.DOMParser(false);
parser.parse(new InputSource(new StringReader(rawConfig)));
defaultMapping = new SharedMemoryShibHandle(parser.getDocument().getDocumentElement());
package edu.internet2.middleware.shibboleth.common;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.StringTokenizer;
-
import javax.servlet.ServletContext;
-
import org.apache.log4j.Logger;
-import org.apache.xerces.parsers.DOMParser;
import org.w3c.dom.Document;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
+
+import edu.internet2.middleware.shibboleth.xml.Parser;
/**
* Constructs a DOM tree for the origin configuration XML file.
+ configFileLocation + "). This probably indicates a bug in shibboleth.");
originConfigFile = configFileLocation;
}
-
- DOMParser parser = new DOMParser();
-
- try {
- parser.setFeature("http://xml.org/sax/features/validation", true);
- parser.setFeature("http://apache.org/xml/features/validation/schema", true);
-
- parser.setEntityResolver(new EntityResolver() {
-
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
- log.debug("Resolving entity for System ID: " + systemId);
- if (systemId != null) {
- StringTokenizer tokenString = new StringTokenizer(systemId, "/");
- String xsdFile = "";
- while (tokenString.hasMoreTokens()) {
- xsdFile = tokenString.nextToken();
- }
- if (xsdFile.endsWith(".xsd")) {
- InputStream stream;
- try {
- stream = new ShibResource("/schemas/" + xsdFile, OriginConfig.class).getInputStream();
- } catch (IOException ioe) {
- log.error("Error loading schema: " + xsdFile + ": " + ioe);
- return null;
- }
- if (stream != null) {
- return new InputSource(stream);
- }
- }
- }
- return null;
- }
- });
-
- parser.setErrorHandler(new ErrorHandler() {
-
- public void error(SAXParseException arg0) throws SAXException {
- throw new SAXException("Error parsing xml file: " + arg0);
- }
-
- public void fatalError(SAXParseException arg0) throws SAXException {
- throw new SAXException("Error parsing xml file: " + arg0);
- }
-
- public void warning(SAXParseException arg0) throws SAXException {
- throw new SAXException("Error parsing xml file: " + arg0);
- }
- });
-
- } catch (SAXException e) {
- log.error("Unable to setup a workable XML parser: " + e);
- throw new ShibbolethConfigurationException("Unable to setup a workable XML parser.");
- }
-
- log.debug("Loading Configuration from (" + originConfigFile + ").");
-
- try {
- parser.parse(new InputSource(new ShibResource(originConfigFile, OriginConfig.class).getInputStream()));
- } catch (SAXException e) {
- log.error("Error while parsing origin configuration: " + e);
- throw new ShibbolethConfigurationException("Error while parsing origin configuration:" + e);
- } catch (IOException e) {
- log.error("Could not load origin configuration: " + e);
- throw new ShibbolethConfigurationException("Could not load origin configuration.");
- }
-
- originConfig = parser.getDocument();
+
+ originConfig = Parser.loadDom(configFileLocation, true);
+ if (originConfig==null)
+ throw new ShibbolethConfigurationException("Problem in "+XML.ORIGIN_SHEMA_ID+" see log");
return originConfig;
}
package edu.internet2.middleware.shibboleth.common;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
/**
- * Utility class for XML constants and schema handling
+ * Utility class for XML constants
*
* @author Scott Cantor
* @created January 2, 2002
{
/** Shibboleth XML namespace */
public final static String SHIB_NS = "urn:mace:shibboleth:1.0";
-
+
/** Shibboleth XML schema identifier */
public final static String SHIB_SCHEMA_ID = "shibboleth.xsd";
-
+
/** Shibboleth trust metadata XML namespace */
public final static String TRUST_NS = "urn:mace:shibboleth:trust:1.0";
public final static String TRUST_SCHEMA_ID = "shibboleth-trust-1.0.xsd";
public final static String MAIN_SHEMA_ID = "shibboleth-targetconfig-1.0.xsd";
+ public final static String ORIGIN_SHEMA_ID = "origin.xsd";
- public final static String XMLSIG_RETMETHOD_RAWX509 = "http://www.w3.org/2000/09/xmldsig#rawX509Certificate";
+ public final static String XMLSIG_RETMETHOD_RAWX509 = "http://www.w3.org/2000/09/xmldsig#rawX509Certificate";
public final static String XMLSIG_RETMETHOD_RAWX509CRL = "http://www.w3.org/2000/09/xmldsig-more#rawX509CRL";
public final static String SHIB_RETMETHOD_PEMX509 = "urn:mace:shibboleth:RetrievalMethod:pemX509Certificate";
public final static String SHIB_RETMETHOD_PEMX509CRL = "urn:mace:shibboleth:RetrievalMethod:pemX509CRL";
- private static byte[] Shib_schema;
- private static byte[] Trust_schema;
-
- /**
- * Custom schema resolver class
- *
- * @author Scott Cantor
- * @created May 18, 2002
- */
- public static class SchemaResolver implements EntityResolver {
- /**
- * A customized entity resolver for the Shibboleth extension schema
- *
- * @param publicId The public identifier of the entity
- * @param systemId The system identifier of the entity
- * @return A source of bytes for the entity or null
- * @exception SAXException Raised if an XML parsing problem occurs
- * @exception java.io.IOException Raised if an I/O problem is detected
- */
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException, java.io.IOException {
- InputSource src = null;
- if (systemId.endsWith(SHIB_SCHEMA_ID) && Shib_schema != null)
- src = new InputSource(new ByteArrayInputStream(Shib_schema));
- else if (systemId.endsWith(TRUST_SCHEMA_ID) && Trust_schema != null)
- src = new InputSource(new ByteArrayInputStream(Trust_schema));
- return src;
- }
- }
-
- static {
- try {
- StringBuffer buf = new StringBuffer(4096);
- InputStream xmlin = XML.class.getResourceAsStream("/schemas/" + SHIB_SCHEMA_ID);
- if (xmlin == null)
- throw new RuntimeException("XML static initializer unable to locate Shibboleth schema");
- else {
- int b;
- while ((b = xmlin.read()) != -1)
- buf.append((char)b);
- Shib_schema = buf.toString().getBytes();
- xmlin.close();
- }
-
- xmlin = XML.class.getResourceAsStream("/schemas/" + TRUST_SCHEMA_ID);
- if (xmlin == null)
- throw new RuntimeException("XML static initializer unable to locate Shibboleth trust schema");
- else {
- int b;
- buf.setLength(0);
- while ((b = xmlin.read()) != -1)
- buf.append((char)b);
- Trust_schema = buf.toString().getBytes();
- xmlin.close();
- }
- }
- catch (java.io.IOException e) {
- throw new RuntimeException("XML static initializer caught an I/O error");
- }
- }
}
import org.opensaml.SAMLException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import edu.internet2.middleware.shibboleth.common.ResourceWatchdog;
import edu.internet2.middleware.shibboleth.common.ResourceWatchdogExecutionException;
import edu.internet2.middleware.shibboleth.metadata.Metadata;
import edu.internet2.middleware.shibboleth.metadata.MetadataException;
import edu.internet2.middleware.shibboleth.metadata.Provider;
+import edu.internet2.middleware.shibboleth.xml.Parser;
/**
* @author Walter Hoehn (wassa@columbia.edu)
public XMLMetadataLoadWrapper(String sitesFileLocation) throws MetadataException, ResourceNotAvailableException {
super(new ShibResource(sitesFileLocation, XMLMetadataLoadWrapper.class));
try {
- org.opensaml.XML.parserPool.registerSchema(XML.SHIB_NS, XML.SHIB_SCHEMA_ID, new XML.SchemaResolver());
- Document doc = org.opensaml.XML.parserPool.parse(resource.getInputStream());
+ Document doc = Parser.loadDom(new InputSource(resource.getInputStream()),true);
currentMeta = new XMLMetadata(doc.getDocumentElement());
- } catch (SAMLException e) {
- log.error("Encountered a problem parsing federation metadata source: " + e);
- throw new MetadataException("Unable to parse federation metadata.");
- } catch (SAXException e) {
- log.error("Encountered a problem parsing federation metadata source: " + e);
- throw new MetadataException("Unable to parse federation metadata.");
} catch (IOException e) {
log.error("Encountered a problem reading federation metadata source: " + e);
throw new MetadataException("Unable to read federation metadata.");
//Load new, but keep the old in place
try {
- newDoc = org.opensaml.XML.parserPool.parse(resource.getInputStream());
- } catch (SAMLException e) {
- log.error("Encountered an error parsing updated federation metadata, continuing to use stale copy.");
- return;
- } catch (SAXException e) {
- log.error("Encountered an error parsing updated federation metadata, continuing to use stale copy.");
- return;
- } catch (IOException e) {
+ newDoc = Parser.loadDom(new InputSource(resource.getInputStream()),true);
+ } catch (IOException e) {
log.error("Encountered an error retrieving updated federation metadata, continuing to use stale copy.");
return;
}
import org.w3c.dom.*;
import edu.internet2.middleware.shibboleth.common.XML;
+import edu.internet2.middleware.shibboleth.xml.Parser;
/**
* Signs/verifies/maintains Shibboleth metadata files
System.exit(1);
}
- org.opensaml.XML.parserPool.registerSchema(XML.SHIB_NS, XML.SHIB_SCHEMA_ID, new XML.SchemaResolver());
- org.opensaml.XML.parserPool.registerSchema(XML.TRUST_NS, XML.TRUST_SCHEMA_ID, new XML.SchemaResolver());
// Parse file and verify root element.
- Document doc = org.opensaml.XML.parserPool.parse(infile);
+ Document doc = Parser.loadDom(infile,true);
Element e = doc.getDocumentElement();
if (ns != null && name != null && !org.opensaml.XML.isElementNamed(e,ns,name)) {
System.err.println("error: root element did not match ns and name parameters");
import jargs.gnu.CmdLineParser;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.net.URL;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
import org.opensaml.SAMLException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import edu.internet2.middleware.shibboleth.common.OriginConfig;
import edu.internet2.middleware.shibboleth.common.ShibbolethConfigurationException;
import edu.internet2.middleware.shibboleth.common.ShibbolethOriginConfig;
+import edu.internet2.middleware.shibboleth.xml.Parser;
/**
* Utility for testing an Attribute Resolver configuration.
System.err.println("Received bad Element data from SAML library.");
System.exit(1);
}
- OutputFormat format = new OutputFormat();
- format.setIndenting(true);
- format.setIndent(4);
-
- new XMLSerializer(xml, format).serialize((Element) node);
-
- out.println(xml.toString());
+ out.println(Parser.serialize(node));
out.println();
}
}
System.err.println("Error creating SAML attribute: " + e.getMessage());
System.exit(1);
}
- catch (IOException e) {
- System.err.println("Error serializing output from Resolver: " + e.getMessage());
- System.exit(1);
- }
}
private static void configureLogging(boolean debugEnabled)
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
-import org.apache.xerces.parsers.DOMParser;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
import edu.internet2.middleware.shibboleth.aa.AAAttributeSet;
import edu.internet2.middleware.shibboleth.common.AuthNPrincipal;
import edu.internet2.middleware.shibboleth.common.ShibbolethOriginConfig;
+import edu.internet2.middleware.shibboleth.xml.Parser;
/**
* Validation suite for <code>Arp</code> processing.
public class ArpTests extends TestCase {
- private DOMParser parser = new DOMParser();
+ private Parser.DOMParser parser = new Parser.DOMParser(true);
Element memoryRepositoryElement;
private String[] arpExamples =
{
super.setUp();
// Setup an xml parser
- try {
- parser.setFeature("http://xml.org/sax/features/validation", true);
- parser.setFeature("http://apache.org/xml/features/validation/schema", true);
- parser.setEntityResolver(new EntityResolver() {
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
-
- if (systemId.endsWith("shibboleth-arp-1.0.xsd")) {
- InputStream stream;
- try {
- stream = new FileInputStream("src/schemas/shibboleth-arp-1.0.xsd");
- if (stream != null) {
- return new InputSource(stream);
- }
- throw new SAXException("Could not load entity: Null input stream");
- } catch (FileNotFoundException e) {
- throw new SAXException("Could not load entity: " + e);
- }
- } else {
- return null;
- }
- }
- });
-
- parser.setErrorHandler(new ErrorHandler() {
- public void error(SAXParseException arg0) throws SAXException {
- throw new SAXException("Error parsing xml file: " + arg0);
- }
- public void fatalError(SAXParseException arg0) throws SAXException {
- throw new SAXException("Error parsing xml file: " + arg0);
- }
- public void warning(SAXParseException arg0) throws SAXException {
- throw new SAXException("Error parsing xml file: " + arg0);
- }
- });
- } catch (Exception e) {
- fail("Failed to setup xml parser: " + e);
- }
//Setup a dummy xml config for a Memory-based repository
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
InputStream inStream = new FileInputStream("data/arp.site.xml");
parser.parse(new InputSource(inStream));
- ByteArrayOutputStream directXML = new ByteArrayOutputStream();
- new XMLSerializer(directXML, new OutputFormat()).serialize(parser.getDocument().getDocumentElement());
+ String directXML = Parser.serialize(parser.getDocument().getDocumentElement());
- ByteArrayOutputStream processedXML = new ByteArrayOutputStream();
- new XMLSerializer(processedXML, new OutputFormat()).serialize(siteArp.unmarshall());
+ String processedXML = Parser.serialize(siteArp.unmarshall());
assertTrue(
"File-based ARP Repository did not return the correct site ARP.",
inStream = new FileInputStream("data/arp.user.test.xml");
parser.parse(new InputSource(inStream));
- directXML = new ByteArrayOutputStream();
- new XMLSerializer(directXML, new OutputFormat()).serialize(parser.getDocument().getDocumentElement());
+ directXML = Parser.serialize(parser.getDocument().getDocumentElement());
- processedXML = new ByteArrayOutputStream();
- new XMLSerializer(processedXML, new OutputFormat()).serialize(userArp.unmarshall());
+ processedXML = Parser.serialize(userArp.unmarshall());
assertTrue(
"File-based ARP Repository did not return the correct user ARP.",
InputStream inStream = new FileInputStream(arpExamples[i]);
parser.parse(new InputSource(inStream));
- ByteArrayOutputStream directXML = new ByteArrayOutputStream();
- new XMLSerializer(directXML, new OutputFormat()).serialize(parser.getDocument().getDocumentElement());
+ String directXML = Parser.serialize(parser.getDocument().getDocumentElement());
Arp arp1 = new Arp();
arp1.marshall(parser.getDocument().getDocumentElement());
- ByteArrayOutputStream processedXML = new ByteArrayOutputStream();
- new XMLSerializer(processedXML, new OutputFormat()).serialize(arp1.unmarshall());
+ String processedXML = Parser.serialize(arp1.unmarshall());
assertTrue(
"Round trip marshall/unmarshall failed for file (" + arpExamples[i] + ")",
* Target: Any
* Attribute: Any value release,
*/
- void arpApplicationTest1(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest1(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Any
* Attribute: Any value release, implicit deny
*/
- void arpApplicationTest2(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest2(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Any
* Attribute: One value release
*/
- void arpApplicationTest3(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest3(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Any
* Attribute: Any value except one release, canonical representation
*/
- void arpApplicationTest4(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest4(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Any
* Attribute: Any value except one release, expanded representation
*/
- void arpApplicationTest5(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest5(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Any
* Attribute: Any value except two release, expanded representation
*/
- void arpApplicationTest6(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest6(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Any
* Attribute: Two value release, canonical representation
*/
- void arpApplicationTest7(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest7(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Any
* Attribute: Two value release, expanded representation
*/
- void arpApplicationTest8(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest8(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Any
* Attribute: Any value deny
*/
- void arpApplicationTest9(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest9(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Any
* Attribute: Any value deny trumps explicit permit expanded representation
*/
- void arpApplicationTest10(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest10(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Any
* Attribute: Any value deny trumps explicit permit canonical representation
*/
- void arpApplicationTest11(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest11(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Specific shar, Any Resource
* Attribute: Any value release
*/
- void arpApplicationTest12(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest12(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Specific shar, Any Resource (another example)
* Attribute: Any value release
*/
- void arpApplicationTest13(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest13(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Specific shar (no match), Any Resource
* Attribute: Any value release
*/
- void arpApplicationTest14(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest14(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Specific shar, Specific resource
* Attribute: Any value release
*/
- void arpApplicationTest15(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest15(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Specific shar, Specific resource (no match)
* Attribute: Any value release
*/
- void arpApplicationTest16(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest16(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Multiple matching rules
* Attribute: various
*/
- void arpApplicationTest17(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest17(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Any
* Attribute: Any value release of two attributes in one rule
*/
- void arpApplicationTest18(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest18(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Any
* Attribute: Any value release,
*/
- void arpApplicationTest19(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest19(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: various
* Attribute: various combinations
*/
- void arpApplicationTest20(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest20(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawSiteArp =
* Target: various
* Attribute: various combinations (same ARPs as 20, different requester)
*/
- void arpApplicationTest21(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest21(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawSiteArp =
* Target: Specific shar, Specific resource
* Attribute: Release values by regex
*/
- void arpApplicationTest22(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest22(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Specific shar, Specific resource
* Attribute: Deny specific values by regex
*/
- void arpApplicationTest23(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest23(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
* Target: Specific shar, Specific resource
* Attribute: No matches on specific values should yield no attribute
*/
- void arpApplicationTest24(ArpRepository repository, DOMParser parser) throws Exception {
+ void arpApplicationTest24(ArpRepository repository, Parser.DOMParser parser) throws Exception {
//Gather the Input
String rawArp =
package edu.internet2.middleware.shibboleth.common;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.InputStream;
import junit.framework.TestCase;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
-import org.apache.xerces.parsers.DOMParser;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
+import edu.internet2.middleware.shibboleth.xml.Parser;
/**
* Validation suite for the <code>Credentials</code> interface.
public class CredentialsTests extends TestCase {
- private DOMParser parser = new DOMParser();
+ private Parser.DOMParser parser = new Parser.DOMParser(true);
public CredentialsTests(String name) {
super(name);
*/
protected void setUp() throws Exception {
super.setUp();
- try {
- parser.setFeature("http://xml.org/sax/features/validation", true);
- parser.setFeature("http://apache.org/xml/features/validation/schema", true);
- parser.setEntityResolver(new EntityResolver() {
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
-
- if (systemId.endsWith("credentials.xsd")) {
- InputStream stream;
- try {
- stream = new FileInputStream("src/schemas/credentials.xsd");
- if (stream != null) {
- return new InputSource(stream);
- }
- throw new SAXException("Could not load entity: Null input stream");
- } catch (FileNotFoundException e) {
- throw new SAXException("Could not load entity: " + e);
- }
- } else if (systemId.endsWith("xmldsig-core-schema.xsd")) {
- InputStream stream;
- try {
- stream = new FileInputStream("src/schemas/xmldsig-core-schema.xsd");
- if (stream != null) {
- return new InputSource(stream);
- }
- throw new SAXException("Could not load entity: Null input stream");
- } catch (FileNotFoundException e) {
- throw new SAXException("Could not load entity: " + e);
- }
- } else {
- return null;
- }
- }
- });
-
- parser.setErrorHandler(new ErrorHandler() {
- public void error(SAXParseException arg0) throws SAXException {
- throw new SAXException("Error parsing xml file: " + arg0);
- }
- public void fatalError(SAXParseException arg0) throws SAXException {
- throw new SAXException("Error parsing xml file: " + arg0);
- }
- public void warning(SAXParseException arg0) throws SAXException {
- throw new SAXException("Error parsing xml file: " + arg0);
- }
- });
- } catch (Exception e) {
- fail("Failed to setup xml parser: " + e);
- }
-
}
public void testKeyStoreX509CompleteChain() {
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
-import org.apache.xerces.parsers.DOMParser;
import org.opensaml.SAMLNameIdentifier;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import edu.internet2.middleware.shibboleth.common.NameIdentifierMappingException;
import edu.internet2.middleware.shibboleth.common.NameMapper;
import edu.internet2.middleware.shibboleth.common.ServiceProvider;
+import edu.internet2.middleware.shibboleth.xml.Parser;
+
/**
public class NameMapperTests extends TestCase {
- private DOMParser parser = new DOMParser();
+ private Parser.DOMParser parser = new Parser.DOMParser(true);
public NameMapperTests(String name) {
protected void setUp() throws Exception {
super.setUp();
- try {
-
- parser.setFeature("http://xml.org/sax/features/validation", true);
- parser.setFeature("http://apache.org/xml/features/validation/schema", true);
- parser.setEntityResolver(new EntityResolver() {
-
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
-
- if (systemId.endsWith("namemapper.xsd")) {
- InputStream stream;
- try {
- stream = new FileInputStream("src/schemas/namemapper.xsd");
- if (stream != null) { return new InputSource(stream); }
- throw new SAXException("Could not load entity: Null input stream");
- } catch (FileNotFoundException e) {
- throw new SAXException("Could not load entity: " + e);
- }
- } else {
- return null;
- }
- }
- });
-
- parser.setErrorHandler(new ErrorHandler() {
-
- public void error(SAXParseException arg0) throws SAXException {
- throw new SAXException("Error parsing xml file: " + arg0);
- }
-
- public void fatalError(SAXParseException arg0) throws SAXException {
-
- throw new SAXException("Error parsing xml file: " + arg0);
- }
-
- public void warning(SAXParseException arg0) throws SAXException {
-
- throw new SAXException("Error parsing xml file: " + arg0);
- }
- });
- } catch (Exception e) {
- fail("Failed to setup xml parser: " + e);
- }
}
public void testCryptoMapping() {
package edu.internet2.middleware.shibboleth.metadata;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
import java.util.Arrays;
import junit.framework.TestCase;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
-import org.apache.xerces.parsers.DOMParser;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
import edu.internet2.middleware.shibboleth.metadata.provider.XMLMetadataLoadWrapper;
public class MetadataTests extends TestCase {
- private DOMParser parser = new DOMParser();
public MetadataTests(String name) {
super(name);
protected void setUp() throws Exception {
super.setUp();
- try {
- parser.setFeature("http://xml.org/sax/features/validation", true);
- parser.setFeature("http://apache.org/xml/features/validation/schema", true);
- parser.setEntityResolver(new EntityResolver() {
-
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
-
- if (systemId.endsWith("credentials.xsd")) {
- InputStream stream;
- try {
- stream = new FileInputStream("src/schemas/shibboleth.xsd");
- if (stream != null) {
- return new InputSource(stream);
- }
- throw new SAXException("Could not load entity: Null input stream");
- } catch (FileNotFoundException e) {
- throw new SAXException("Could not load entity: " + e);
- }
- } else if (systemId.endsWith("xmldsig-core-schema.xsd")) {
- InputStream stream;
- try {
- stream = new FileInputStream("src/schemas/xmldsig-core-schema.xsd");
- if (stream != null) {
- return new InputSource(stream);
- }
- throw new SAXException("Could not load entity: Null input stream");
- } catch (FileNotFoundException e) {
- throw new SAXException("Could not load entity: " + e);
- }
- } else {
- return null;
- }
- }
- });
-
- parser.setErrorHandler(new ErrorHandler() {
-
- public void error(SAXParseException arg0) throws SAXException {
- throw new SAXException("Error parsing xml file: " + arg0);
- }
-
- public void fatalError(SAXParseException arg0) throws SAXException {
- throw new SAXException("Error parsing xml file: " + arg0);
- }
-
- public void warning(SAXParseException arg0) throws SAXException {
- throw new SAXException("Error parsing xml file: " + arg0);
- }
- });
- } catch (Exception e) {
- fail("Failed to setup xml parser: " + e);
- }
}