1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.mina.proxy.session;
21
22 import java.net.InetSocketAddress;
23 import java.nio.charset.Charset;
24 import java.util.List;
25
26 import org.apache.mina.core.session.IoSession;
27 import org.apache.mina.proxy.ProxyConnector;
28 import org.apache.mina.proxy.ProxyLogicHandler;
29 import org.apache.mina.proxy.event.IoSessionEventQueue;
30 import org.apache.mina.proxy.filter.ProxyFilter;
31 import org.apache.mina.proxy.handlers.ProxyRequest;
32 import org.apache.mina.proxy.handlers.http.HttpAuthenticationMethods;
33 import org.apache.mina.proxy.handlers.http.HttpSmartProxyHandler;
34
35
36
37
38
39
40
41
42 public class ProxyIoSession {
43
44 public static final String PROXY_SESSION = ProxyConnector.class.getName() + ".ProxySession";
45
46 private static final String DEFAULT_ENCODING = "ISO-8859-1";
47
48
49
50
51
52
53 private List<HttpAuthenticationMethods> preferedOrder;
54
55
56
57
58 private ProxyRequest request;
59
60
61
62
63 private ProxyLogicHandler handler;
64
65
66
67
68 private ProxyFilter proxyFilter;
69
70
71
72
73 private IoSession session;
74
75
76
77
78 private ProxyConnector connector;
79
80
81
82
83 private InetSocketAddress proxyAddress = null;
84
85
86
87
88
89
90 private boolean reconnectionNeeded = false;
91
92
93
94
95 private String charsetName;
96
97
98
99
100 private IoSessionEventQueueQueue.html#IoSessionEventQueue">IoSessionEventQueue eventQueue = new IoSessionEventQueue(this);
101
102
103
104
105 private boolean authenticationFailed;
106
107
108
109
110
111
112
113 public ProxyIoSession(InetSocketAddress proxyAddress, ProxyRequest request) {
114 setProxyAddress(proxyAddress);
115 setRequest(request);
116 }
117
118
119
120
121 public IoSessionEventQueue getEventQueue() {
122 return eventQueue;
123 }
124
125
126
127
128
129
130
131 public List<HttpAuthenticationMethods> getPreferedOrder() {
132 return preferedOrder;
133 }
134
135
136
137
138
139
140 public void setPreferedOrder(List<HttpAuthenticationMethods> preferedOrder) {
141 this.preferedOrder = preferedOrder;
142 }
143
144
145
146
147 public ProxyLogicHandler getHandler() {
148 return handler;
149 }
150
151
152
153
154
155
156 public void setHandler(ProxyLogicHandler handler) {
157 this.handler = handler;
158 }
159
160
161
162
163 public ProxyFilter getProxyFilter() {
164 return proxyFilter;
165 }
166
167
168
169
170
171
172
173
174 public void setProxyFilter(ProxyFilter proxyFilter) {
175 this.proxyFilter = proxyFilter;
176 }
177
178
179
180
181 public ProxyRequest getRequest() {
182 return request;
183 }
184
185
186
187
188
189
190 private void setRequest(ProxyRequest request) {
191 if (request == null) {
192 throw new IllegalArgumentException("request cannot be null");
193 }
194
195 this.request = request;
196 }
197
198
199
200
201 public IoSession getSession() {
202 return session;
203 }
204
205
206
207
208
209
210
211
212 public void setSession(IoSession session) {
213 this.session = session;
214 }
215
216
217
218
219 public ProxyConnector getConnector() {
220 return connector;
221 }
222
223
224
225
226
227
228
229
230 public void setConnector(ProxyConnector connector) {
231 this.connector = connector;
232 }
233
234
235
236
237 public InetSocketAddress getProxyAddress() {
238 return proxyAddress;
239 }
240
241
242
243
244
245
246 private void setProxyAddress(InetSocketAddress proxyAddress) {
247 if (proxyAddress == null) {
248 throw new IllegalArgumentException("proxyAddress object cannot be null");
249 }
250
251 this.proxyAddress = proxyAddress;
252 }
253
254
255
256
257
258 public boolean isReconnectionNeeded() {
259 return reconnectionNeeded;
260 }
261
262
263
264
265
266
267
268
269
270
271
272 public void setReconnectionNeeded(boolean reconnectionNeeded) {
273 this.reconnectionNeeded = reconnectionNeeded;
274 }
275
276
277
278
279 public Charset getCharset() {
280 return Charset.forName(getCharsetName());
281 }
282
283
284
285
286 public String getCharsetName() {
287 if (charsetName == null) {
288 charsetName = DEFAULT_ENCODING;
289 }
290
291 return charsetName;
292 }
293
294
295
296
297
298
299 public void setCharsetName(String charsetName) {
300 this.charsetName = charsetName;
301 }
302
303
304
305
306 public boolean isAuthenticationFailed() {
307 return authenticationFailed;
308 }
309
310
311
312
313
314
315 public void setAuthenticationFailed(boolean authenticationFailed) {
316 this.authenticationFailed = authenticationFailed;
317 }
318 }