cvs server: Diffing . cvs server: Diffing SOAPpy Index: SOAPpy/Client.py =================================================================== RCS file: /cvsroot/pywebsvcs/SOAPpy/SOAPpy/Client.py,v retrieving revision 1.9 diff -r1.9 Client.py 96c96 < if proto not in ('http', 'https'): --- > if proto not in ('http', 'https', 'httpg'): 97a98,100 > if proto == 'httpg' and not config.GSIclient: > raise AttributeError, \ > "GSI client not supported by this Python installation" 133a137,144 > # If we are configured to use GSI, set it up > if hasattr(config, "channel_mode") and \ > hasattr(config, "delegation_mode"): > from pyGlobus.io import CHANNEL_MODE, DELEGATION_MODE, GSIHTTP > CHANNEL_MODE = config.channel_mode > DELEGATION_MODE = config.delegation_mode > # end GSI stuff > 144,145c155,158 < < if addr.proto == 'https': --- > > if addr.proto == 'httpg': > r = GSIHTTP(real_addr) > elif addr.proto == 'https': 204c217,218 < data = r.getfile().read() --- > data = r.getfile().read(int(headers.get("Content-length"))) > 258d271 < 259a273,279 > # GSI Additions > if hasattr(config, "channel_mode") and \ > hasattr(config, "delegation_mode"): > self.channel_mode = config.channel_mode > self.delegation_mode = config.delegation_mode > #end GSI Additions > Index: SOAPpy/Config.py =================================================================== RCS file: /cvsroot/pywebsvcs/SOAPpy/SOAPpy/Config.py,v retrieving revision 1.2 diff -r1.2 Config.py 39a40 > 42a44,46 > try: from pyGlobus import io > except: pass > 50c54 < __readonly = ('SSLserver', 'SSLclient') --- > __readonly = ('SSLserver', 'SSLclient', 'GSIserver', 'GSIclient') 76,77c80,81 < < --- > self.authMethod = None > 84a89,91 > try: io; d['GSIserver'] = 1 > except: d['GSIserver'] = 0 > 87a95,97 > try: io; d['GSIclient'] = 1 > except: d['GSIclient'] = 0 > Index: SOAPpy/Server.py =================================================================== RCS file: /cvsroot/pywebsvcs/SOAPpy/SOAPpy/Server.py,v retrieving revision 1.4 diff -r1.4 Server.py 138,139c138,142 < def registerObject(self, object, namespace = ''): < if namespace == '': namespace = self.namespace --- > def registerObject(self, object, namespace = '', path = ''): > if namespace == '' and path == '': namespace = self.namespace > if namespace == '' and path != '': > namespace = path.replace("/", ":") > if namespace[0] == ":": namespace = namespace[1:] 142c145,146 < def registerFunction(self, function, namespace = '', funcName = None): --- > def registerFunction(self, function, namespace = '', funcName = None, > path = ''): 144c148,151 < if namespace == '': namespace = self.namespace --- > if namespace == '' and path == '': namespace = self.namespace > if namespace == '' and path != '': > namespace = path.replace("/", ":") > if namespace[0] == ":": namespace = namespace[1:] 150,151c157,161 < def registerKWObject(self, object, namespace = ''): < if namespace == '': namespace = self.namespace --- > def registerKWObject(self, object, namespace = '', path = ''): > if namespace == '' and path == '': namespace = self.namespace > if namespace == '' and path != '': > namespace = path.replace("/", ":") > if namespace[0] == ":": namespace = namespace[1:] 157c167,172 < def registerKWFunction(self, function, namespace = '', funcName = None): --- > def registerKWFunction(self, function, namespace = '', funcName = None, > path = ''): > if namespace == '' and path == '': namespace = self.namespace > if namespace == '' and path != '': > namespace = path.replace("/", ":") > if namespace[0] == ":": namespace = namespace[1:] 186c201 < data = self.rfile.read(int(self.headers["content-length"])) --- > data = self.rfile.read(int(self.headers["Content-length"])) 240a256,260 > if len(self.path) == 1: > ns = None > else: > ns = self.path.replace("/", ":") > if ns[0] == ":": ns = ns[1:] 241a262,264 > > # authorization method > a = None 248c271,280 < else: # Now look at registered objects --- > > # look for the authorization method > if self.server.config.authMethod != None: > authmethod = self.server.config.authMethod > if self.server.funcmap.has_key(ns) and \ > self.server.funcmap[ns].has_key(authmethod): > a = self.server.funcmap[ns][authmethod] > print "Found function %s" % authmethod > else: > # Now look at registered objects 252a285,293 > > # Look for the authorization method > if self.server.config.authMethod != None: > authmethod = self.server.config.authMethod > if hasattr(f, authmethod): > a = getattr(f, authmethod) > print "Found object %s" % authmethod > > # then continue looking for the method 255a297 > 267a310,319 > fr = 1 > # Do an authorization check > if a != None: > c = SOAPContext(header, body, attrs, data, > self.connection, self.headers, > self.headers["soapaction"]) > if not apply(a, (), {"_SOAPContext" : c}): > raise faultType("%s:Server" % NS.ENV_T, > "Method %s failed." % nsmethod, > "Authorization failed.") 269d320 < 303d353 < 504d553 < 555a605,675 > > try: > from pyGlobus.io import GSITCPSocketServer, ThreadingGSITCPSocketServer > from pyGlobus import ioc > > Config.channel_mode = ioc.GLOBUS_IO_SECURE_CHANNEL_MODE_GSI_WRAP > Config.delegation_mode = ioc.GLOBUS_IO_SECURE_DELEGATION_MODE_FULL_PROXY > Config.tcpAttr = None > Config.authMethod = "_authorize" > > class GSISOAPServer(GSITCPSocketServer, SOAPServerBase): > def __init__(self, addr = ('localhost', 8000), > RequestHandler = SOAPRequestHandler, log = 1, > encoding = 'UTF-8', config = Config, namespace = None): > > # Test the encoding, raising an exception if it's not known > if encoding != None: > ''.encode(encoding) > > self.namespace = namespace > self.objmap = {} > self.funcmap = {} > self.encoding = encoding > self.config = config > self.log = log > > self.allow_reuse_address= 1 > > GSITCPSocketServer.__init__(self, addr, RequestHandler, > self.config.channel_mode, > self.config.delegation_mode, > tcpAttr = self.config.tcpAttr) > > def get_request(self): > sock, addr = GSITCPSocketServer.get_request(self) > > return sock, addr > > class ThreadingGSISOAPServer(ThreadingGSITCPSocketServer, SOAPServerBase): > > def __init__(self, addr = ('localhost', 8000), > RequestHandler = SOAPRequestHandler, log = 1, > encoding = 'UTF-8', config = Config, namespace = None): > > # Test the encoding, raising an exception if it's not known > if encoding != None: > ''.encode(encoding) > > self.namespace = namespace > self.objmap = {} > self.funcmap = {} > self.encoding = encoding > self.config = config > self.log = log > > self.allow_reuse_address= 1 > > ThreadingGSITCPSocketServer.__init__(self, addr, RequestHandler, > self.config.channel_mode, > self.config.delegation_mode, > tcpAttr = self.config.tcpAttr) > > def get_request(self): > sock, addr = ThreadingGSITCPSocketServer.get_request(self) > > return sock, addr > except: > print "Not defining GSI Classes" > import traceback > traceback.print_exc(file=sys.stdout) > pass cvs server: Diffing bid cvs server: Diffing contrib cvs server: Diffing docs cvs server: Diffing tests Index: tests/echoClient.py =================================================================== RCS file: /cvsroot/pywebsvcs/SOAPpy/tests/echoClient.py,v retrieving revision 1.4 diff -r1.4 echoClient.py 11c11,13 < Config.debug = 1 --- > #Config.debug = 1 > #Config.dumpSOAPIn = 1 > #Config.dumpSOAPOut = 1 17a20,23 > pathserver = SOAPProxy("https://localhost:9900/pathtest") > elif len(sys.argv) > 1 and sys.argv[1] == '-g': > server = SOAPProxy("httpg://localhost:9900") > pathserver = SOAPProxy("httpg://localhost:9900/pathtest") 19a26 > pathserver = SOAPProxy("http://localhost:9900/pathtest") 24c31,39 < print server.echo_ino("moo") --- > try: > print server.echo_ino("moo") > except Exception, e: > print "Caught exception: ", e > > try: > print pathserver.echo_ino("cow") > except Exception, e: > print "Caught exception: ", e 27c42,50 < print server.prop.echo2("moo") --- > try: > print server.prop.echo2("moo") > except Exception, e: > print "Caught exception: ", e > > try: > print pathserver.prop.echo2("cow") > except Exception, e: > print "Caught exception: ", e 30c53,60 < print server.echo_wkw(third = "three", first = "one", second = "two") --- > try: > print server.echo_wkw(third = "three", first = "one", second = "two") > except Exception, e: > print "Caught exception: ", e > try: > print pathserver.echo_wkw(third = "three", first = "one", second = "two") > except Exception, e: > print "Caught exception: ", e 33c63,70 < print server.echo_wc("moo") --- > try: > print server.echo_wc("moo") > except Exception, e: > print "Caught exception: ", e > try: > print pathserver.echo_wc("cow") > except Exception, e: > print "Caught exception: ", e 37c74,81 < print server._hd(hd).echo_wc("moo") --- > try: > print server._hd(hd).echo_wc("moo") > except Exception, e: > print "Caught exception: ", e > try: > print pathserver._hd(hd).echo_wc("cow") > except Exception, e: > print "Caught exception: ", e Index: tests/echoServer.py =================================================================== RCS file: /cvsroot/pywebsvcs/SOAPpy/tests/echoServer.py,v retrieving revision 1.4 diff -r1.4 echoServer.py 10,11c10,17 < Config.dumpSOAPIn = 1 < Config.dumpSOAPOut = 1 --- > # Uncomment to see outgoing HTTP headers and SOAP and incoming > #Config.dumpSOAPIn = 1 > #Config.dumpSOAPOut = 1 > #Config.debug = 1 > Config.authMethod = "_authorize" > > # Set this to 0 to test authorization > allowAll = 1 15a22,30 > def _authorize(*args, **kw): > global allowAll > if allowAll: > print "Authorize (function) called! (approved)" > return 1 > else: > print "Authorize (function) called! (denied)" > return 0 > 32a48,56 > def _authorize(self, *args, **kw): > global allowAll > if allowAll: > print "Authorize (method) called! (approved)" > return 1 > else: > print "Authorize (method) called! (denied)" > return 0 > 55c79,84 < print c.connection.getpeername() # The socket object, useful for --- > if not GSI: > print c.connection.getpeername() # The socket object, useful for > else: > print c.connection.get_remote_address() # The socket object, useful for > ctx = c.connection.get_security_context() > print ctx.inquire()[0].display() 68a98,100 > addr = ('localhost', 9900) > GSI = 0 > SSL = 0 69a102 > SSL = 1 74a108,111 > server = SOAPServer(addr, ssl_context = ssl_context) > elif len(sys.argv) > 1 and sys.argv[1] == '-g': > GSI = 1 > server = GSISOAPServer(addr) 76,78c113 < ssl_context = None < < server = SOAPServer(('localhost',9900), ssl_context = ssl_context) --- > server = SOAPServer(addr) 80a116,118 > server.registerFunction(echo, path = "/pathtest") > server.registerFunction(_authorize) > server.registerFunction(_authorize, path = "/pathtest") 84a123 > server.registerObject(o, path = "/pathtest") 87a127,128 > server.registerFunction(MethodSig(echo_wc, keywords = 0, context = 1), > path = "/pathtest") 90a132 > server.registerKWFunction(echo_wkw, path = "/pathtest") cvs server: Diffing tools cvs server: Diffing validate