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
15 from sfa.util.genitable import GeniTable
17 class get_gids(Method):
19 Get a list of record information (hrn, gid and type) for
22 @param cred credential string
23 @param cert certificate string
27 interfaces = ['registry']
30 Parameter(str, "Certificate string"),
31 Mixed(Parameter(str, "Human readable name (hrn)"),
32 Parameter(type([str]), "List of Human readable names (hrn)"))
35 returns = [Parameter(dict, "Dictionary of gids keyed on hrn")]
37 def call(self, cred, hrns):
38 # validate the credential
39 self.api.auth.check(cred, 'getgids')
40 user_cred = Credential(string=cred)
41 origin_hrn = user_cred.get_gid_caller().get_hrn()
44 manager_base = 'sfa.managers'
45 mgr_type = self.api.config.SFA_REGISTRY_TYPE
46 manager_module = manager_base + ".registry_manager_%s" % mgr_type
47 manager = __import__(manager_module, fromlist=[manager_base])
48 records = manager.resolve(self.api, hrns, None, origin_hrn=origin_hrn)
50 raise RecordNotFound(hrns)
53 allowed_fields = ['hrn', 'type', 'gid']
54 for record in records:
55 for key in record.keys():
56 if key not in allowed_fields: