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