fixed error in assertion text
[p2pool.git] / SOAPpy / GSIServer.py
1 from __future__ import nested_scopes
2
3 """
4 GSIServer - Contributed by Ivan R. Judson <judson@mcs.anl.gov>
5
6
7 ################################################################################
8 #
9 # SOAPpy - Cayce Ullman       (cayce@actzero.com)
10 #          Brian Matthews     (blm@actzero.com)
11 #          Gregory Warnes     (Gregory.R.Warnes@Pfizer.com)
12 #          Christopher Blunck (blunck@gst.com)
13 #
14 ################################################################################
15 # Copyright (c) 2003, Pfizer
16 # Copyright (c) 2001, Cayce Ullman.
17 # Copyright (c) 2001, Brian Matthews.
18 #
19 # All rights reserved.
20 #
21 # Redistribution and use in source and binary forms, with or without
22 # modification, are permitted provided that the following conditions are met:
23 # Redistributions of source code must retain the above copyright notice, this
24 # list of conditions and the following disclaimer.
25 #
26 # Redistributions in binary form must reproduce the above copyright notice,
27 # this list of conditions and the following disclaimer in the documentation
28 # and/or other materials provided with the distribution.
29 #
30 # Neither the name of actzero, inc. nor the names of its contributors may
31 # be used to endorse or promote products derived from this software without
32 # specific prior written permission.
33 #
34 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
35 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
38 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
39 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
40 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
41 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
42 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
43 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 #
45 ################################################################################
46 """
47
48 ident = '$Id: GSIServer.py 1468 2008-05-24 01:55:33Z warnes $'
49 from version import __version__
50
51 #import xml.sax
52 import re
53 import socket
54 import sys
55 import SocketServer
56 from types import *
57 import BaseHTTPServer
58
59 # SOAPpy modules
60 from Parser      import parseSOAPRPC
61 from Config      import SOAPConfig
62 from Types       import faultType, voidType, simplify
63 from NS          import NS
64 from SOAPBuilder import buildSOAP
65 from Utilities   import debugHeader, debugFooter
66
67 try: from M2Crypto import SSL
68 except: pass
69
70 #####
71
72 from Server import *
73
74 from pyGlobus.io import GSITCPSocketServer, ThreadingGSITCPSocketServer
75 from pyGlobus import ioc
76
77 def GSIConfig():
78     config = SOAPConfig()
79     config.channel_mode = ioc.GLOBUS_IO_SECURE_CHANNEL_MODE_GSI_WRAP
80     config.delegation_mode = ioc.GLOBUS_IO_SECURE_DELEGATION_MODE_FULL_PROXY
81     config.tcpAttr = None
82     config.authMethod = "_authorize"
83     return config
84
85 Config = GSIConfig()
86
87 class GSISOAPServer(GSITCPSocketServer, SOAPServerBase):
88     def __init__(self, addr = ('localhost', 8000),
89                  RequestHandler = SOAPRequestHandler, log = 0,
90                  encoding = 'UTF-8', config = Config, namespace = None):
91
92         # Test the encoding, raising an exception if it's not known
93         if encoding != None:
94             ''.encode(encoding)
95
96         self.namespace          = namespace
97         self.objmap             = {}
98         self.funcmap            = {}
99         self.encoding           = encoding
100         self.config             = config
101         self.log                = log
102         
103         self.allow_reuse_address= 1
104         
105         GSITCPSocketServer.__init__(self, addr, RequestHandler,
106                                     self.config.channel_mode,
107                                     self.config.delegation_mode,
108                                     tcpAttr = self.config.tcpAttr)
109         
110     def get_request(self):
111         sock, addr = GSITCPSocketServer.get_request(self)
112
113         return sock, addr
114        
115 class ThreadingGSISOAPServer(ThreadingGSITCPSocketServer, SOAPServerBase):
116
117     def __init__(self, addr = ('localhost', 8000),
118                  RequestHandler = SOAPRequestHandler, log = 0,
119                  encoding = 'UTF-8', config = Config, namespace = None):
120         
121         # Test the encoding, raising an exception if it's not known
122         if encoding != None:
123             ''.encode(encoding)
124
125         self.namespace          = namespace
126         self.objmap             = {}
127         self.funcmap            = {}
128         self.encoding           = encoding
129         self.config             = config
130         self.log                = log
131         
132         self.allow_reuse_address= 1
133         
134         ThreadingGSITCPSocketServer.__init__(self, addr, RequestHandler,
135                                              self.config.channel_mode,
136                                              self.config.delegation_mode,
137                                              tcpAttr = self.config.tcpAttr)
138
139     def get_request(self):
140         sock, addr = ThreadingGSITCPSocketServer.get_request(self)
141
142         return sock, addr
143