On Oct 2, 2005, at 6:54 AM, Christoph Zwerschke wrote:
I need a way to check whether the current servlet was accessed
through https or not. If not, I want to rewrite the url to https
and inform the user. How can I check this?
You can overwrite the respond method with something like this:
def respond(self, transaction):
request = self.request()
if request.environ()['SERVER_PORT'] != 443:
url = request.serverURLDir()
if request.hasField('path'):
url += request.field('path')
url = 'https://' + url
self.sendRedirectAndEnd(url)
else:
SitePage.respond(self, transaction)
Or, try to do it using Apache rewrite (there are probably a lot of
howtos in the Internet).
I have a subclass of my SitePage called SSLPage which
has in it:
def awake(self, transaction):
SitePage.awake(self, transaction)
if not (transaction.request().serverDictionary().has_key
('HTTPS') and \
transaction.request().serverDictionary()['HTTPS'] == 'on'):
# Not SSL
self.sendRedirectAndEnd('https://.../' + self.request
().servletURI())
#print "INSECURE!"
and that seems to work well.
--
Randall Randall <[EMAIL PROTECTED]>
"Who made up all the rules / We follow them like fools ;
Believe them to be true / Don't care to think them through."
- "They", Jem Griffiths
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Webware-discuss mailing list
Webware-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-discuss