4 from sfa.trust.credential import *
5 from sfa.trust.rights import *
6 from sfa.util.faults import *
7 from sfa.util.method import Method
8 from sfa.util.parameter import Parameter, Mixed
9 from sfa.util.debug import log
11 class get_credential(Method):
13 Retrive a credential for an object
14 If cred == Nonee then the behavior reverts to get_self_credential
16 @param cred credential object specifying rights of the caller
17 @param type type of object (user | slice | sa | ma | node)
18 @param hrn human readable name of object
20 @return the string representation of a credential object
23 interfaces = ['registry']
26 Mixed(Parameter(str, "credential"),
27 Parameter(None, "No credential")),
28 Parameter(str, "Human readable name (hrn)")
31 returns = Parameter(str, "String representation of a credential object")
33 def call(self, cred, type, hrn):
35 self.api.auth.check(cred, 'getcredential')
36 self.api.auth.verify_object_belongs_to_me(hrn)
38 # send the call to the right manager
39 manager_base = 'sfa.managers'
40 mgr_type = self.api.config.SFA_REGISTRY_TYPE
41 manager_module = manager_base + ".registry_manager_%s" % mgr_type
42 manager = __import__(manager_module, fromlist=[manager_base])
43 return manager.get_credential(self.api, hrn, type)