X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Ftrust%2Fcredential.py;h=34cc7e41ba083bbad8040f38bacca8df39900edd;hb=09647a9e4158f61d648cd4359ddcc65140152e15;hp=c4e6982d303624c8fefb41ad1d6a32025b336ed1;hpb=699667b3e734e954b0c93fbb2a6c29d82246d1dd;p=sfa.git diff --git a/sfa/trust/credential.py b/sfa/trust/credential.py index c4e6982d..34cc7e41 100644 --- a/sfa/trust/credential.py +++ b/sfa/trust/credential.py @@ -237,7 +237,7 @@ class Credential(object): # @param string If string!=None, load the credential from the string # @param filename If filename!=None, load the credential from the file # FIXME: create and subject are ignored! - def __init__(self, create=False, subject=None, string=None, filename=None): + def __init__(self, create=False, subject=None, string=None, filename=None, cred=None): self.gidCaller = None self.gidObject = None self.expiration = None @@ -250,6 +250,17 @@ class Credential(object): self.xml = None self.refid = None self.legacy = None + self.type = None + self.version = None + + if cred: + if isinstance(cred, StringTypes): + string = cred + elif isinstance(cred, dict): + string = cred['geni_value'] + self.type = cred['geni_type'] + self.version = cred['geni_version'] + # Check if this is a legacy credential, translate it if so if string or filename: @@ -364,8 +375,6 @@ class Credential(object): if not self.gidObject: self.decode() return self.gidObject - - ## # Expiration: an absolute UTC time of expiration (as either an int or string or datetime) @@ -404,8 +413,7 @@ class Credential(object): if isinstance(privs, str): self.privileges = Rights(string = privs) else: - self.privileges = privs - + self.privileges = privs ## # return the privileges as a Rights object