3aff1e7502ff1120eab9323746fddf65e33f555f
[sfa.git] / sfa / methods / RedeemTicket.py
1 import xmlrpclib
2 from sfa.util.faults import *
3 from sfa.util.method import Method
4 from sfa.util.parameter import Parameter, Mixed
5
6 class RedeemTicket(Method):
7     """
8
9     @param cred credential string specifying the rights of the caller
10     @param ticket 
11     @return 1 is successful, faults otherwise  
12     """
13
14     interfaces = ['component']
15     
16     accepts = [
17         Parameter(str, "Ticket  string representation of SFA ticket"),
18         Mixed(Parameter(str, "Credential string"),
19               Parameter(type([str]), "List of credentials")),
20         ]
21
22     returns = [Parameter(int, "1 if successful")]
23     
24     def call(self, ticket, creds):
25         valid_creds = self.api.auth.checkCredentials(cred, 'redeemticket')
26         self.api.auth.check_ticket(ticket)
27
28         
29         # send the call to the right manager
30         manager = self.api.get_interface_manager()
31         manager.redeem_ticket(self.api, ticket) 
32         return 1