disambiguate get_subject and pretty_subject
Thierry Parmentelat [Tue, 14 Apr 2015 11:00:07 +0000 (13:00 +0200)]
sfa/trust/auth.py
sfa/trust/certificate.py
sfa/trust/credential.py

index 2c5a447..e852e19 100644 (file)
@@ -145,7 +145,7 @@ class Auth:
         
         # make sure the client_gid is not blank
         if not self.client_gid:
-            raise MissingCallerGID(self.client_cred.get_subject())
+            raise MissingCallerGID(self.client_cred.pretty_subject())
        
         # validate the client cert if it exists
         if self.peer_cert:
index dc2672f..c3f3790 100644 (file)
@@ -505,13 +505,13 @@ class Certificate:
                 return " "+chunk
 
     def pretty_cert(self):
+        message = "[Cert."
         x = self.x509.get_subject()
         ou = getattr(x, "OU")
-        cn = getattr(x, "CN")
-        data = self.get_data(field='subjectAltName')
-        message = "[Cert."
         if ou: message += " OU: {}".format(ou)
+        cn = getattr(x, "CN")
         if cn: message += " CN: {}".format(cn)
+        data = self.get_data(field='subjectAltName')
         if data:
             message += " SubjectAltName:"
             counter = 0
index 20b1dfd..1f924e0 100644 (file)
@@ -284,7 +284,7 @@ class Credential(object):
                 self.xmlsec_path = path + '/' + 'xmlsec1'
                 break
 
-    def get_subject(self):
+    def pretty_subject(self):
         subject = ""
         if not self.gidObject:
             self.decode()
@@ -1078,7 +1078,7 @@ class Credential(object):
     # show_xml is ignored
     def dump_string(self, dump_parents=False, show_xml=None):
         result=""
-        result += "CREDENTIAL %s\n" % self.get_subject()
+        result += "CREDENTIAL %s\n" % self.pretty_subject()
         filename=self.get_filename()
         if filename: result += "Filename %s\n"%filename
         privileges = self.get_privileges()