refactored registry methods to use the registry manager module
[sfa.git] / sfa / methods / get_trusted_certs.py
1
2 ### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/methods/reset_slices.py $
3
4 from sfa.util.faults import *
5 from sfa.util.method import Method
6 from sfa.util.parameter import Parameter, Mixed
7 from sfa.trust.auth import Auth
8 from sfa.trust.credential import Credential
9
10 class get_trusted_certs(Method):
11     """
12     @param cred credential string specifying the rights of the caller
13     @return 1 is successful, faults otherwise  
14     """
15
16     interfaces = ['registry']
17     
18     accepts = [
19         Parameter(str, "Credential string")
20         ]
21
22     returns = Parameter(int, "1 if successful")
23     
24     def call(self, cred):
25         # authenticate the cred
26         self.api.auth.check(cred, 'gettrustedcerts')
27
28         trusted_cert_strings = [gid.save_to_string(save_parents=True) for \
29                                 gid in self.api.auth.trusted_cert_list] 
30         
31         return trusted_cert_strings