1 package edu.internet2.middleware.shibboleth.common;
3 import java.io.ByteArrayInputStream;
4 import java.io.InputStream;
5 import org.xml.sax.EntityResolver;
6 import org.xml.sax.InputSource;
7 import org.xml.sax.SAXException;
10 * Utility class for XML constants and schema handling
12 * @author Scott Cantor
13 * @created January 2, 2002
17 /** Shibboleth extension XML namespace */
18 public final static String SHIB_NS = "urn:mace:shibboleth:1.0";
20 /** Shibboleth XML schema identifier */
21 public final static String SHIB_SCHEMA_ID = "shibboleth.xsd";
23 private static byte[] Shib_schema;
26 * Custom schema resolver class
28 * @author Scott Cantor
29 * @created May 18, 2002
31 protected static class SchemaResolver implements EntityResolver
34 * A customized entity resolver for the Shibboleth extension schema
36 * @param publicId The public identifier of the entity
37 * @param systemId The system identifier of the entity
38 * @return A source of bytes for the entity or
40 * @exception SAXException Raised if an XML parsing problem
42 * @exception java.io.IOException Raised if an I/O problem is detected
44 public InputSource resolveEntity(String publicId, String systemId)
45 throws SAXException, java.io.IOException
47 InputSource src = null;
48 if (systemId.endsWith('/' + SHIB_SCHEMA_ID) && Shib_schema != null)
49 src = new InputSource(new ByteArrayInputStream(Shib_schema));
58 StringBuffer buf = new StringBuffer(1024);
59 InputStream xmlin = XML.class.getResourceAsStream("/schemas/" + SHIB_SCHEMA_ID);
61 throw new RuntimeException("XML static initializer unable to locate Shibboleth schema");
65 while ((b = xmlin.read()) != -1)
67 Shib_schema = buf.toString().getBytes();
71 catch (java.io.IOException e)
73 throw new RuntimeException("XML static initializer caught an I/O error");