X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fmethods%2Fget_gid.py;h=b3d7c6f1e1f205435b21fd04c41e813afc0c4a2b;hb=3d7237fa0b5f2b4a60cb97c7fb3b6aecfd94558a;hp=bae5a747521bccfa8df023984515498a950b9cf4;hpb=96610e35383146f6fe38aeb9fcfe7126b2d38a9d;p=sfa.git diff --git a/sfa/methods/get_gid.py b/sfa/methods/get_gid.py index bae5a747..b3d7c6f1 100644 --- a/sfa/methods/get_gid.py +++ b/sfa/methods/get_gid.py @@ -6,13 +6,11 @@ # raise ConnectionKeyGIDMismatch(gid.get_subject()) from sfa.util.faults import * -from sfa.util.misc import * from sfa.util.method import Method from sfa.util.parameter import Parameter, Mixed from sfa.trust.auth import Auth from sfa.trust.gid import GID from sfa.trust.certificate import Certificate -from sfa.util.genitable import GeniTable class get_gid(Method): """ @@ -26,28 +24,31 @@ class get_gid(Method): accepts = [ Parameter(str, "Certificate string"), - Parameter(str, "Human readable name (hrn)"), - Parameter(str, "Request hash") + Parameter(str, "Human readable name (hrn)"), + Parameter(str, "Object type") ] - returns = [Parameter(dict, "Aggregate interface information")] + returns = Parameter(str, "GID string") - def call(self, cert, hrn, type, requestHash): + def call(self, cert, hrn, type): self.api.auth.verify_object_belongs_to_me(hrn) - certificate = Certificate(string=cert) - table = GeniTable() - records = table.find({'hrn': hrn, 'type': type}) + + # resolve the record + manager_base = 'sfa.managers' + mgr_type = self.api.config.SFA_REGISTRY_TYPE + manager_module = manager_base + ".registry_manager_%s" % mgr_type + manager = __import__(manager_module, fromlist=[manager_base]) + records = manager.resolve(self.api, hrn, type, origin_hrn=hrn) if not records: raise RecordNotFound(hrn) record = records[0] - gidStr = record['gid'] - gid = GID(string=gidStr) - + + # make sure client's certificate is the gid's pub key + gid = GID(string=record['gid']) + certificate = Certificate(string=cert) if not certificate.is_pubkey(gid.get_pubkey()): raise ConnectionKeyGIDMismatch(gid.get_subject()) + + return record['gid'] - # authenticate the gid - self.api.auth.authenticateGid(gidStr, [cert, hrn, type], requestHash) - - return gidStr