Wiki source code of Programming__WebObjects-Web Applications-Development-SSL
Version 22.1 by Quinton Dolan on 2007/07/12 20:45
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
20.1 | 1 | == Detecting SSL == |
| |
18.1 | 2 | |
| 3 | Code for detecting whether SSL is active for the current request: | ||
| 4 | I'm told this won't work with IIS: | ||
| 5 | |||
| |
22.1 | 6 | {{code}} |
| |
18.1 | 7 | |
| |
22.1 | 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" ); | ||
| |
18.1 | 14 | if( header == null ) { |
| |
22.1 | 15 | log.debug( "no server_port header found, assuming insecure connection" ); |
| |
18.1 | 16 | } else { |
| |
22.1 | 17 | log.debug( "server_port header found, using it" ); |
| 18 | secureMode = header.equals( "443" ); | ||
| |
18.1 | 19 | } |
| |
22.1 | 20 | } else { |
| 21 | log.debug( "https header found, using it" ); | ||
| 22 | secureMode = header.equals( "on" ); | ||
| 23 | } | ||
| 24 | log.debug( "secure mode set to " + secureMode ); | ||
| |
18.1 | 25 | |
| |
22.1 | 26 | {{/code}} |
| |
20.1 | 27 | |
| 28 | Category:WebObjects |