validate credential against XSD schema instead of RelaxNG
Tony Mack [Tue, 30 Nov 2010 16:39:40 +0000 (11:39 -0500)]
setup.py
sfa.spec
sfa/trust/credential.py

index 3a76835..f6fcdcd 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -55,9 +55,10 @@ data_files = [('/etc/sfa/', [ 'config/aggregates.xml',
                               'config/default_config.xml',
                               'config/sfi_config',
                               'sfa/managers/pl/pl.rng',
-                              'sfa/trust/credential.rng',
-                              'sfa/trust/top.rng',
-                              'sfa/trust/protogeni-rspec-common.rng',
+                              'sfa/trust/credential.xsd',
+                              'sfa/trust/top.xsd',
+                              'sfa/trust/xml.xsd',
+                              'sfa/trust/protogeni-rspec-common.xsd',
                             ]),
               ('/etc/sfatables/matches/', glob('sfatables/matches/*.xml')),
               ('/etc/sfatables/targets/', glob('sfatables/targets/*.xml')),
index 1c182f4..8efdd5d 100644 (file)
--- a/sfa.spec
+++ b/sfa.spec
@@ -131,9 +131,10 @@ rm -rf $RPM_BUILD_ROOT
 %config (noreplace) /etc/sfa/registries.xml
 /etc/init.d/sfa
 /etc/sfa/pl.rng
-/etc/sfa/credential.rng
-/etc/sfa/top.rng
-/etc/sfa/protogeni-rspec-common.rng
+/etc/sfa/credential.xsd
+/etc/sfa/top.xsd
+/etc/sfa/xml.xsd
+/etc/sfa/protogeni-rspec-common.xsd
 %{_bindir}/sfa-config-tty
 %{_bindir}/sfa-import-plc.py*
 %{_bindir}/sfa-clean-peer-records.py*
index 5478b03..3268026 100644 (file)
@@ -660,9 +660,9 @@ class Credential(object):
             if schema and os.path.exists(schema):
                 tree = etree.parse(StringIO(self.xml))
                 schema_doc = etree.parse(schema)
-                relaxng = etree.RelaxNG(schema_doc)
-                if not relaxng(tree):
-                    error = relaxng.error_log.last_error
+                xmlschema = etree.XMLSchema(schema_doc)
+                if not xmlschema.validate(tree):
+                    error = xmlschema.error_log.last_error
                     message = "%s (line %s)" % (error.message, error.line)
                     raise CredentialNotVerifiable(message)