~ubuntu-branches/ubuntu/maverick/tomcat6/maverick-proposed

« back to all changes in this revision

Viewing changes to java/org/apache/catalina/valves/RemoteIpValve.java

  • Committer: Bazaar Package Importer
  • Author(s): Thierry Carrez
  • Date: 2010-05-21 13:51:15 UTC
  • mfrom: (2.2.12 sid)
  • Revision ID: james.westby@ubuntu.com-20100521135115-qfwnf24lzvi3644v
Tags: 6.0.26-2
* debian/tomcat6.{postinst,prerm}: Respect TOMCAT6_USER and TOMCAT6_GROUP
  as defined in /etc/default/tomcat6 when setting directory permissions and
  authbind configuration (Closes: #581018, LP: #557300)
* debian/tomcat6.postinst: Use group "tomcat6" instead of "adm" for
  permissions in /var/lib/tomcat6, so that group "adm" doesn't get write
  permissions over /var/lib/tomcat6/webapps (LP: #569118)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import java.util.regex.PatternSyntaxException;
27
27
 
28
28
import javax.servlet.ServletException;
 
29
import javax.servlet.ServletRequest;
29
30
 
30
31
import org.apache.tomcat.util.res.StringManager;
31
32
import org.apache.catalina.connector.Request;
126
127
 * <td><code>https</code></td>
127
128
 * </tr>
128
129
 * <tr>
 
130
 * <td>httpServerPort</td>
 
131
 * <td>Value returned by {@link ServletRequest#getServerPort()} when the <code>protocolHeader</code> indicates <code>http</code> protocol</td>
 
132
 * <td>N/A</td>
 
133
 * <td>integer</td>
 
134
 * <td>80</td>
 
135
 * </tr>
 
136
 * <tr>
 
137
 * <td>httpsServerPort</td>
 
138
 * <td>Value returned by {@link ServletRequest#getServerPort()} when the <code>protocolHeader</code> indicates <code>https</code> protocol</td>
 
139
 * <td>N/A</td>
 
140
 * <td>integer</td>
 
141
 * <td>443</td>
 
142
 * </tr>
129
143
 * </table>
130
144
 * </p>
131
145
 * <p>
149
163
 * </p>
150
164
 * <code><pre>
151
165
 * &lt;Valve 
152
 
 *   className="org.apache.catalina.connector.RemoteIpValve"
 
166
 *   className="org.apache.catalina.valves.RemoteIpValve"
153
167
 *   internalProxies="192\.168\.0\.10, 192\.168\.0\.11"
154
168
 *   remoteIPHeader="x-forwarded-for"
155
169
 *   remoteIPProxiesHeader="x-forwarded-by"
211
225
 * </p>
212
226
 * <code><pre>
213
227
 * &lt;Valve 
214
 
 *   className="org.apache.catalina.connector.RemoteIpValve"
 
228
 *   className="org.apache.catalina.valves.RemoteIpValve"
215
229
 *   internalProxies="192\.168\.0\.10, 192\.168\.0\.11"
216
230
 *   remoteIPHeader="x-forwarded-for"
217
231
 *   remoteIPProxiesHeader="x-forwarded-by"
253
267
 * </p>
254
268
 * <code><pre>
255
269
 * &lt;Valve 
256
 
 *   className="org.apache.catalina.connector.RemoteIpValve"
 
270
 *   className="org.apache.catalina.valves.RemoteIpValve"
257
271
 *   internalProxies="192\.168\.0\.10, 192\.168\.0\.11"
258
272
 *   remoteIPHeader="x-forwarded-for"
259
273
 *   remoteIPProxiesHeader="x-forwarded-by"
296
310
 * </p>
297
311
 * <code><pre>
298
312
 * &lt;Valve 
299
 
 *   className="org.apache.catalina.connector.RemoteIpValve"
 
313
 *   className="org.apache.catalina.valves.RemoteIpValve"
300
314
 *   internalProxies="192\.168\.0\.10, 192\.168\.0\.11"
301
315
 *   remoteIPHeader="x-forwarded-for"
302
316
 *   remoteIPProxiesHeader="x-forwarded-by"
342
356
    /**
343
357
     * The descriptive information related to this implementation.
344
358
     */
345
 
    private static final String info = "org.apache.catalina.connector.RemoteIpValve/1.0";
 
359
    private static final String info = "org.apache.catalina.valves.RemoteIpValve/1.0";
346
360
    
347
361
    /**
348
362
     * Logger
415
429
    }
416
430
    
417
431
    /**
 
432
     * @see #setHttpServerPort(int)
 
433
     */
 
434
    private int httpServerPort = 80;
 
435
    
 
436
    /**
418
437
     * @see #setHttpsServerPort(int)
419
438
     */
420
439
    private int httpsServerPort = 443;
456
475
        return httpsServerPort;
457
476
    }
458
477
    
 
478
    public int getHttpServerPort() {
 
479
        return httpServerPort;
 
480
    }
 
481
    
459
482
    /**
460
483
     * Return descriptive information about this Valve implementation.
461
484
     */
507
530
    public String getRemoteIpHeader() {
508
531
        return remoteIpHeader;
509
532
    }
510
 
    
 
533
 
511
534
    /**
512
535
     * @see #setTrustedProxies(String)
513
536
     * @return comma delimited list of trusted proxies
580
603
            
581
604
            if (protocolHeader != null) {
582
605
                String protocolHeaderValue = request.getHeader(protocolHeader);
583
 
                if (protocolHeaderValue != null && protocolHeaderHttpsValue.equalsIgnoreCase(protocolHeaderValue)) {
 
606
                if (protocolHeaderValue == null) {
 
607
                    // don't modify the secure,scheme and serverPort attributes
 
608
                    // of the request
 
609
                } else if (protocolHeaderHttpsValue.equalsIgnoreCase(protocolHeaderValue)) {
584
610
                    request.setSecure(true);
585
611
                    // use request.coyoteRequest.scheme instead of request.setScheme() because request.setScheme() is no-op in Tomcat 6.0
586
612
                    request.getCoyoteRequest().scheme().setString("https");
587
613
                    
588
614
                    request.setServerPort(httpsServerPort);
 
615
                } else {
 
616
                    request.setSecure(false);
 
617
                    // use request.coyoteRequest.scheme instead of request.setScheme() because request.setScheme() is no-op in Tomcat 6.0
 
618
                    request.getCoyoteRequest().scheme().setString("http");
 
619
                    
 
620
                    request.setServerPort(httpServerPort);
589
621
                }
590
622
            }
591
623
            
613
645
    
614
646
    /**
615
647
     * <p>
 
648
     * Server Port value if the {@link #protocolHeader} is not <code>null</code> and does not indicate HTTP
 
649
     * </p>
 
650
     * <p>
 
651
     * Default value : 80
 
652
     * </p>
 
653
     */
 
654
    public void setHttpServerPort(int httpServerPort) {
 
655
        this.httpServerPort = httpServerPort;
 
656
    }
 
657
    
 
658
    /**
 
659
     * <p>
616
660
     * Server Port value if the {@link #protocolHeader} indicates HTTPS
617
661
     * </p>
618
662
     * <p>