source: fedd/federation/abac_remote_service.py @ ee7f7e4

axis_examplecompt_changesinfo-ops
Last change on this file since ee7f7e4 was 181cf9c, checked in by Jay Jacobs <Jay.Jacobs@…>, 15 years ago

API tested. Use abac_test.sh for example usage.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1#!/usr/local/bin/python
2
3import fedd_abac_services
4#import fedd_services
5import remote_service
6from fedd_services import CreateRequestMessage
7from M2Crypto import SSL
8from remote_service import service_caller
9from service_error import service_error
10from server import soap_handler
11
12# Turn off the matching of hostname to certificate ID
13SSL.Connection.clientPostConnectionCheck = None
14
15class abac_soap_handler(soap_handler):
16    """
17    Encapsulate the handler code to unpack and pack SOAP requests and     
18    responses and call the given method.
19
20    The code to decapsulate and encapsulate parameters encoded in SOAP is the
21    same modulo a few parameters.  This is a functor that calls a fedd service
22    trhough a soap interface.  The parameters are the typecode of the request
23    parameters, the method to call (usually a bound instance of a method on a
24    fedd service providing class), the constructor of a response packet and
25    name of the body element of that packet.  The handler takes a ParsedSoap
26    object (the request) and returns an instance of the class created by
27    constructor containing the response.  Failures of the constructor or badly
28    created constructors will result in None being returned.
29    """
30
31    def get_class(self, class_name):
32        return getattr(fedd_abac_services, class_name, None) or \
33                getattr(fedd_abac_internal_services, class_name, None)
34
35
36class abac_service_caller(service_caller):
37    def __init__(self, service_name, request_message=None, 
38            request_body_name=None, tracefile=None):
39        self.service_name = service_name
40        self.locator = fedd_abac_services.feddABACServiceLocator
41        self.port_name = 'getfeddABACPortType'
42
43        if request_message: self.request_message = request_message
44        else:
45            request_message_name = "%sRequestMessage" % service_name
46            self.request_message = \
47                    getattr(fedd_abac_services, request_message_name, None) # or \
48#                   getattr(fedd_internal_services, request_message_name, None)
49            if not self.request_message:
50                raise service_error(service_error.internal,
51                        "Cannot find class for %s" % request_message_name)
52
53        if request_body_name: self.request_body_name = request_body_name
54        else: self.request_body_name = "%sRequestBody" % service_name
55
56        self.tracefile = tracefile
57        self.__call__ = self.call_service
58
Note: See TracBrowser for help on using the repository browser.