summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
Diffstat (limited to 'example')
-rwxr-xr-xexample/idp2/idp.py11
-rwxr-xr-xexample/sp-wsgi/sp.py31
-rw-r--r--example/sp-wsgi/sp_conf.py.example1
3 files changed, 26 insertions, 17 deletions
diff --git a/example/idp2/idp.py b/example/idp2/idp.py
index c54b7d8f..5e924f49 100755
--- a/example/idp2/idp.py
+++ b/example/idp2/idp.py
@@ -8,8 +8,13 @@ import re
import time
from hashlib import sha1
-from cherrypy import wsgiserver
-from cherrypy.wsgiserver.ssl_builtin import BuiltinSSLAdapter
+
+try:
+ from cheroot.wsgi import Server as WSGIServer
+ from cheroot.ssl.builtin import BuiltinSSLAdapter
+except ImportError:
+ from cherrypy.wsgiserver import CherryPyWSGIServer as WSGIServer
+ from cherrypy.wsgiserver.ssl_builtin import BuiltinSSLAdapter
from six.moves.urllib.parse import parse_qs
from six.moves.http_cookies import SimpleCookie
@@ -1085,7 +1090,7 @@ if __name__ == '__main__':
pass
ds.DefaultSignature(sign_alg, digest_alg)
- SRV = wsgiserver.CherryPyWSGIServer((HOST, PORT), application)
+ SRV = WSGIServer((HOST, PORT), application)
_https = ""
if CONFIG.HTTPS:
diff --git a/example/sp-wsgi/sp.py b/example/sp-wsgi/sp.py
index 38a737ee..9de43abe 100755
--- a/example/sp-wsgi/sp.py
+++ b/example/sp-wsgi/sp.py
@@ -106,21 +106,21 @@ def handle_static(environ, start_response, path):
:return: wsgi response for the static file.
"""
try:
- text = open(path).read()
+ data = open(path, 'rb').read()
if path.endswith(".ico"):
- resp = Response(text, headers=[('Content-Type', "image/x-icon")])
+ resp = Response(data, headers=[('Content-Type', "image/x-icon")])
elif path.endswith(".html"):
- resp = Response(text, headers=[('Content-Type', 'text/html')])
+ resp = Response(data, headers=[('Content-Type', 'text/html')])
elif path.endswith(".txt"):
- resp = Response(text, headers=[('Content-Type', 'text/plain')])
+ resp = Response(data, headers=[('Content-Type', 'text/plain')])
elif path.endswith(".css"):
- resp = Response(text, headers=[('Content-Type', 'text/css')])
+ resp = Response(data, headers=[('Content-Type', 'text/css')])
elif path.endswith(".js"):
- resp = Response(text, headers=[('Content-Type', 'text/javascript')])
+ resp = Response(data, headers=[('Content-Type', 'text/javascript')])
elif path.endswith(".png"):
- resp = Response(text, headers=[('Content-Type', 'image/png')])
+ resp = Response(data, headers=[('Content-Type', 'image/png')])
else:
- resp = Response(text)
+ resp = Response(data)
except IOError:
resp = NotFound()
return resp(environ, start_response)
@@ -849,7 +849,12 @@ def application(environ, start_response):
if __name__ == '__main__':
- from cherrypy import wsgiserver
+ try:
+ from cheroot.wsgi import Server as WSGIServer
+ from cheroot.ssl import pyopenssl
+ except ImportError:
+ from cherrypy.wsgiserver import CherryPyWSGIServer as WSGIServer
+ from cherrypy.wsgiserver import ssl_pyopenssl as pyopenssl
_parser = argparse.ArgumentParser()
_parser.add_argument('-d', dest='debug', action='store_true',
@@ -923,14 +928,12 @@ if __name__ == '__main__':
pass
ds.DefaultSignature(sign_alg, digest_alg)
- SRV = wsgiserver.CherryPyWSGIServer((HOST, PORT), application)
+ SRV = WSGIServer((HOST, PORT), application)
_https = ""
if service_conf.HTTPS:
- from cherrypy.wsgiserver import ssl_pyopenssl
-
- SRV.ssl_adapter = ssl_pyopenssl.pyOpenSSLAdapter(SERVER_CERT,
- SERVER_KEY, CERT_CHAIN)
+ SRV.ssl_adapter = pyopenssl.pyOpenSSLAdapter(
+ SERVER_CERT, SERVER_KEY, CERT_CHAIN)
_https = " using SSL/TLS"
logger.info("Server starting")
print("SP listening on %s:%s%s" % (HOST, PORT, _https))
diff --git a/example/sp-wsgi/sp_conf.py.example b/example/sp-wsgi/sp_conf.py.example
index 46adaa9b..6dec8cf7 100644
--- a/example/sp-wsgi/sp_conf.py.example
+++ b/example/sp-wsgi/sp_conf.py.example
@@ -23,6 +23,7 @@ CONFIG = {
"description": "Example SP",
"service": {
"sp": {
+ "want_response_signed": False,
"authn_requests_signed": True,
"logout_requests_signed": True,
"endpoints": {