From: Tony Mack Date: Mon, 17 Oct 2011 02:16:32 +0000 (-0400) Subject: filter_creds_by_caller() supports list args X-Git-Tag: sfa-1.1-1~97 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;ds=sidebyside;h=45783d105788cd2a834ffca14c5b788d40d32d3d;p=sfa.git filter_creds_by_caller() supports list args --- diff --git a/sfa/trust/credential.py b/sfa/trust/credential.py index 575911bc..a18019d8 100644 --- a/sfa/trust/credential.py +++ b/sfa/trust/credential.py @@ -209,17 +209,19 @@ class Signature(object): # not be changed else the signature is no longer valid. So, once # you have loaded an existing signed credential, do not call encode() or sign() on it. -def filter_creds_by_caller(creds, caller_hrn): +def filter_creds_by_caller(creds, caller_hrn_list): """ Returns a list of creds who's gid caller matches the specified caller hrn """ if not isinstance(creds, list): creds = [creds] + if not isinstance(caller_hrn_list, list): + caller_hrn_list = [caller_hrn_list] caller_creds = [] for cred in creds: try: tmp_cred = Credential(string=cred) - if tmp_cred.get_gid_caller().get_hrn() == caller_hrn: + if tmp_cred.get_gid_caller().get_hrn() in caller_hrn_list: caller_creds.append(cred) except: pass return caller_creds