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