Add schema for Name Identifier Mappings and schema checking for tests.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Wed, 21 Jan 2004 06:43:38 +0000 (06:43 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Wed, 21 Jan 2004 06:43:38 +0000 (06:43 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@830 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/common/NameIdentifierMapping.java
src/schemas/namemapper.xsd [new file with mode: 0644]
tests/edu/internet2/middleware/shibboleth/hs/provider/NameMapperTests.java

index 1d8484e..1159024 100644 (file)
@@ -59,7 +59,7 @@ import org.opensaml.SAMLNameIdentifier;
  */
 public interface NameIdentifierMapping {
 
-       public static final String mappingNamespace = "urn:mace:shibboleth:origin.config:1.0";
+       public static final String mappingNamespace = "urn:mace:shibboleth:namemapper:1.0";
 
        /**
         * Returns the Name Identifier format for this mapping.
diff --git a/src/schemas/namemapper.xsd b/src/schemas/namemapper.xsd
new file mode 100644 (file)
index 0000000..693a2b3
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema targetNamespace="urn:mace:shibboleth:namemapper:1.0" xmlns:namemapper="urn:mace:shibboleth:namemapper:1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" elementFormDefault="qualified" attributeFormDefault="unqualified">
+       <xs:element name="NameMapping" type="namemapper:NameMappingType"/>
+       <xs:complexType name="NameMappingType">
+               <xs:sequence minOccurs="0" maxOccurs="unbounded">
+                       <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+               </xs:sequence>
+               <xs:attribute name="format" type="xs:anyURI" use="required"/>
+               <xs:attribute name="id" type="xs:string" use="optional"/>
+               <xs:attribute name="class" type="xs:string" use="optional"/>
+               <xs:attribute name="type" type="xs:string" use="optional"/>
+               <xs:anyAttribute namespace="##any" processContents="lax"/>
+       </xs:complexType>
+</xs:schema>
index 1ab6862..26c2e4c 100644 (file)
@@ -103,15 +103,15 @@ public class NameMapperTests extends TestCase {
                try {
 
                        //TODO turn on validation
-                       parser.setFeature("http://xml.org/sax/features/validation", false);
-                       parser.setFeature("http://apache.org/xml/features/validation/schema", false);
+                       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")) {
+                                       if (systemId.endsWith("namemapper.xsd")) {
                                                InputStream stream;
                                                try {
-                                                       stream = new FileInputStream("src/schemas/shibboleth-arp-1.0.xsd");
+                                                       stream = new FileInputStream("src/schemas/namemapper.xsd");
                                                        if (stream != null) {
                                                                return new InputSource(stream);
                                                        }
@@ -150,8 +150,11 @@ public class NameMapperTests extends TestCase {
 
                        String rawConfig =
                                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
-                                       + "<NameMapping id=\"cryptotest\" format=\"urn:mace:shibboleth:1.0:nameIdentifier\""
-                                       + "             type=\"CryptoHandleGenerator\" handleTTL=\"1800\">"
+                                       + "<NameMapping xmlns=\"urn:mace:shibboleth:namemapper:1.0\""
+                                       + "             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+                                       + "             xsi:schemaLocation=\"urn:mace:shibboleth:namemapper:1.0 namemapper.xsd\" "
+                                       + "                     id=\"cryptotest\" format=\"urn:mace:shibboleth:1.0:nameIdentifier\" "
+                                       + "                     type=\"CryptoHandleGenerator\" handleTTL=\"1800\">"
                                        + "             <KeyStorePath>"
                                        + file.toURL().toString()
                                        + "</KeyStorePath>"
@@ -218,7 +221,10 @@ public class NameMapperTests extends TestCase {
 
                        String rawConfig =
                                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
-                                       + "<NameMapping format=\"urn:mace:shibboleth:1.0:nameIdentifier\""
+                                       + "<NameMapping xmlns=\"urn:mace:shibboleth:namemapper:1.0\""
+                                       + "             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+                                       + "             xsi:schemaLocation=\"urn:mace:shibboleth:namemapper:1.0 namemapper.xsd\" "
+                                       + "                     format=\"urn:mace:shibboleth:1.0:nameIdentifier\""
                                        + "             type=\"CryptoHandleGenerator\" handleTTL=\"1800\">"
                                        + "             <KeyStorePath>"
                                        + file.toURL().toString()
@@ -265,7 +271,10 @@ public class NameMapperTests extends TestCase {
 
                        String rawConfig =
                                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
-                                       + "<NameMapping format=\"urn:mace:shibboleth:1.0:nameIdentifier\""
+                                       + "<NameMapping xmlns=\"urn:mace:shibboleth:namemapper:1.0\""
+                                       + "             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+                                       + "             xsi:schemaLocation=\"urn:mace:shibboleth:namemapper:1.0 namemapper.xsd\" "
+                                       + "                     format=\"urn:mace:shibboleth:1.0:nameIdentifier\""
                                        + "             type=\"CryptoHandleGenerator\" handleTTL=\"1800\">"
                                        + "             <KeyStorePath>"
                                        + file.toURL().toString()
@@ -318,7 +327,11 @@ public class NameMapperTests extends TestCase {
 
                        String rawConfig =
                                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
-                                       + "<NameMapping id=\"memorytest\" format=\"urn:mace:shibboleth:1.0:nameIdentifier\""
+                                       + "<NameMapping xmlns=\"urn:mace:shibboleth:namemapper:1.0\""
+                                       + "             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+                                       + "             xsi:schemaLocation=\"urn:mace:shibboleth:namemapper:1.0 namemapper.xsd\" "
+                                       + "                     id=\"memorytest\" "
+                                       + "             format=\"urn:mace:shibboleth:1.0:nameIdentifier\""
                                        + "             type=\"SharedMemoryShibHandle\" handleTTL=\"1800\"/>";
 
                        parser.parse(new InputSource(new StringReader(rawConfig)));
@@ -354,7 +367,10 @@ public class NameMapperTests extends TestCase {
                        String format = "urn-x:test:NameIdFormat1";
                        String rawConfig =
                                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
-                                       + "<NameMapping format=\""
+                                       + "<NameMapping xmlns=\"urn:mace:shibboleth:namemapper:1.0\""
+                                       + "             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+                                       + "             xsi:schemaLocation=\"urn:mace:shibboleth:namemapper:1.0 namemapper.xsd\" "
+                                       + "                     format=\""
                                        + format
                                        + "\""
                                        + "             type=\"Principal\"/>";