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