#!/usr/local/bin/python import fedd_abac_services #import fedd_services import remote_service from fedd_services import CreateRequestMessage from M2Crypto import SSL from remote_service import service_caller from service_error import service_error from server import soap_handler # Turn off the matching of hostname to certificate ID SSL.Connection.clientPostConnectionCheck = None class abac_soap_handler(soap_handler): """ Encapsulate the handler code to unpack and pack SOAP requests and responses and call the given method. The code to decapsulate and encapsulate parameters encoded in SOAP is the same modulo a few parameters. This is a functor that calls a fedd service trhough a soap interface. The parameters are the typecode of the request parameters, the method to call (usually a bound instance of a method on a fedd service providing class), the constructor of a response packet and name of the body element of that packet. The handler takes a ParsedSoap object (the request) and returns an instance of the class created by constructor containing the response. Failures of the constructor or badly created constructors will result in None being returned. """ def get_class(self, class_name): return getattr(fedd_abac_services, class_name, None) or \ getattr(fedd_abac_internal_services, class_name, None) class abac_service_caller(service_caller): def __init__(self, service_name, request_message=None, request_body_name=None, tracefile=None): self.service_name = service_name self.locator = fedd_abac_services.feddABACServiceLocator self.port_name = 'getfeddABACPortType' if request_message: self.request_message = request_message else: request_message_name = "%sRequestMessage" % service_name self.request_message = \ getattr(fedd_abac_services, request_message_name, None) # or \ # getattr(fedd_internal_services, request_message_name, None) if not self.request_message: raise service_error(service_error.internal, "Cannot find class for %s" % request_message_name) if request_body_name: self.request_body_name = request_body_name else: self.request_body_name = "%sRequestBody" % service_name self.tracefile = tracefile self.__call__ = self.call_service