2 from sfa.util.xrn import urn_to_hrn
3 from sfa.util.method import Method
4 from sfa.util.sfalogging import logger
6 from sfa.storage.parameter import Parameter, Mixed
7 from sfa.trust.credential import Credential
10 class CreateGid(Method):
12 Create a signed credential for the object with the registry. In addition to being stored in the
13 SFA database, the appropriate records will also be created in the
16 @param cred credential string
17 @param xrn urn or hrn of certificate owner
18 @param cert caller's certificate
20 @return gid string representation
23 interfaces = ['registry']
26 Mixed(Parameter(str, "Credential string"),
27 Parameter(type([str]), "List of credentials")),
28 Parameter(str, "URN or HRN of certificate owner"),
29 Parameter(str, "Certificate string"),
32 returns = Parameter(int, "String representation of gid object")
34 def call(self, creds, xrn, cert=None):
35 # TODO: is there a better right to check for or is 'update good enough?
36 valid_creds = self.api.auth.checkCredentials(creds, 'update')
39 hrn, type = urn_to_hrn(xrn)
40 self.api.auth.verify_object_permission(hrn)
43 origin_hrn = Credential(
44 string=valid_creds[0]).get_gid_caller().get_hrn()
45 logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s" %
46 (self.api.interface, origin_hrn, xrn, self.name))
48 return self.api.manager.CreateGid(self.api, xrn, cert)