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
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
+