1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/JavaServlet/AuthApp.py Tue Sep 21 18:01:01 2004 +0000
1.3 @@ -0,0 +1,15 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +from WebStack.Adapters import JavaServlet
1.7 +from Auth import AuthResource, AuthAuthenticator
1.8 +from javax.servlet.http import HttpServlet
1.9 +
1.10 +class AuthApp(HttpServlet):
1.11 + def __init__(self):
1.12 + HttpServlet.__init__(self)
1.13 + self.dispatcher = JavaServlet.Dispatcher(AuthResource(), AuthAuthenticator())
1.14 +
1.15 + def service(self, request, response):
1.16 + self.dispatcher.service(request, response)
1.17 +
1.18 +# vim: tabstop=4 expandtab shiftwidth=4
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/examples/JavaServlet/LoginApp.py Tue Sep 21 18:01:01 2004 +0000
2.3 @@ -0,0 +1,29 @@
2.4 +#!/usr/bin/env python
2.5 +
2.6 +from WebStack.Adapters import JavaServlet
2.7 +from WebStack.Resources.Login import LoginResource, LoginAuthenticator
2.8 +from javax.servlet.http import HttpServlet
2.9 +
2.10 +# NOTE: Not sure if the resource should be maintained in a resource pool.
2.11 +
2.12 +resource = LoginResource(
2.13 + LoginAuthenticator(
2.14 + secret_key="horses",
2.15 + credentials=(
2.16 + ("badger", "abc"),
2.17 + ("vole", "xyz"),
2.18 + )
2.19 + ),
2.20 + use_redirect=0
2.21 +)
2.22 +
2.23 +class LoginApp(HttpServlet):
2.24 + def __init__(self):
2.25 + global resource
2.26 + HttpServlet.__init__(self)
2.27 + self.dispatcher = JavaServlet.Dispatcher(resource)
2.28 +
2.29 + def service(self, request, response):
2.30 + self.dispatcher.service(request, response)
2.31 +
2.32 +# vim: tabstop=4 expandtab shiftwidth=4
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/examples/JavaServlet/SimpleWithLoginApp.py Tue Sep 21 18:01:01 2004 +0000
3.3 @@ -0,0 +1,28 @@
3.4 +#!/usr/bin/env python
3.5 +
3.6 +from WebStack.Adapters import JavaServlet
3.7 +from Simple import SimpleResource
3.8 +from WebStack.Resources.LoginRedirect import LoginRedirectResource, LoginRedirectAuthenticator
3.9 +from javax.servlet.http import HttpServlet
3.10 +
3.11 +# NOTE: Not sure if the resource should be maintained in a resource pool.
3.12 +
3.13 +resource = LoginRedirectResource(
3.14 + login_url="http://localhost:8080/LoginApp/",
3.15 + app_url="http://localhost:8080",
3.16 + resource=SimpleResource(),
3.17 + authenticator=LoginRedirectAuthenticator(secret_key="horses"),
3.18 + anonymous_parameter_name="anonymous",
3.19 + logout_parameter_name="logout"
3.20 + )
3.21 +
3.22 +class SimpleWithLoginApp(HttpServlet):
3.23 + def __init__(self):
3.24 + global resource
3.25 + HttpServlet.__init__(self)
3.26 + self.dispatcher = JavaServlet.Dispatcher(resource)
3.27 +
3.28 + def service(self, request, response):
3.29 + self.dispatcher.service(request, response)
3.30 +
3.31 +# vim: tabstop=4 expandtab shiftwidth=4