<description>The human readable name for this interface.</description>
</variable>
+ <variable id="credential_schema" type="string">
+ <name>Credential Schema</name>
+ <value>/etc/sfa/credential.rng</value>
+ <description>The path to the default credential schema</description>
+ </variable>
+
<variable id="api_debug" type="boolean">
<name>Debug</name>
<value>false</value>
'config/registries.xml',
'config/default_config.xml',
'config/sfi_config',
- 'sfa/managers/pl/pl.rng']),
+ 'sfa/managers/pl/pl.rng',
+ 'sfa/trust/credential.rng']),
('/etc/sfatables/matches/', glob('sfatables/matches/*.xml')),
('/etc/sfatables/targets/', glob('sfatables/targets/*.xml')),
('/etc/init.d/', ['sfa/init.d/sfa', 'sfa/init.d/sfa-cm'])]
raise InsufficientRights(operation)
if self.trusted_cert_list:
- self.client_cred.verify(self.trusted_cert_file_list)
+ self.client_cred.verify(self.trusted_cert_file_list, self.config.SFA_CREDENTIAL_SCHEMA)
else:
raise MissingTrustedRoots(self.config.get_trustedroots_dir())
from tempfile import mkstemp
from xml.dom.minidom import Document, parseString
from dateutil.parser import parse
-
+from lxml import etree
+from StringIO import StringIO
from sfa.util.faults import *
from sfa.util.sfalogging import sfa_logger
from sfa.trust.certificate import Keypair
# must be done elsewhere
#
# @param trusted_certs: The certificates of trusted CA certificates
- def verify(self, trusted_certs):
+ # @param schema: The RelaxNG schema to validate the credential against
+ def verify(self, trusted_certs, schema=None):
if not self.xml:
self.decode()
+
+ # validate against RelaxNG schema
+ if not self.legacy:
+ 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
+ message = "%s (line %s)" % (error.message, error.line)
+ raise CredentialNotVerifiable(message)
+
-# trusted_cert_objects = [GID(filename=f) for f in trusted_certs]
+# trusted_cert_objects = [GID(filename=f) for f in trusted_certs]
trusted_cert_objects = []
ok_trusted_certs = []
for f in trusted_certs:
if self.legacy.object_gid:
self.legacy.object_gid.verify_chain(trusted_cert_objects)
return True
+
# make sure it is not expired
if self.get_expiration() < datetime.datetime.utcnow():