source: fedd/federation/abac_remote_service.py @ 4c8a0b7

axis_examplecompt_changesinfo-opsversion-2.00version-3.01version-3.02
Last change on this file since 4c8a0b7 was 19a3e06, checked in by Jay Jacobs <Jay.Jacobs@…>, 15 years ago

Initial abac client version

  • Property mode set to 100644
File size: 2.6 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
41        if getattr(fedd_abac_services.feddABACBindingSOAP, service_name, None):
42            self.locator = fedd_abac_services.feddABACServiceLocator
43            self.port_name = 'getfeddABACPortType'
44# feddABAC has no internal implementation but might in the future
45#       elif getattr(fedd_internal_services.feddInternalBindingSOAP,
46#               service_name, None):
47#           self.locator = fedd_internal_services.feddInternalServiceLocator
48#           self.port_name = 'getfeddABACInternalPortType'
49
50        if request_message: self.request_message = request_message
51        else:
52            request_message_name = "%sRequestMessage" % service_name
53            self.request_message = \
54                    getattr(fedd_abac_services, request_message_name, None) # or \
55#                   getattr(fedd_internal_services, request_message_name, None)
56            if not self.request_message:
57                raise service_error(service_error.internal,
58                        "Cannot find class for %s" % request_message_name)
59
60        if request_body_name: self.request_body_name = request_body_name
61        else: self.request_body_name = "%sRequestBody" % service_name
62
63        self.tracefile = tracefile
64        self.__call__ = self.call_service
65
Note: See TracBrowser for help on using the repository browser.