Last modified by Aaron Rosenzweig on 2012/03/19 19:33

From version 20.1
edited by smmccraw
on 2007/07/08 09:46
Change comment: There is no comment for this version
To version 22.1
edited by Quinton Dolan
on 2007/07/12 20:45
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.smmccraw
1 +XWiki.qdolan
Content
... ... @@ -3,26 +3,26 @@
3 3  Code for detecting whether SSL is active for the current request:
4 4  I'm told this won't work with IIS:
5 5  
6 -{{panel}}
6 +{{code}}
7 7  
8 - // Is this page being accessed securely?
9 - boolean secureMode = false;
10 - String header = context.request().headerForKey("https");
8 +// Is this page being accessed securely?
9 +boolean secureMode = false;
10 +String header = context.request().headerForKey("https");
11 +if( header == null ) {
12 + log.debug( "no https header, looking for server_port" );
13 + header = context.request().headerForKey( "server_port" );
11 11   if( header == null ) {
12 - log.debug( "no https header, looking for server_port" );
13 - header = context.request().headerForKey( "server_port" );
14 - if( header == null ) {
15 - log.debug( "no server_port header found, assuming insecure connection" );
16 - } else {
17 - log.debug( "server_port header found, using it" );
18 - secureMode = header.equals( "443" );
19 - }
15 + log.debug( "no server_port header found, assuming insecure connection" );
20 20   } else {
21 - log.debug( "https header found, using it" );
22 - secureMode = header.equals( "on" );
17 + log.debug( "server_port header found, using it" );
18 + secureMode = header.equals( "443" );
23 23   }
24 - log.debug( "secure mode set to " + secureMode );
20 +} else {
21 + log.debug( "https header found, using it" );
22 + secureMode = header.equals( "on" );
23 +}
24 +log.debug( "secure mode set to " + secureMode );
25 25  
26 -{{/panel}}
26 +{{/code}}
27 27  
28 28  Category:WebObjects