X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Ftrust%2Fcredential_legacy.py;h=e66e69933aec778b39679dc374862db149bd3683;hb=57b6a99255d4a88be9c0f910f8524677e34ff4bc;hp=dc02941d08d35f1d20ed10fdf0fb1d031f834839;hpb=9c3a451f7d42b349462d2c80f81644c5a150b2f2;p=sfa.git diff --git a/sfa/trust/credential_legacy.py b/sfa/trust/credential_legacy.py index dc02941d..e66e6993 100644 --- a/sfa/trust/credential_legacy.py +++ b/sfa/trust/credential_legacy.py @@ -5,15 +5,11 @@ # certificate that stores a tuple of parameters. ## -### $Id: credential.py 17477 2010-03-25 16:49:34Z jkarlin $ -### $URL: svn+ssh://svn.planet-lab.org/svn/sfa/branches/geni-api/sfa/trust/credential.py $ - import xmlrpclib +from sfa.util.faults import MissingDelegateBit, ChildRightsNotSubsetOfParent from sfa.trust.certificate import Certificate -from sfa.trust.rights import * -from sfa.trust.gid import * -from sfa.util.faults import * +from sfa.trust.gid import GID ## # Credential is a tuple: @@ -110,16 +106,16 @@ class CredentialLegacy(Certificate): ## # set the privileges # - # @param privs either a comma-separated list of privileges of a RightList object + # @param privs either a comma-separated list of privileges of a Rights object def set_privileges(self, privs): if isinstance(privs, str): - self.privileges = RightList(string = privs) + self.privileges = Rights(string = privs) else: self.privileges = privs ## - # return the privileges as a RightList object + # return the privileges as a Rights object def get_privileges(self): if not self.privileges: @@ -176,7 +172,7 @@ class CredentialLegacy(Certificate): privStr = dict.get("privileges", None) if privStr: - self.privileges = RightList(string = privStr) + self.privileges = Rights(string = privStr) else: self.privileges = None @@ -223,24 +219,29 @@ class CredentialLegacy(Certificate): # # @param dump_parents If true, also dump the parent certificates - def dump(self, dump_parents=False): - print "CREDENTIAL", self.get_subject() + def dump(self, *args, **kwargs): + print self.dump_string(*args,**kwargs) + + def dump_string(self, dump_parents=False): + result="" + result += "CREDENTIAL %s\n" % self.get_subject() - print " privs:", self.get_privileges().save_to_string() + result += " privs: %s\n" % self.get_privileges().save_to_string() - print " gidCaller:" gidCaller = self.get_gid_caller() if gidCaller: + result += " gidCaller:\n" gidCaller.dump(8, dump_parents) - print " gidObject:" gidObject = self.get_gid_object() if gidObject: - gidObject.dump(8, dump_parents) + result += " gidObject:\n" + result += gidObject.dump_string(8, dump_parents) - print " delegate:", self.get_delegate() + result += " delegate: %s" % self.get_delegate() if self.parent and dump_parents: - print "PARENT", - self.parent.dump(dump_parents) + result += "PARENT\n" + result += self.parent.dump_string(dump_parents) + return result