1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.mortbay.jetty.handler.rewrite;
16
17 import java.io.IOException;
18
19 import javax.servlet.http.HttpServletRequest;
20 import javax.servlet.http.HttpServletResponse;
21
22 import org.mortbay.jetty.HttpHeaderValues;
23 import org.mortbay.jetty.HttpHeaders;
24 import org.mortbay.util.StringMap;
25
26
27
28
29
30
31
32
33 public class MsieSslRule extends Rule
34 {
35 private static final int IEv5 = '5';
36 private static final int IEv6 = '6';
37 private static StringMap __IE6_BadOS = new StringMap();
38 {
39 __IE6_BadOS.put("NT 5.01", Boolean.TRUE);
40 __IE6_BadOS.put("NT 5.0",Boolean.TRUE);
41 __IE6_BadOS.put("NT 4.0",Boolean.TRUE);
42 __IE6_BadOS.put("98",Boolean.TRUE);
43 __IE6_BadOS.put("98; Win 9x 4.90",Boolean.TRUE);
44 __IE6_BadOS.put("95",Boolean.TRUE);
45 __IE6_BadOS.put("CE",Boolean.TRUE);
46 }
47
48 public MsieSslRule()
49 {
50 _handling = false;
51 _terminating = false;
52 }
53
54 public String matchAndApply(String target, HttpServletRequest request, HttpServletResponse response) throws IOException
55 {
56 if (request.isSecure())
57 {
58 String user_agent = request.getHeader(HttpHeaders.USER_AGENT);
59
60 if (user_agent!=null)
61 {
62 int msie=user_agent.indexOf("MSIE");
63 if (msie>0 && user_agent.length()-msie>5)
64 {
65
66 int ieVersion = user_agent.charAt(msie+5);
67
68 if ( ieVersion<=IEv5)
69 {
70 response.setHeader(HttpHeaders.CONNECTION, HttpHeaderValues.CLOSE);
71 return target;
72 }
73
74 if (ieVersion==IEv6)
75 {
76 int windows = user_agent.indexOf("Windows",msie+5);
77 if (windows>0)
78 {
79 int end=user_agent.indexOf(')',windows+8);
80 if(end<0 || __IE6_BadOS.getEntry(user_agent,windows+8,end-windows-8)!=null)
81 {
82 response.setHeader(HttpHeaders.CONNECTION, HttpHeaderValues.CLOSE);
83 return target;
84 }
85 }
86 }
87 }
88 }
89 }
90 return null;
91 }
92 }