本文整理汇总了Python中SimpleXMLRPCServer.SimpleXMLRPCRequestHandler类的典型用法代码示例。如果您正苦于以下问题:Python SimpleXMLRPCRequestHandler类的具体用法?Python SimpleXMLRPCRequestHandler怎么用?Python SimpleXMLRPCRequestHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleXMLRPCRequestHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_POST
def do_POST(self): # override
# Check for Basic HTTP authentication
if self.checkAuthorization():
SimpleXMLRPCRequestHandler.do_POST(self)
else:
self.report_401()
示例2: finish
def finish(self):
# XXX do we want to delete the peercert attribute?
# If so, use: del self.server.peercert
self.server.peercert = None
self.server.der_cert = None
self.server.pem_cert = None
SimpleXMLRPCRequestHandler.finish(self)
示例3: __init__
def __init__(self, request, client_address, server):
self._client_address = client_address
self._authenticated = False
self._server = server
self._user = None
SimpleXMLRPCRequestHandler.__init__(self, request,
client_address, server)
示例4: setup
def setup(self):
SimpleXMLRPCRequestHandler.setup(self)
# This first is humanreadable subjectAltName URI, etc
self.server.peercert = self.request.getpeercert()
self.server.der_cert = self.request.getpeercert(binary_form=True)
# This last is what a GID is created from
self.server.pem_cert = self.der_to_pem(self.server.der_cert)
示例5: send_response
def send_response(self, code, message=None):
'''
Overrides to capture end of request.
'''
# Clear current user
self.server.auth_handler.validate_token(None)
SimpleXMLRPCRequestHandler.send_response(self, code, message)
示例6: do_POST
def do_POST(self):
"""Handles the HTTPS POST request."""
SimpleXMLRPCRequestHandler.do_POST(self)
try:
# shut down the connection
self.connection.shutdown()
except:
pass
示例7: setup
def setup(self):
self.suppress_body = False
if self.server.enable_ssl:
self.connection = self.request
self.rfile = socket._fileobject(self.request, "rb", self.rbufsize)
self.wfile = socket._fileobject(self.request, "wb", self.wbufsize)
else:
SimpleXMLRPCRequestHandler.setup(self)
示例8: do_POST
def do_POST(self):
if self._server.auth_disabled:
return SimpleXMLRPCRequestHandler.do_POST(self)
hashfunc = self._server.hashfunc
nonce = None
if self.headers.has_key('authorization'):
attrs = _parse_digest_header(self.headers['authorization'])
if not attrs:
_LOGGER.error(
"Illegal digest authentication from {host}".format(
host=self._client_address))
self.send_response(400)
return
nonce = attrs['nonce']
store = _persistence.current_persister()
user = credentials.User.fetch_user(attrs['username'],
protocol='xmlrpc')
if not user:
_LOGGER.error("Authentication failed for {user}@{host}".format(
user=attrs['username'], host=self._client_address[0]))
self.send_response(400)
return
ha1 = user.password_hash
ha2 = hashfunc('POST' + ':' + self.rpc_paths[1]).hexdigest()
if 'qop' in attrs and attrs['qop'] in ('auth', 'auth-int'):
data = "{nonce}:{nc}:{cnonce}:{qop}:{ha2}".format(
nonce=attrs['nonce'],
nc=attrs['nc'],
cnonce=attrs['cnonce'],
qop=attrs['qop'],
ha2=ha2)
reqdigest = hashfunc(ha1 + ':' + data).hexdigest()
else:
kd = hashfunc(ha1 + ':' + nonce + ':' + ha2).hexdigest()
if reqdigest == attrs['response']:
self._authenticated = self._server.authorize_client(
nonce,
self._client_address,
attrs['username'], attrs['realm'],
nc=int(attrs['nc'], 16))
self._user = user
else:
self.send_response(400)
return
if not self._authenticated:
nonce = _digest_nonce(self._server.hashfunc,
self._client_address)
self.send_authentication(nonce)
return
return SimpleXMLRPCRequestHandler.do_POST(self)
示例9: setup
def setup(self):
SimpleXMLRPCRequestHandler.setup(self)
# This first is humanreadable subjectAltName URI, etc
self.server.peercert = self.request.getpeercert()
self.server.der_cert = self.request.getpeercert(binary_form=True)
# This last is what a GID is created from
self.server.pem_cert = self.der_to_pem(self.server.der_cert)
if self.server.logRequests:
self.log_message("Got call from client cert: %s", self.server.peercert)
示例10: do_POST
def do_POST(self):
try:
remote_token = self.headers["Bitbake-token"]
except:
remote_token = None
if remote_token != self.connection_token:
self.report_503()
else:
SimpleXMLRPCRequestHandler.do_POST(self)
示例11: do_POST
def do_POST(self):
#send unauthorized if not in list
if self.client_address[0] not in settings.authorized_clients:
self.send_response(401)
else:
#super(RequestHandler, self).do_POST(self)
#cannot use super() to make calls in python 2.7.5 with the
#SimpleXMLRPCRequestHandler, as its ultimate base class
#BaseRequestHandler in SocketServer.py is not a new-style
#class (it does not inherit from object). Resort to manual
#call to do_POST() instead.
SimpleXMLRPCRequestHandler.do_POST(self)
示例12: handle_one_request
def handle_one_request(self):
try:
with session() as s:
NAMESPACE.session = s
SimpleXMLRPCRequestHandler.handle_one_request(self)
finally:
NAMESPACE.session = None
NAMESPACE.machine = None
NAMESPACE.user = None
if DebileMasterInterface.shutdown_request:
check_shutdown()
示例13: do_POST
def do_POST(self):
# authentication
if self.authMap != None: # explicit None!
if self.headers.has_key('authorization') and self.headers['authorization'].startswith('Basic '):
authenticationString = base64.b64decode(self.headers['authorization'].split(' ')[1])
if authenticationString.find(':') != -1:
username, password = authenticationString.split(':', 1)
if self.authMap.has_key(username) and self.verifyPassword(username, password):
return SimpleXMLRPCRequestHandler.do_POST(self)
self.send_response(401)
self.end_headers()
return False
return SimpleXMLRPCRequestHandler.do_POST(self)
示例14: do_POST
def do_POST(self):
try:
remote_token = self.headers["Bitbake-token"]
except:
remote_token = None
if remote_token != self.server.connection_token and remote_token != "observer":
self.report_503()
else:
if remote_token == "observer":
self.server.readonly = True
else:
self.server.readonly = False
SimpleXMLRPCRequestHandler.do_POST(self)
示例15: do_POST
def do_POST(self):
try:
_, auth = self.headers["authorization"].split()
uid, md5 = base64.decodestring(auth).strip().split(':')
vhost = self.path.split('/')[1].lower()
self.data = self.getUser(uid, md5, vhost)
if self.data is None:
raise AuthFailed
# Call super.do_POST() to do the actual work
SimpleXMLRPCRequestHandler.do_POST(self)
except:
self.send_response(401)
self.end_headers()