2 from sfa.util.xrn import urn_to_hrn
3 from sfa.util.method import Method
4 from sfa.util.parameter import Parameter, Mixed
5 from sfa.trust.credential import Credential
7 class CreateGid(Method):
9 Create a signed credential for the s object with the registry. In addition to being stored in the
10 SFA database, the appropriate records will also be created in the
13 @param xrn urn or hrn of certificate owner
14 @param cert caller's certificate
15 @param cred credential string
17 @return gid string representation
20 interfaces = ['registry']
23 Mixed(Parameter(str, "Credential string"),
24 Parameter(type([str]), "List of credentials")),
25 Parameter(str, "URN or HRN of certificate owner"),
26 Parameter(str, "Certificate string"),
29 returns = Parameter(int, "String representation of gid object")
31 def call(self, creds, xrn, cert=None):
32 # TODO: is there a better right to check for or is 'update good enough?
33 valid_creds = self.api.auth.checkCredentials(creds, 'update')
36 hrn, type = urn_to_hrn(xrn)
37 self.api.auth.verify_object_permission(hrn)
40 origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
43 origin_hrn = Credential(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"%(self.api.interface, origin_hrn, xrn, self.name))
46 manager = self.api.get_interface_manager()
48 return manager.create_gid(self.api, xrn, cert)