1 # * require certificate as an argument
3 # * get pubkey from gid
4 # * if certifacate matches pubkey from gid, return gid, else raise exception
5 # if not peer.is_pubkey(gid.get_pubkey()):
6 # raise ConnectionKeyGIDMismatch(gid.get_subject())
8 from sfa.util.faults import *
9 from sfa.util.method import Method
10 from sfa.util.parameter import Parameter, Mixed
11 from sfa.trust.auth import Auth
12 from sfa.trust.gid import GID
13 from sfa.trust.certificate import Certificate
14 from sfa.trust.credential import Credential
16 class get_gids(Method):
18 Get a list of record information (hrn, gid and type) for
21 @param cred credential string
22 @param cert certificate string
26 interfaces = ['registry']
29 Parameter(str, "Certificate string"),
30 Mixed(Parameter(str, "Human readable name (hrn or xrn)"),
31 Parameter(type([str]), "List of Human readable names (hrn or xrn)"))
34 returns = [Parameter(dict, "Dictionary of gids keyed on hrn")]
36 def call(self, cred, xrns):
37 # validate the credential
38 self.api.auth.check(cred, 'getgids')
39 user_cred = Credential(string=cred)
40 origin_hrn = user_cred.get_gid_caller().get_hrn()
43 manager_base = 'sfa.managers'
44 mgr_type = self.api.config.SFA_REGISTRY_TYPE
45 manager_module = manager_base + ".registry_manager_%s" % mgr_type
46 manager = __import__(manager_module, fromlist=[manager_base])
47 records = manager.resolve(self.api, xrns, None, origin_hrn=origin_hrn)
49 raise RecordNotFound(hrns)
52 allowed_fields = ['hrn', 'type', 'gid']
53 for record in records:
54 for key in record.keys():
55 if key not in allowed_fields: