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.HttpHeader;
27 import org.eclipse.jetty.http.HttpHeaderValue;
28 import org.eclipse.jetty.util.ArrayTernaryTrie;
29 import org.eclipse.jetty.util.StringMap;
30 import org.eclipse.jetty.util.Trie;
31
32
33
34
35
36
37
38
39 public class MsieSslRule extends Rule
40 {
41 private static final int IEv5 = '5';
42 private static final int IEv6 = '6';
43 private static Trie<Boolean> __IE6_BadOS = new ArrayTernaryTrie<>();
44 {
45 __IE6_BadOS.put("NT 5.01", Boolean.TRUE);
46 __IE6_BadOS.put("NT 5.0",Boolean.TRUE);
47 __IE6_BadOS.put("NT 4.0",Boolean.TRUE);
48 __IE6_BadOS.put("98",Boolean.TRUE);
49 __IE6_BadOS.put("98; Win 9x 4.90",Boolean.TRUE);
50 __IE6_BadOS.put("95",Boolean.TRUE);
51 __IE6_BadOS.put("CE",Boolean.TRUE);
52 }
53
54 public MsieSslRule()
55 {
56 _handling = false;
57 _terminating = false;
58 }
59
60 @Override
61 public String matchAndApply(String target, HttpServletRequest request, HttpServletResponse response) throws IOException
62 {
63 if (request.isSecure())
64 {
65 String user_agent = request.getHeader(HttpHeader.USER_AGENT.asString());
66
67 if (user_agent!=null)
68 {
69 int msie=user_agent.indexOf("MSIE");
70 if (msie>0 && user_agent.length()-msie>5)
71 {
72
73 int ieVersion = user_agent.charAt(msie+5);
74
75 if ( ieVersion<=IEv5)
76 {
77 response.setHeader(HttpHeader.CONNECTION.asString(), HttpHeaderValue.CLOSE.asString());
78 return target;
79 }
80
81 if (ieVersion==IEv6)
82 {
83 int windows = user_agent.indexOf("Windows",msie+5);
84 if (windows>0)
85 {
86 int end=user_agent.indexOf(')',windows+8);
87 if(end<0 || __IE6_BadOS.get(user_agent,windows+8,end-windows-8)!=null)
88 {
89 response.setHeader(HttpHeader.CONNECTION.asString(), HttpHeaderValue.CLOSE.asString());
90 return target;
91 }
92 }
93 }
94 }
95 }
96 }
97 return null;
98 }
99 }