X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fplc%2Fapi.py;fp=sfa%2Fplc%2Fapi.py;h=ddca04d7e0296fffc3e38bedc7c81eaeff783eb4;hb=b4337060a7f0d2373d7429f58d5a93d47fa22b66;hp=8a2567dd8222879752c145fc100cadf4e5527a39;hpb=430896c90f993b77c80b830ae7d1b349e4ba6d58;p=sfa.git diff --git a/sfa/plc/api.py b/sfa/plc/api.py index 8a2567dd..ddca04d7 100644 --- a/sfa/plc/api.py +++ b/sfa/plc/api.py @@ -10,6 +10,7 @@ import os import traceback import string import xmlrpclib +import sfa.util.xmlrpcprotocol as xmlrpcprotocol from sfa.trust.auth import Auth from sfa.util.config import * from sfa.util.faults import * @@ -124,11 +125,26 @@ class SfaAPI(BaseAPI): return shell def getCredential(self): + """ + Retrun a valid credential for this interface. + """ if self.interface in ['registry']: return self.getCredentialFromLocalRegistry() else: return self.getCredentialFromRegistry() - + + def getDelegatedCredential(self, creds): + """ + Attempt to find a credential delegated to us in + the specified list of creds. + """ + if creds and not isinstance(creds, list): + creds = [creds] + delegated_creds = filter_creds_by_caller(creds,self.hrn) + if not delegated_creds: + return None + return delegated_creds[0] + def getCredentialFromRegistry(self): """ Get our credential from a remote registry @@ -620,7 +636,7 @@ class ComponentAPI(BaseAPI): """ path = self.config.SFA_DATA_DIR config_dir = self.config.config_path - credfile = path + os.sep + 'node.cred' + cred_filename = path + os.sep + 'node.cred' try: credential = Credential(filename = cred_filename) return credential.save_to_string(save_parents=True)