From 73bb956984ac50cad8754dbc70dab2c4836b477d Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Fri, 20 Aug 2010 22:27:31 +0000 Subject: [PATCH] added filter_cred_by_caller() method --- sfa/trust/auth.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/sfa/trust/auth.py b/sfa/trust/auth.py index 28e86393..8570c786 100644 --- a/sfa/trust/auth.py +++ b/sfa/trust/auth.py @@ -15,9 +15,24 @@ from sfa.util.config import * from sfa.util.namespace import * from sfa.util.sfaticket import * from sfa.util.sfalogging import logger - import sys +def filter_creds_by_caller(self, creds, caller_hrn): + """ + Returns a list of creds who's gid caller matches the + specified caller hrn + """ + if not isinstance(creds, list): creds = [creds] + caller_creds = [] + for cred in creds: + try: + tmp_cred = Credential(string=cred) + if tmp_cred.get_gid_caller().get_hrn() == caller_hrn: + caller_creds.append(cred) + except: pass + return caller_creds + + class Auth: """ Credential based authentication @@ -303,3 +318,20 @@ class Auth: def get_authority(self, hrn): return get_authority(hrn) + + def filter_creds_by_caller(self, creds, caller_hrn): + """ + Returns a list of creds who's gid caller matches the + specified caller hrn + """ + if not isinstance(creds, list): + creds = [creds] + creds = [] + for cred in creds: + try: + tmp_cred = Credential(string=cred) + if tmp_cred.get_gid_caller().get_hrn() == caller_hrn: + creds.append(cred) + except: pass + return creds + -- 2.47.0