X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fmethods%2Fcreate_gid.py;h=c92720459f8029b059aa048a192465c10ba0ea39;hb=11d02cbfd5e91784119bb9377fceb4fa6adae621;hp=1b6a94b1ddd37434b88285cefee9e8d7b408e4f9;hpb=f13173726f8382eef380f1e754f24dd2b126a77b;p=sfa.git diff --git a/sfa/methods/create_gid.py b/sfa/methods/create_gid.py index 1b6a94b1..c9272045 100644 --- a/sfa/methods/create_gid.py +++ b/sfa/methods/create_gid.py @@ -4,9 +4,11 @@ from sfa.trust.certificate import Keypair from sfa.util.faults import * +from sfa.util.namespace import * from sfa.util.method import Method from sfa.util.parameter import Parameter, Mixed -from sfa.util.auth import Auth +from sfa.trust.gid import create_uuid +from sfa.trust.auth import Auth class create_gid(Method): """ @@ -26,7 +28,7 @@ class create_gid(Method): accepts = [ Parameter(str, "Credential string"), - Parameter(str, "Human readable name (hrn)"), + Parameter(str, "Human readable name (hrn or urn)"), Mixed(Parameter(str, "Unique identifier for new GID (uuid)"), Parameter(None, "Unique identifier (uuid) not specified")), Parameter(str, "public-key string") @@ -34,7 +36,12 @@ class create_gid(Method): returns = Parameter(str, "String represeneation of a GID object") - def call(self, cred, hrn, uuid, pubkey_str): + def call(self, cred, xrn, uuid, pubkey_str): + + # convert urn to hrn + hrn, type = hrn_to_urn(xrn) + + # validate the credential self.api.auth.check(cred, "getcredential") self.api.auth.verify_object_belongs_to_me(hrn) self.api.auth.verify_object_permission(hrn) @@ -44,6 +51,6 @@ class create_gid(Method): pkey = Keypair() pkey.load_pubkey_from_string(pubkey_str) - gid = self.api.auth.hierarchy.create_gid(hrn, uuid, pkey) + gid = self.api.auth.hierarchy.create_gid(xrn, uuid, pkey) return gid.save_to_string(save_parents=True)