handle escape chars in hrn
[sfa.git] / sfa / trust / gid.py
index 8d1017f..3b1f96c 100644 (file)
@@ -66,11 +66,6 @@ def create_uuid():
 
 
 class GID(Certificate):
-    uuid = None
-    hrn = None
-    urn = None
-    email = None # for adding to the SubjectAltName
-
     ##
     # Create a new GID object
     #
@@ -79,9 +74,13 @@ class GID(Certificate):
     # @param string If string!=None, load the GID from a string
     # @param filename If filename!=None, load the GID from a file
     # @param lifeDays life of GID in days - default is 1825==5 years
+    # @param email Email address to put in subjectAltName - default is None
 
-    def __init__(self, create=False, subject=None, string=None, filename=None, uuid=None, hrn=None, urn=None, lifeDays=1825):
-        
+    def __init__(self, create=False, subject=None, string=None, filename=None, uuid=None, hrn=None, urn=None, lifeDays=1825, email=None):
+        self.uuid = None
+        self.hrn = None
+        self.urn = None
+        self.email = None # for adding to the SubjectAltName             
         Certificate.__init__(self, lifeDays, create, subject, string, filename)
         if subject:
             logger.debug("Creating GID for subject: %s" % subject)
@@ -93,6 +92,8 @@ class GID(Certificate):
         if urn:
             self.urn = urn
             self.hrn, type = urn_to_hrn(urn)
+        if email:
+            self.set_email(email)
 
     def set_uuid(self, uuid):
         if isinstance(uuid, str):
@@ -158,8 +159,6 @@ class GID(Certificate):
 
         self.set_data(str, 'subjectAltName')
 
-        
-
 
     ##
     # Decode the subject-alt-name field of the X509 certificate into the
@@ -251,7 +250,7 @@ class GID(Certificate):
             #    trusted_hrn = trusted_hrn[:trusted_hrn.rindex('.')]
             cur_hrn = self.get_hrn()
             if not hrn_authfor_hrn(trusted_hrn, cur_hrn):
-                raise GidParentHrn("Trusted root with HRN %s isn't a namespace authority for this cert %s" % (trusted_hrn, cur_hrn))
+                raise GidParentHrn("Trusted root with HRN %s isn't a namespace authority for this cert: %s" % (trusted_hrn, cur_hrn))
 
             # There are multiple types of authority - accept them all here
             if not trusted_type.find('authority') == 0: