X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Ftrust%2Fgid.py;h=7e9d40cedffd2d2f3c3eddc634fa737e22de0ade;hb=ed059ad1c34a78aacf0c27b1f0b65b42154b4116;hp=6c0436c4731e2d388841036d694a92849d14d0f3;hpb=f13173726f8382eef380f1e754f24dd2b126a77b;p=sfa.git diff --git a/sfa/trust/gid.py b/sfa/trust/gid.py index 6c0436c4..7e9d40ce 100644 --- a/sfa/trust/gid.py +++ b/sfa/trust/gid.py @@ -1,5 +1,5 @@ ## -# Implements GENI GID. GIDs are based on certificates, and the GID class is a +# Implements SFA GID. GIDs are based on certificates, and the GID class is a # descendant of the certificate class. ## @@ -7,10 +7,10 @@ ### $URL$ import xmlrpclib - import uuid -from sfa.trust.certificate import Certificate +from sfa.trust.certificate import Certificate +from sfa.util.namespace import * ## # Create a new uuid. Returns the UUID as a string. @@ -27,6 +27,10 @@ def create_uuid(): # HRN is a human readable name. It is a dotted form similar to a backward domain # name. For example, planetlab.us.arizona.bakers. # +# URN is a human readable identifier of form: +# "urn:publicid:IDN+toplevelauthority[:sub-auth.]*[\res. type]\ +object name" +# For example, urn:publicid:IDN+planetlab:us:arizona+user+bakers +# # PUBLIC_KEY is the public key of the principal identified by the UUID/HRN. # It is a Keypair object as defined in the cert.py module. # @@ -41,6 +45,7 @@ def create_uuid(): class GID(Certificate): uuid = None hrn = None + urn = None ## # Create a new GID object @@ -50,12 +55,16 @@ 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 - def __init__(self, create=False, subject=None, string=None, filename=None, uuid=None, hrn=None): + def __init__(self, create=False, subject=None, string=None, filename=None, uuid=None, hrn=None, urn=None): + Certificate.__init__(self, create, subject, string, filename) if uuid: self.uuid = uuid if hrn: self.hrn = hrn + if urn: + self.urn = urn + self.hrn, type = urn_to_hrn(urn) def set_uuid(self, uuid): self.uuid = uuid @@ -73,14 +82,28 @@ class GID(Certificate): self.decode() return self.hrn + def set_urn(self, urn): + self.urn = urn + self.hrn, type = urn_to_hrn(urn) + + def get_urn(self): + if not self.urn: + self.decode() + return self.urn + ## # Encode the GID fields and package them into the subject-alt-name field # of the X509 certificate. This must be called prior to signing the # certificate. It may only be called once per certificate. def encode(self): + if self.urn: + urn = self.urn + else: + urn = hrn_to_urn(self.hrn, None) + dict = {"uuid": self.uuid, - "hrn": self.hrn} + "urn": self.urn} str = xmlrpclib.dumps((dict,)) self.set_data(str) @@ -97,7 +120,10 @@ class GID(Certificate): dict = {} self.uuid = dict.get("uuid", None) - self.hrn = dict.get("hrn", None) + self.urn = dict.get("urn", None) + self.hrn = dict.get("hrn", None) + if self.urn: + self.hrn = urn_to_hrn(self.urn)[0] ## # Dump the credential to stdout. @@ -107,6 +133,7 @@ class GID(Certificate): def dump(self, indent=0, dump_parents=False): print " "*indent, " hrn:", self.get_hrn() + print " "*indent, " urn:", self.get_urn() print " "*indent, "uuid:", self.get_uuid() if self.parent and dump_parents: