refactoring.
@@ -1,65 +0,0 @@ | ||
1 | -package jp.sf.ssoproxy; | |
2 | - | |
3 | -public class SSOProxyConstraints { | |
4 | - public static final String PREFIX = "ssoproxy."; | |
5 | - | |
6 | - public static final String STORED_COOKIE_LIST = PREFIX | |
7 | - + "StoredCookieList_"; | |
8 | - | |
9 | - public static final String MIME_TYPE_PARAM = PREFIX + "MimeType"; | |
10 | - | |
11 | - public static final String RESPONSE_HEADERS_PARAM = PREFIX | |
12 | - + "ResponseHeaders"; | |
13 | - | |
14 | - public static final String RESPONSE_BODY_FILE_PARAM = PREFIX | |
15 | - + "ResponseBodyFile"; | |
16 | - | |
17 | - public static final String RESPONSE_BODY_INPUT_STREAM_PARAM = PREFIX | |
18 | - + "ResponseBodyInputStream"; | |
19 | - | |
20 | - public static final String LOGIN_BODY_FILE_PARAM = PREFIX + "LoginBodyFile"; | |
21 | - | |
22 | - public static final String LOGIN_BODY_INPUT_STREAM_PARAM = PREFIX | |
23 | - + "LoginBodyInputStream"; | |
24 | - | |
25 | - public static final String STATUS_CODE_PARAM = PREFIX + "StatusCode"; | |
26 | - | |
27 | - public static final String INPUT_ENCODING_PARAM = PREFIX + "InputEncoding"; | |
28 | - | |
29 | - public static final String CONTENT_TYPE_ENCODING_PARAM = PREFIX | |
30 | - + "ContentTypeEncoding"; | |
31 | - | |
32 | - public static final String URL_PARAM = PREFIX + "Url"; | |
33 | - | |
34 | - public static final String ORIGINAL_URL_PARAM = PREFIX + "OriginalUrl"; | |
35 | - | |
36 | - public static final String OUTPUT_ENCODING_PARAM = PREFIX | |
37 | - + "OutputEncoding"; | |
38 | - | |
39 | - public static final String PROXY_CONFIG_PARAM = PREFIX + "ProxyConfig"; | |
40 | - | |
41 | - public static final String POST_METHOD = "POST"; | |
42 | - | |
43 | - public static final String GET_METHOD = "GET"; | |
44 | - | |
45 | - public static final String REQUEST_PARAM_QUERY_SEPARATOR = "&"; | |
46 | - | |
47 | - public static final String REQUEST_PARAM_URL_SEPARATOR = "?"; | |
48 | - | |
49 | - public static final String REQUEST_PARAM_EQUAL = "="; | |
50 | - | |
51 | - public static final String CURRENT_REMOTE_USER = "CurrentRemoteUser"; | |
52 | - | |
53 | - public static final String ERROR_CODE = "ErrorCode"; | |
54 | - | |
55 | - public static final String ERROR_MESSAGE = "ErrorMessage"; | |
56 | - | |
57 | - public static final String SYSTEM_LOCALE_KEY = "sytemLocale"; | |
58 | - | |
59 | - public static final String ERROR_JSP_KEY = "errorPage"; | |
60 | - | |
61 | - public static final String DEFAULT_ERROR_JSP = "/error.jsp"; | |
62 | - | |
63 | - public static final String CURRENT_REMOTE_USER_KEY = "currentUserKey"; | |
64 | - | |
65 | -} |
@@ -14,7 +14,7 @@ | ||
14 | 14 | import javax.servlet.http.HttpServletResponse; |
15 | 15 | import javax.servlet.http.HttpSession; |
16 | 16 | |
17 | -import jp.sf.ssoproxy.SSOProxyConstraints; | |
17 | +import jp.sf.ssoproxy.SSOProxyConstants; | |
18 | 18 | import jp.sf.ssoproxy.access.AccessException; |
19 | 19 | import jp.sf.ssoproxy.access.AccessManager; |
20 | 20 | import jp.sf.ssoproxy.access.ResponseHeader; |
@@ -133,7 +133,7 @@ | ||
133 | 133 | |
134 | 134 | File responseBodyFile = File.createTempFile(RESPONSE_BODY_FILE_PREFIX, |
135 | 135 | TEMP_FILE_SUFFIX); |
136 | - resultMap.put(SSOProxyConstraints.RESPONSE_BODY_FILE_PARAM, | |
136 | + resultMap.put(SSOProxyConstants.RESPONSE_BODY_FILE_PARAM, | |
137 | 137 | responseBodyFile); |
138 | 138 | |
139 | 139 | DeferredFileOutputStream dfos = new DeferredFileOutputStream( |
@@ -140,7 +140,7 @@ | ||
140 | 140 | getDownloadThreshold(), responseBodyFile); |
141 | 141 | IOUtils.copy(inputStream, dfos); |
142 | 142 | if (!dfos.isThresholdExceeded()) { |
143 | - resultMap.put(SSOProxyConstraints.RESPONSE_BODY_INPUT_STREAM_PARAM, | |
143 | + resultMap.put(SSOProxyConstants.RESPONSE_BODY_INPUT_STREAM_PARAM, | |
144 | 144 | new ByteArrayInputStream(dfos.getData())); |
145 | 145 | return; |
146 | 146 | } |
@@ -147,7 +147,7 @@ | ||
147 | 147 | dfos.flush(); |
148 | 148 | IOUtils.closeQuietly(dfos); |
149 | 149 | |
150 | - resultMap.put(SSOProxyConstraints.RESPONSE_BODY_INPUT_STREAM_PARAM, | |
150 | + resultMap.put(SSOProxyConstants.RESPONSE_BODY_INPUT_STREAM_PARAM, | |
151 | 151 | new FileInputStream(responseBodyFile)); |
152 | 152 | } |
153 | 153 |
@@ -159,20 +159,20 @@ | ||
159 | 159 | |
160 | 160 | File responseBodyFile = File.createTempFile(RESPONSE_BODY_FILE_PREFIX, |
161 | 161 | TEMP_FILE_SUFFIX); |
162 | - resultMap.put(SSOProxyConstraints.RESPONSE_BODY_FILE_PARAM, | |
162 | + resultMap.put(SSOProxyConstants.RESPONSE_BODY_FILE_PARAM, | |
163 | 163 | responseBodyFile); |
164 | 164 | |
165 | 165 | File loginBodyFile = File.createTempFile(LOGIN_BODY_FILE_PREFIX, |
166 | 166 | TEMP_FILE_SUFFIX); |
167 | - resultMap.put(SSOProxyConstraints.LOGIN_BODY_FILE_PARAM, loginBodyFile); | |
167 | + resultMap.put(SSOProxyConstants.LOGIN_BODY_FILE_PARAM, loginBodyFile); | |
168 | 168 | |
169 | 169 | DeferredFileOutputStream dfos = new DeferredFileOutputStream( |
170 | 170 | getDownloadThreshold(), responseBodyFile); |
171 | 171 | IOUtils.copy(inputStream, dfos); |
172 | 172 | if (!dfos.isThresholdExceeded()) { |
173 | - resultMap.put(SSOProxyConstraints.RESPONSE_BODY_INPUT_STREAM_PARAM, | |
173 | + resultMap.put(SSOProxyConstants.RESPONSE_BODY_INPUT_STREAM_PARAM, | |
174 | 174 | new ByteArrayInputStream(dfos.getData())); |
175 | - resultMap.put(SSOProxyConstraints.LOGIN_BODY_INPUT_STREAM_PARAM, | |
175 | + resultMap.put(SSOProxyConstants.LOGIN_BODY_INPUT_STREAM_PARAM, | |
176 | 176 | new ByteArrayInputStream(dfos.getData())); |
177 | 177 | return; |
178 | 178 | } |
@@ -179,9 +179,9 @@ | ||
179 | 179 | dfos.flush(); |
180 | 180 | IOUtils.closeQuietly(dfos); |
181 | 181 | |
182 | - resultMap.put(SSOProxyConstraints.RESPONSE_BODY_INPUT_STREAM_PARAM, | |
182 | + resultMap.put(SSOProxyConstants.RESPONSE_BODY_INPUT_STREAM_PARAM, | |
183 | 183 | new FileInputStream(responseBodyFile)); |
184 | - resultMap.put(SSOProxyConstraints.LOGIN_BODY_INPUT_STREAM_PARAM, | |
184 | + resultMap.put(SSOProxyConstants.LOGIN_BODY_INPUT_STREAM_PARAM, | |
185 | 185 | new FileInputStream(loginBodyFile)); |
186 | 186 | } |
187 | 187 |
@@ -189,13 +189,13 @@ | ||
189 | 189 | int result) throws IOException { |
190 | 190 | Map<String, Object> resultMap = new HashMap<String, Object>(); |
191 | 191 | |
192 | - resultMap.put(SSOProxyConstraints.STATUS_CODE_PARAM, result); | |
192 | + resultMap.put(SSOProxyConstants.STATUS_CODE_PARAM, result); | |
193 | 193 | Header[] responseHeaders = httpMethod.getResponseHeaders(); |
194 | 194 | List<ResponseHeader> responseHeaderList = new ArrayList<ResponseHeader>(); |
195 | 195 | for (int i = 0; i < responseHeaders.length; i++) { |
196 | 196 | responseHeaderList.add(new ResponseHeader(responseHeaders[i])); |
197 | 197 | } |
198 | - resultMap.put(SSOProxyConstraints.RESPONSE_HEADERS_PARAM, | |
198 | + resultMap.put(SSOProxyConstants.RESPONSE_HEADERS_PARAM, | |
199 | 199 | responseHeaderList); |
200 | 200 | // TODO response footer? |
201 | 201 | // content type |
@@ -221,14 +221,14 @@ | ||
221 | 221 | if (mimeType == null) { |
222 | 222 | mimeType = DEFAULT_CONTENT_TYPE; |
223 | 223 | } |
224 | - resultMap.put(SSOProxyConstraints.MIME_TYPE_PARAM, mimeType); | |
225 | - resultMap.put(SSOProxyConstraints.URL_PARAM, url); | |
226 | - resultMap.put(SSOProxyConstraints.CONTENT_TYPE_ENCODING_PARAM, | |
224 | + resultMap.put(SSOProxyConstants.MIME_TYPE_PARAM, mimeType); | |
225 | + resultMap.put(SSOProxyConstants.URL_PARAM, url); | |
226 | + resultMap.put(SSOProxyConstants.CONTENT_TYPE_ENCODING_PARAM, | |
227 | 227 | inputEncoding); |
228 | 228 | if (inputEncoding == null) { |
229 | 229 | inputEncoding = httpMethod.getParams().getContentCharset(); |
230 | 230 | } |
231 | - resultMap.put(SSOProxyConstraints.INPUT_ENCODING_PARAM, inputEncoding); | |
231 | + resultMap.put(SSOProxyConstants.INPUT_ENCODING_PARAM, inputEncoding); | |
232 | 232 | |
233 | 233 | return resultMap; |
234 | 234 | } |
@@ -242,7 +242,7 @@ | ||
242 | 242 | |
243 | 243 | HttpClient httpclient = getHttpClient(hostConfig); |
244 | 244 | |
245 | - String cookieMapName = SSOProxyConstraints.STORED_COOKIE_LIST | |
245 | + String cookieMapName = SSOProxyConstants.STORED_COOKIE_LIST | |
246 | 246 | + hostConfig.getName(); |
247 | 247 | |
248 | 248 | HttpSession httpSession = request.getSession(); |
@@ -249,10 +249,10 @@ | ||
249 | 249 | setCookiesToServer(httpSession, cookieMapName, httpclient); |
250 | 250 | |
251 | 251 | HttpMethod httpMethod = null; |
252 | - if (SSOProxyConstraints.GET_METHOD.equals(request.getMethod())) { | |
252 | + if (SSOProxyConstants.GET_METHOD.equals(request.getMethod())) { | |
253 | 253 | httpMethod = UrlBuilderUtil.buildGetMethod(url, request |
254 | 254 | .getParameterMap(), encoding); |
255 | - } else if (SSOProxyConstraints.POST_METHOD.equals(request.getMethod())) { | |
255 | + } else if (SSOProxyConstants.POST_METHOD.equals(request.getMethod())) { | |
256 | 256 | httpMethod = UrlBuilderUtil.buildPostMethod(url, request |
257 | 257 | .getParameterMap(), encoding); |
258 | 258 | } else { |
@@ -292,7 +292,7 @@ | ||
292 | 292 | |
293 | 293 | HttpClient httpclient = getHttpClient(hostConfig); |
294 | 294 | |
295 | - String cookieListName = SSOProxyConstraints.STORED_COOKIE_LIST | |
295 | + String cookieListName = SSOProxyConstants.STORED_COOKIE_LIST | |
296 | 296 | + hostConfig.getName(); |
297 | 297 | |
298 | 298 | HttpSession httpSession = request.getSession(); |
@@ -338,7 +338,7 @@ | ||
338 | 338 | |
339 | 339 | HttpClient httpclient = getHttpClient(hostConfig); |
340 | 340 | |
341 | - String cookieMapName = SSOProxyConstraints.STORED_COOKIE_LIST | |
341 | + String cookieMapName = SSOProxyConstants.STORED_COOKIE_LIST | |
342 | 342 | + hostConfig.getName(); |
343 | 343 | |
344 | 344 | HttpSession httpSession = request.getSession(); |
@@ -386,9 +386,9 @@ | ||
386 | 386 | throws AccessException { |
387 | 387 | // content type |
388 | 388 | String mimeType = (String) resultMap |
389 | - .get(SSOProxyConstraints.MIME_TYPE_PARAM); | |
389 | + .get(SSOProxyConstants.MIME_TYPE_PARAM); | |
390 | 390 | String contentTypeEncoding = (String) resultMap |
391 | - .get(SSOProxyConstraints.CONTENT_TYPE_ENCODING_PARAM); | |
391 | + .get(SSOProxyConstants.CONTENT_TYPE_ENCODING_PARAM); | |
392 | 392 | StringBuilder contentType = new StringBuilder(mimeType); |
393 | 393 | if (contentTypeEncoding != null) { |
394 | 394 | contentType.append("; charset=").append(contentTypeEncoding); |
@@ -397,7 +397,7 @@ | ||
397 | 397 | |
398 | 398 | // headers |
399 | 399 | List<ResponseHeader> responseHeaderList = (List<ResponseHeader>) resultMap |
400 | - .get(SSOProxyConstraints.RESPONSE_HEADERS_PARAM); | |
400 | + .get(SSOProxyConstants.RESPONSE_HEADERS_PARAM); | |
401 | 401 | for (ResponseHeader responseHeader : responseHeaderList) { |
402 | 402 | if (SET_COOKIE_HEADER.equals(responseHeader.getName()) |
403 | 403 | || SET_COOKIE2_HEADER.equals(responseHeader.getName())) { |
@@ -421,18 +421,18 @@ | ||
421 | 421 | } |
422 | 422 | |
423 | 423 | Map<String, Object> props = new HashMap<String, Object>(); |
424 | - props.put(SSOProxyConstraints.URL_PARAM, resultMap | |
425 | - .get(SSOProxyConstraints.URL_PARAM)); | |
426 | - props.put(SSOProxyConstraints.INPUT_ENCODING_PARAM, resultMap | |
427 | - .get(SSOProxyConstraints.INPUT_ENCODING_PARAM)); | |
428 | - props.put(SSOProxyConstraints.OUTPUT_ENCODING_PARAM, resultMap | |
429 | - .get(SSOProxyConstraints.OUTPUT_ENCODING_PARAM)); | |
430 | - props.put(SSOProxyConstraints.PROXY_CONFIG_PARAM, proxyConfig); | |
424 | + props.put(SSOProxyConstants.URL_PARAM, resultMap | |
425 | + .get(SSOProxyConstants.URL_PARAM)); | |
426 | + props.put(SSOProxyConstants.INPUT_ENCODING_PARAM, resultMap | |
427 | + .get(SSOProxyConstants.INPUT_ENCODING_PARAM)); | |
428 | + props.put(SSOProxyConstants.OUTPUT_ENCODING_PARAM, resultMap | |
429 | + .get(SSOProxyConstants.OUTPUT_ENCODING_PARAM)); | |
430 | + props.put(SSOProxyConstants.PROXY_CONFIG_PARAM, proxyConfig); | |
431 | 431 | // props.put(SSOProxyConstraints.REQUEST_PARAM, request); |
432 | 432 | // props.put(SSOProxyConstraints.RESPONSE_PARAM, response); |
433 | 433 | |
434 | 434 | InputStream inputStream = (InputStream) resultMap |
435 | - .get(SSOProxyConstraints.RESPONSE_BODY_INPUT_STREAM_PARAM); | |
435 | + .get(SSOProxyConstants.RESPONSE_BODY_INPUT_STREAM_PARAM); | |
436 | 436 | try { |
437 | 437 | if (inputStream != null) { |
438 | 438 | forwarder.forward(props, inputStream, response |
@@ -454,13 +454,13 @@ | ||
454 | 454 | String redirectLocation; |
455 | 455 | redirectLocation = getResponseHeaderValue( |
456 | 456 | (List<ResponseHeader>) resultMap |
457 | - .get(SSOProxyConstraints.RESPONSE_HEADERS_PARAM), | |
457 | + .get(SSOProxyConstants.RESPONSE_HEADERS_PARAM), | |
458 | 458 | LOCATION_HEADER); |
459 | 459 | if (redirectLocation != null) { |
460 | 460 | // TODO headers |
461 | 461 | try { |
462 | 462 | response.setStatus((Integer) resultMap |
463 | - .get(SSOProxyConstraints.STATUS_CODE_PARAM)); | |
463 | + .get(SSOProxyConstants.STATUS_CODE_PARAM)); | |
464 | 464 | response.sendRedirect(proxyConfig |
465 | 465 | .buildProxyUrl(redirectLocation)); |
466 | 466 | } catch (IOException e) { |
@@ -490,25 +490,25 @@ | ||
490 | 490 | } |
491 | 491 | |
492 | 492 | InputStream responseBodyInputStream = (InputStream) resultMap |
493 | - .get(SSOProxyConstraints.RESPONSE_BODY_INPUT_STREAM_PARAM); | |
493 | + .get(SSOProxyConstants.RESPONSE_BODY_INPUT_STREAM_PARAM); | |
494 | 494 | if (responseBodyInputStream != null) { |
495 | 495 | IOUtils.closeQuietly(responseBodyInputStream); |
496 | 496 | } |
497 | 497 | |
498 | 498 | File responseBodyFile = (File) resultMap |
499 | - .get(SSOProxyConstraints.RESPONSE_BODY_FILE_PARAM); | |
499 | + .get(SSOProxyConstants.RESPONSE_BODY_FILE_PARAM); | |
500 | 500 | if (responseBodyFile != null) { |
501 | 501 | FileUtils.deleteQuietly(responseBodyFile); |
502 | 502 | } |
503 | 503 | |
504 | 504 | InputStream loginBodyInputStream = (InputStream) resultMap |
505 | - .get(SSOProxyConstraints.LOGIN_BODY_INPUT_STREAM_PARAM); | |
505 | + .get(SSOProxyConstants.LOGIN_BODY_INPUT_STREAM_PARAM); | |
506 | 506 | if (loginBodyInputStream != null) { |
507 | 507 | IOUtils.closeQuietly(loginBodyInputStream); |
508 | 508 | } |
509 | 509 | |
510 | 510 | File loginBodyFile = (File) resultMap |
511 | - .get(SSOProxyConstraints.LOGIN_BODY_FILE_PARAM); | |
511 | + .get(SSOProxyConstants.LOGIN_BODY_FILE_PARAM); | |
512 | 512 | if (loginBodyFile != null) { |
513 | 513 | FileUtils.deleteQuietly(loginBodyFile); |
514 | 514 | } |
@@ -0,0 +1,76 @@ | ||
1 | +package jp.sf.ssoproxy; | |
2 | + | |
3 | +import jp.sf.ssoproxy.cookie.StandardBrowserSpec; | |
4 | + | |
5 | +import org.apache.commons.httpclient.cookie.CookiePolicy; | |
6 | + | |
7 | +public class SSOProxyConstants { | |
8 | + | |
9 | + public static final String PREFIX = "ssoproxy."; | |
10 | + | |
11 | + public static final String STANDARD_BROWSER = "browser"; | |
12 | + | |
13 | + public static final String STORED_COOKIE_LIST = PREFIX | |
14 | + + "StoredCookieList_"; | |
15 | + | |
16 | + public static final String MIME_TYPE_PARAM = PREFIX + "MimeType"; | |
17 | + | |
18 | + public static final String RESPONSE_HEADERS_PARAM = PREFIX | |
19 | + + "ResponseHeaders"; | |
20 | + | |
21 | + public static final String RESPONSE_BODY_FILE_PARAM = PREFIX | |
22 | + + "ResponseBodyFile"; | |
23 | + | |
24 | + public static final String RESPONSE_BODY_INPUT_STREAM_PARAM = PREFIX | |
25 | + + "ResponseBodyInputStream"; | |
26 | + | |
27 | + public static final String LOGIN_BODY_FILE_PARAM = PREFIX + "LoginBodyFile"; | |
28 | + | |
29 | + public static final String LOGIN_BODY_INPUT_STREAM_PARAM = PREFIX | |
30 | + + "LoginBodyInputStream"; | |
31 | + | |
32 | + public static final String STATUS_CODE_PARAM = PREFIX + "StatusCode"; | |
33 | + | |
34 | + public static final String INPUT_ENCODING_PARAM = PREFIX + "InputEncoding"; | |
35 | + | |
36 | + public static final String CONTENT_TYPE_ENCODING_PARAM = PREFIX | |
37 | + + "ContentTypeEncoding"; | |
38 | + | |
39 | + public static final String URL_PARAM = PREFIX + "Url"; | |
40 | + | |
41 | + public static final String ORIGINAL_URL_PARAM = PREFIX + "OriginalUrl"; | |
42 | + | |
43 | + public static final String OUTPUT_ENCODING_PARAM = PREFIX | |
44 | + + "OutputEncoding"; | |
45 | + | |
46 | + public static final String PROXY_CONFIG_PARAM = PREFIX + "ProxyConfig"; | |
47 | + | |
48 | + public static final String POST_METHOD = "POST"; | |
49 | + | |
50 | + public static final String GET_METHOD = "GET"; | |
51 | + | |
52 | + public static final String REQUEST_PARAM_QUERY_SEPARATOR = "&"; | |
53 | + | |
54 | + public static final String REQUEST_PARAM_URL_SEPARATOR = "?"; | |
55 | + | |
56 | + public static final String REQUEST_PARAM_EQUAL = "="; | |
57 | + | |
58 | + public static final String CURRENT_REMOTE_USER = "CurrentRemoteUser"; | |
59 | + | |
60 | + public static final String ERROR_CODE = "ErrorCode"; | |
61 | + | |
62 | + public static final String ERROR_MESSAGE = "ErrorMessage"; | |
63 | + | |
64 | + public static final String SYSTEM_LOCALE_KEY = "sytemLocale"; | |
65 | + | |
66 | + public static final String ERROR_JSP_KEY = "errorPage"; | |
67 | + | |
68 | + public static final String DEFAULT_ERROR_JSP = "/error.jsp"; | |
69 | + | |
70 | + public static final String CURRENT_REMOTE_USER_KEY = "currentUserKey"; | |
71 | + | |
72 | + static { | |
73 | + CookiePolicy.registerCookieSpec(STANDARD_BROWSER, | |
74 | + StandardBrowserSpec.class); | |
75 | + } | |
76 | +} |
@@ -1,5 +1,6 @@ | ||
1 | 1 | package jp.sf.ssoproxy.servlet; |
2 | 2 | |
3 | +import java.io.File; | |
3 | 4 | import java.io.IOException; |
4 | 5 | import java.io.InputStream; |
5 | 6 | import java.io.UnsupportedEncodingException; |
@@ -11,7 +12,7 @@ | ||
11 | 12 | import javax.servlet.http.HttpServletRequest; |
12 | 13 | import javax.servlet.http.HttpServletResponse; |
13 | 14 | |
14 | -import jp.sf.ssoproxy.SSOProxyConstraints; | |
15 | +import jp.sf.ssoproxy.SSOProxyConstants; | |
15 | 16 | import jp.sf.ssoproxy.access.AccessManager; |
16 | 17 | import jp.sf.ssoproxy.config.AuthConfig; |
17 | 18 | import jp.sf.ssoproxy.config.HostConfig; |
@@ -18,6 +19,8 @@ | ||
18 | 19 | import jp.sf.ssoproxy.config.ProxyConfig; |
19 | 20 | import jp.sf.ssoproxy.util.ErrorHandlingUtil; |
20 | 21 | |
22 | +import org.apache.commons.fileupload.disk.DiskFileItemFactory; | |
23 | +import org.apache.commons.fileupload.servlet.ServletFileUpload; | |
21 | 24 | import org.seasar.framework.container.S2Container; |
22 | 25 | import org.seasar.framework.container.factory.SingletonS2ContainerFactory; |
23 | 26 |
@@ -31,17 +34,19 @@ | ||
31 | 34 | |
32 | 35 | private Locale systemLocale; |
33 | 36 | |
37 | + private ServletFileUpload servletFileUpload; | |
38 | + | |
34 | 39 | @Override |
35 | 40 | public void init() throws ServletException { |
36 | 41 | // set an error page |
37 | 42 | errorPage = getServletConfig().getInitParameter( |
38 | - SSOProxyConstraints.ERROR_JSP_KEY); | |
43 | + SSOProxyConstants.ERROR_JSP_KEY); | |
39 | 44 | if (errorPage == null) { |
40 | - errorPage = SSOProxyConstraints.DEFAULT_ERROR_JSP; | |
45 | + errorPage = SSOProxyConstants.DEFAULT_ERROR_JSP; | |
41 | 46 | } |
42 | 47 | // set a system locale |
43 | 48 | String value = getServletConfig().getInitParameter( |
44 | - SSOProxyConstraints.SYSTEM_LOCALE_KEY); | |
49 | + SSOProxyConstants.SYSTEM_LOCALE_KEY); | |
45 | 50 | if (value != null) { |
46 | 51 | try { |
47 | 52 | String[] values = value.split("_"); |
@@ -60,6 +65,25 @@ | ||
60 | 65 | } else { |
61 | 66 | systemLocale = Locale.ENGLISH; |
62 | 67 | } |
68 | + | |
69 | + // Create a factory for disk-based file items | |
70 | + DiskFileItemFactory factory = new DiskFileItemFactory(); | |
71 | + | |
72 | + // Set factory constraints | |
73 | + String sizeThreshold = getServletConfig().getInitParameter( | |
74 | + "uploadSizeThreshold"); | |
75 | + if (sizeThreshold != null) { | |
76 | + factory.setSizeThreshold(Integer.parseInt(sizeThreshold)); | |
77 | + } | |
78 | + String repositoryPath = getServletConfig().getInitParameter( | |
79 | + "uploadRepositoryPath"); | |
80 | + if (repositoryPath != null) { | |
81 | + factory.setRepository(new File(repositoryPath)); | |
82 | + } | |
83 | + | |
84 | + // Create a new file upload handler | |
85 | + servletFileUpload = new ServletFileUpload(factory); | |
86 | + | |
63 | 87 | } |
64 | 88 | |
65 | 89 | @Override |
@@ -130,38 +154,46 @@ | ||
130 | 154 | return; |
131 | 155 | } |
132 | 156 | |
157 | + // Check that we have a file upload request | |
158 | + boolean isMultipart = ServletFileUpload.isMultipartContent(request); | |
159 | + | |
133 | 160 | Map<String, Object> resultMap = null; |
134 | 161 | try { |
135 | 162 | String url = hostConfig.buildUrl(pathInfo.substring(actualPathPos)); |
136 | - // TODO the url has request parameters or not when checking it in a following method... | |
137 | - AuthConfig authConfig = hostConfig.getAuthConfig(request | |
138 | - .getMethod(), url, request.getParameterMap()); | |
163 | + if (isMultipart) { | |
139 | 164 | |
140 | - // check a login page | |
141 | - if (authConfig != null) { | |
142 | - // Check a login page | |
143 | - resultMap = accessManager.sendLoginPageRequest(request, | |
144 | - hostConfig, authConfig); | |
145 | - int statusCode = ((Integer) resultMap | |
146 | - .get(SSOProxyConstraints.STATUS_CODE_PARAM)).intValue(); | |
147 | - if (statusCode == 200 | |
148 | - && authConfig | |
149 | - .checkLoginPage((InputStream) resultMap | |
150 | - .get(SSOProxyConstraints.LOGIN_BODY_INPUT_STREAM_PARAM))) { | |
151 | - // release result | |
152 | - accessManager.release(resultMap); | |
153 | - // Send auth info | |
154 | - resultMap = accessManager.sendAuthPageRequest(request, | |
165 | + } else { | |
166 | + // TODO the url has request parameters or not when checking it in a following method... | |
167 | + AuthConfig authConfig = hostConfig.getAuthConfig(request | |
168 | + .getMethod(), url, request.getParameterMap()); | |
169 | + | |
170 | + // check a login page | |
171 | + if (authConfig != null) { | |
172 | + // Check a login page | |
173 | + resultMap = accessManager.sendLoginPageRequest(request, | |
155 | 174 | hostConfig, authConfig); |
175 | + int statusCode = ((Integer) resultMap | |
176 | + .get(SSOProxyConstants.STATUS_CODE_PARAM)) | |
177 | + .intValue(); | |
178 | + if (statusCode == 200 | |
179 | + && authConfig | |
180 | + .checkLoginPage((InputStream) resultMap | |
181 | + .get(SSOProxyConstants.LOGIN_BODY_INPUT_STREAM_PARAM))) { | |
182 | + // release result | |
183 | + accessManager.release(resultMap); | |
184 | + // Send auth info | |
185 | + resultMap = accessManager.sendAuthPageRequest(request, | |
186 | + hostConfig, authConfig); | |
187 | + } | |
188 | + } else { | |
189 | + // get a content from a back-end server | |
190 | + resultMap = accessManager.sendRequest(request, hostConfig, | |
191 | + url, hostConfig.getEncoding()); | |
156 | 192 | } |
157 | - } else { | |
158 | - // get a content from a back-end server | |
159 | - resultMap = accessManager.sendRequest(request, hostConfig, url, | |
160 | - hostConfig.getEncoding()); | |
161 | 193 | } |
162 | 194 | |
163 | 195 | int statusCode = ((Integer) resultMap |
164 | - .get(SSOProxyConstraints.STATUS_CODE_PARAM)).intValue(); | |
196 | + .get(SSOProxyConstants.STATUS_CODE_PARAM)).intValue(); | |
165 | 197 | // redirect |
166 | 198 | if (isRedirectStatusCode(statusCode)) { |
167 | 199 | accessManager.redirectResponse(request, response, resultMap, |
@@ -178,7 +210,7 @@ | ||
178 | 210 | accessManager.sendResponse(request, response, resultMap, |
179 | 211 | proxyConfig, hostConfigName, hostConfig |
180 | 212 | .getForwarderName((String) resultMap |
181 | - .get(SSOProxyConstraints.MIME_TYPE_PARAM))); | |
213 | + .get(SSOProxyConstants.MIME_TYPE_PARAM))); | |
182 | 214 | // flush |
183 | 215 | response.flushBuffer(); |
184 | 216 | } catch (Exception e) { |
@@ -3,6 +3,7 @@ | ||
3 | 3 | import java.util.HashMap; |
4 | 4 | import java.util.Map; |
5 | 5 | |
6 | +import jp.sf.ssoproxy.SSOProxyConstants; | |
6 | 7 | import jp.sf.ssoproxy.config.AuthConfig; |
7 | 8 | import jp.sf.ssoproxy.config.ConfigException; |
8 | 9 | import jp.sf.ssoproxy.config.HostConfig; |
@@ -49,7 +50,7 @@ | ||
49 | 50 | encoding = UTF_8; |
50 | 51 | accessManagerName = DEFAULT_ACCESS_MANAGER; |
51 | 52 | forwarderMap = new HashMap<String, String>(); |
52 | - cookiePolicy = CookiePolicy.BROWSER_COMPATIBILITY; | |
53 | + cookiePolicy = SSOProxyConstants.STANDARD_BROWSER; | |
53 | 54 | singleCookieHeader = false; |
54 | 55 | connectionTimeout = 30000; |
55 | 56 | } |
@@ -9,7 +9,7 @@ | ||
9 | 9 | |
10 | 10 | import javax.servlet.http.HttpServletRequest; |
11 | 11 | |
12 | -import jp.sf.ssoproxy.SSOProxyConstraints; | |
12 | +import jp.sf.ssoproxy.SSOProxyConstants; | |
13 | 13 | import jp.sf.ssoproxy.config.AuthConfig; |
14 | 14 | import jp.sf.ssoproxy.config.ConfigException; |
15 | 15 | import jp.sf.ssoproxy.util.UrlBuilderUtil; |
@@ -94,15 +94,15 @@ | ||
94 | 94 | */ |
95 | 95 | public HttpMethod buildLoginHttpMethod(HttpServletRequest request) |
96 | 96 | throws ConfigException { |
97 | - if (SSOProxyConstraints.POST_METHOD.equals(loginPageMethod)) { | |
97 | + if (SSOProxyConstants.POST_METHOD.equals(loginPageMethod)) { | |
98 | 98 | return UrlBuilderUtil.buildPostMethod(loginPageUrl, |
99 | - getParameterMap(request, SSOProxyConstraints.GET_METHOD, | |
99 | + getParameterMap(request, SSOProxyConstants.GET_METHOD, | |
100 | 100 | loginPageDataList), |
101 | - getParameterMap(request, SSOProxyConstraints.POST_METHOD, | |
101 | + getParameterMap(request, SSOProxyConstants.POST_METHOD, | |
102 | 102 | loginPageDataList), loginPageEncoding); |
103 | - } else if (SSOProxyConstraints.GET_METHOD.equals(loginPageMethod)) { | |
103 | + } else if (SSOProxyConstants.GET_METHOD.equals(loginPageMethod)) { | |
104 | 104 | return UrlBuilderUtil.buildGetMethod(loginPageUrl, |
105 | - getParameterMap(request, SSOProxyConstraints.GET_METHOD, | |
105 | + getParameterMap(request, SSOProxyConstants.GET_METHOD, | |
106 | 106 | loginPageDataList), loginPageEncoding); |
107 | 107 | } |
108 | 108 | // error |
@@ -114,14 +114,14 @@ | ||
114 | 114 | */ |
115 | 115 | public HttpMethod buildAuthHttpMethod(HttpServletRequest request) |
116 | 116 | throws ConfigException { |
117 | - if (SSOProxyConstraints.POST_METHOD.equals(authPageMethod)) { | |
117 | + if (SSOProxyConstants.POST_METHOD.equals(authPageMethod)) { | |
118 | 118 | return UrlBuilderUtil.buildPostMethod(authPageUrl, getParameterMap( |
119 | - request, SSOProxyConstraints.GET_METHOD, authPageDataList), | |
120 | - getParameterMap(request, SSOProxyConstraints.POST_METHOD, | |
119 | + request, SSOProxyConstants.GET_METHOD, authPageDataList), | |
120 | + getParameterMap(request, SSOProxyConstants.POST_METHOD, | |
121 | 121 | authPageDataList), authPageEncoding); |
122 | - } else if (SSOProxyConstraints.GET_METHOD.equals(authPageMethod)) { | |
122 | + } else if (SSOProxyConstants.GET_METHOD.equals(authPageMethod)) { | |
123 | 123 | return UrlBuilderUtil.buildGetMethod(authPageUrl, getParameterMap( |
124 | - request, SSOProxyConstraints.GET_METHOD, authPageDataList), | |
124 | + request, SSOProxyConstants.GET_METHOD, authPageDataList), | |
125 | 125 | authPageEncoding); |
126 | 126 | } |
127 | 127 | // error |
@@ -4,7 +4,7 @@ | ||
4 | 4 | |
5 | 5 | import javax.servlet.http.HttpServletRequest; |
6 | 6 | |
7 | -import jp.sf.ssoproxy.SSOProxyConstraints; | |
7 | +import jp.sf.ssoproxy.SSOProxyConstants; | |
8 | 8 | import jp.sf.ssoproxy.config.ConfigException; |
9 | 9 | import jp.sf.ssoproxy.util.JetspeedUtil; |
10 | 10 |
@@ -27,7 +27,7 @@ | ||
27 | 27 | if (usernameKey.equals(value)) { |
28 | 28 | // from user attribute |
29 | 29 | String remoteUser = (String) request.getSession().getAttribute( |
30 | - SSOProxyConstraints.CURRENT_REMOTE_USER); | |
30 | + SSOProxyConstants.CURRENT_REMOTE_USER); | |
31 | 31 | if (remoteUser == null) { |
32 | 32 | // error |
33 | 33 | throw new ConfigException("000009"); |
@@ -45,7 +45,7 @@ | ||
45 | 45 | } else if (passwordKey.equals(value)) { |
46 | 46 | // from user attribute |
47 | 47 | String remoteUser = (String) request.getSession().getAttribute( |
48 | - SSOProxyConstraints.CURRENT_REMOTE_USER); | |
48 | + SSOProxyConstants.CURRENT_REMOTE_USER); | |
49 | 49 | if (remoteUser == null) { |
50 | 50 | // error |
51 | 51 | throw new ConfigException("000011"); |
@@ -12,7 +12,7 @@ | ||
12 | 12 | import javax.servlet.http.HttpServletRequest; |
13 | 13 | import javax.servlet.http.HttpServletResponse; |
14 | 14 | |
15 | -import jp.sf.ssoproxy.SSOProxyConstraints; | |
15 | +import jp.sf.ssoproxy.SSOProxyConstants; | |
16 | 16 | import jp.sf.ssoproxy.util.ErrorHandlingUtil; |
17 | 17 | |
18 | 18 | public abstract class AbstractAuthFilter implements Filter { |
@@ -26,20 +26,20 @@ | ||
26 | 26 | public void init(FilterConfig config) throws ServletException { |
27 | 27 | // set an current user key |
28 | 28 | currentUserKey = config |
29 | - .getInitParameter(SSOProxyConstraints.CURRENT_REMOTE_USER_KEY); | |
29 | + .getInitParameter(SSOProxyConstants.CURRENT_REMOTE_USER_KEY); | |
30 | 30 | if (currentUserKey == null) { |
31 | - currentUserKey = SSOProxyConstraints.CURRENT_REMOTE_USER; | |
31 | + currentUserKey = SSOProxyConstants.CURRENT_REMOTE_USER; | |
32 | 32 | } |
33 | 33 | |
34 | 34 | // set an error page |
35 | - errorPage = config.getInitParameter(SSOProxyConstraints.ERROR_JSP_KEY); | |
35 | + errorPage = config.getInitParameter(SSOProxyConstants.ERROR_JSP_KEY); | |
36 | 36 | if (errorPage == null) { |
37 | - errorPage = SSOProxyConstraints.DEFAULT_ERROR_JSP; | |
37 | + errorPage = SSOProxyConstants.DEFAULT_ERROR_JSP; | |
38 | 38 | } |
39 | 39 | |
40 | 40 | // set a system locale |
41 | 41 | String value = config |
42 | - .getInitParameter(SSOProxyConstraints.SYSTEM_LOCALE_KEY); | |
42 | + .getInitParameter(SSOProxyConstants.SYSTEM_LOCALE_KEY); | |
43 | 43 | if (value != null) { |
44 | 44 | try { |
45 | 45 | String[] values = value.split("_"); |
@@ -8,7 +8,7 @@ | ||
8 | 8 | import javax.portlet.RenderRequest; |
9 | 9 | import javax.portlet.RenderResponse; |
10 | 10 | |
11 | -import jp.sf.ssoproxy.SSOProxyConstraints; | |
11 | +import jp.sf.ssoproxy.SSOProxyConstants; | |
12 | 12 | |
13 | 13 | public class SSOEnablerPortlet extends GenericPortlet { |
14 | 14 |
@@ -17,7 +17,7 @@ | ||
17 | 17 | String remoteUser = request.getRemoteUser(); |
18 | 18 | if (remoteUser != null) { |
19 | 19 | request.getPortletSession().setAttribute( |
20 | - SSOProxyConstraints.CURRENT_REMOTE_USER, remoteUser, | |
20 | + SSOProxyConstants.CURRENT_REMOTE_USER, remoteUser, | |
21 | 21 | PortletSession.APPLICATION_SCOPE); |
22 | 22 | } |
23 | 23 | } |
@@ -0,0 +1,104 @@ | ||
1 | +package jp.sf.ssoproxy.cookie; | |
2 | + | |
3 | +import org.apache.commons.httpclient.Cookie; | |
4 | +import org.apache.commons.httpclient.cookie.CookieSpecBase; | |
5 | +import org.apache.commons.httpclient.cookie.MalformedCookieException; | |
6 | + | |
7 | +public class StandardBrowserSpec extends CookieSpecBase { | |
8 | + public StandardBrowserSpec() { | |
9 | + super(); | |
10 | + } | |
11 | + | |
12 | + /** | |
13 | + * Performs most common {@link Cookie} validation | |
14 | + * | |
15 | + * @param host the host from which the {@link Cookie} was received | |
16 | + * @param port the port from which the {@link Cookie} was received | |
17 | + * @param path the path from which the {@link Cookie} was received | |
18 | + * @param secure <tt>true</tt> when the {@link Cookie} was received using a | |
19 | + * secure connection | |
20 | + * @param cookie The cookie to validate. | |
21 | + * @throws MalformedCookieException if an exception occurs during | |
22 | + * validation | |
23 | + */ | |
24 | + | |
25 | + public void validate(String host, int port, String path, boolean secure, | |
26 | + final Cookie cookie) throws MalformedCookieException { | |
27 | + | |
28 | + LOG.trace("enter CookieSpecBase.validate(" | |
29 | + + "String, port, path, boolean, Cookie)"); | |
30 | + if (host == null) { | |
31 | + throw new IllegalArgumentException("Host of origin may not be null"); | |
32 | + } | |
33 | + if (host.trim().equals("")) { | |
34 | + throw new IllegalArgumentException( | |
35 | + "Host of origin may not be blank"); | |
36 | + } | |
37 | + if (port < 0) { | |
38 | + throw new IllegalArgumentException("Invalid port: " + port); | |
39 | + } | |
40 | + if (path == null) { | |
41 | + throw new IllegalArgumentException( | |
42 | + "Path of origin may not be null."); | |
43 | + } | |
44 | + if (path.trim().equals("")) { | |
45 | + path = PATH_DELIM; | |
46 | + } | |
47 | + host = host.toLowerCase(); | |
48 | + // check version | |
49 | + if (cookie.getVersion() < 0) { | |
50 | + throw new MalformedCookieException("Illegal version number " | |
51 | + + cookie.getValue()); | |
52 | + } | |
53 | + | |
54 | + // security check... we musn't allow the server to give us an | |
55 | + // invalid domain scope | |
56 | + | |
57 | + // Validate the cookies domain attribute. NOTE: Domains without | |
58 | + // any dots are allowed to support hosts on private LANs that don't | |
59 | + // have DNS names. Since they have no dots, to domain-match the | |
60 | + // request-host and domain must be identical for the cookie to sent | |
61 | + // back to the origin-server. | |
62 | + if (host.indexOf(".") >= 0) { | |
63 | + // Not required to have at least two dots. RFC 2965. | |
64 | + // A Set-Cookie2 with Domain=ajax.com will be accepted. | |
65 | + | |
66 | + // domain must match host | |
67 | + if (!host.endsWith(cookie.getDomain())) { | |
68 | + String s = cookie.getDomain(); | |
69 | + if (s.startsWith(".")) { | |
70 | + s = s.substring(1, s.length()); | |
71 | + } | |
72 | + if (!host.equals(s)) { | |
73 | + throw new MalformedCookieException( | |
74 | + "Illegal domain attribute \"" + cookie.getDomain() | |
75 | + + "\". Domain of origin: \"" + host + "\""); | |
76 | + } | |
77 | + } | |
78 | + } else { | |
79 | + if (!host.equals(cookie.getDomain())) { | |
80 | + throw new MalformedCookieException( | |
81 | + "Illegal domain attribute \"" + cookie.getDomain() | |
82 | + + "\". Domain of origin: \"" + host + "\""); | |
83 | + } | |
84 | + } | |
85 | + | |
86 | + // another security check... we musn't allow the server to give us a | |
87 | + // cookie that doesn't match this path | |
88 | + | |
89 | + int idx = path.lastIndexOf(PATH_DELIM); | |
90 | + String requstPath = path; | |
91 | + if (idx > 0) { | |
92 | + requstPath = requstPath.substring(0, idx + 1); | |
93 | + } | |
94 | + if (cookie.getPath() != null && cookie.getPath().startsWith(requstPath)) { | |
95 | + throw new MalformedCookieException("Illegal path attribute \"" | |
96 | + + cookie.getPath() + "\". Path of origin: \"" + path + "\""); | |
97 | + } | |
98 | + // if (!path.startsWith(cookie.getPath())) { | |
99 | + // throw new MalformedCookieException( | |
100 | + // "Illegal path attribute \"" + cookie.getPath() | |
101 | + // + "\". Path of origin: \"" + path + "\""); | |
102 | + // } | |
103 | + } | |
104 | +} |
@@ -5,7 +5,7 @@ | ||
5 | 5 | import java.io.OutputStreamWriter; |
6 | 6 | import java.util.Map; |
7 | 7 | |
8 | -import jp.sf.ssoproxy.SSOProxyConstraints; | |
8 | +import jp.sf.ssoproxy.SSOProxyConstants; | |
9 | 9 | import jp.sf.ssoproxy.SSOProxyException; |
10 | 10 | import jp.sf.ssoproxy.forwarder.Forwarder; |
11 | 11 | import jp.sf.ssoproxy.forwarder.ForwarderException; |
@@ -88,16 +88,16 @@ | ||
88 | 88 | getHtmlHandlerName()); |
89 | 89 | |
90 | 90 | String inputEncoding = (String) props |
91 | - .get(SSOProxyConstraints.INPUT_ENCODING_PARAM); | |
91 | + .get(SSOProxyConstants.INPUT_ENCODING_PARAM); | |
92 | 92 | if (inputEncoding == null) { |
93 | 93 | inputEncoding = DEFAULT_INPUT_ENCODING; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // set properties |
97 | - htmlHandler.getProperties().put(SSOProxyConstraints.URL_PARAM, | |
98 | - props.get(SSOProxyConstraints.URL_PARAM)); | |
99 | - htmlHandler.getProperties().put(SSOProxyConstraints.PROXY_CONFIG_PARAM, | |
100 | - props.get(SSOProxyConstraints.PROXY_CONFIG_PARAM)); | |
97 | + htmlHandler.getProperties().put(SSOProxyConstants.URL_PARAM, | |
98 | + props.get(SSOProxyConstants.URL_PARAM)); | |
99 | + htmlHandler.getProperties().put(SSOProxyConstants.PROXY_CONFIG_PARAM, | |
100 | + props.get(SSOProxyConstants.PROXY_CONFIG_PARAM)); | |
101 | 101 | |
102 | 102 | InputSource inputSource = new InputSource(is); |
103 | 103 | inputSource.setEncoding(inputEncoding); |
@@ -124,7 +124,7 @@ | ||
124 | 124 | parser.parse(inputSource); |
125 | 125 | |
126 | 126 | String encoding = (String) props |
127 | - .get(SSOProxyConstraints.OUTPUT_ENCODING_PARAM); | |
127 | + .get(SSOProxyConstants.OUTPUT_ENCODING_PARAM); | |
128 | 128 | if (encoding == null) { |
129 | 129 | // encoding = DEFAULT_OUTPUT_ENCODING; |
130 | 130 | encoding = inputEncoding; |
@@ -143,7 +143,7 @@ | ||
143 | 143 | // } catch (IOException e) { |
144 | 144 | // error |
145 | 145 | throw new ForwarderException("000006", new Object[] { props |
146 | - .get(SSOProxyConstraints.URL_PARAM) }, e); | |
146 | + .get(SSOProxyConstants.URL_PARAM) }, e); | |
147 | 147 | } |
148 | 148 | } |
149 | 149 |
@@ -5,7 +5,7 @@ | ||
5 | 5 | import java.io.OutputStream; |
6 | 6 | import java.util.Map; |
7 | 7 | |
8 | -import jp.sf.ssoproxy.SSOProxyConstraints; | |
8 | +import jp.sf.ssoproxy.SSOProxyConstants; | |
9 | 9 | import jp.sf.ssoproxy.SSOProxyException; |
10 | 10 | import jp.sf.ssoproxy.forwarder.Forwarder; |
11 | 11 | import jp.sf.ssoproxy.forwarder.ForwarderException; |
@@ -31,7 +31,7 @@ | ||
31 | 31 | } catch (IOException e) { |
32 | 32 | // error |
33 | 33 | throw new ForwarderException("000007", new Object[] { props |
34 | - .get(SSOProxyConstraints.URL_PARAM) }, e); | |
34 | + .get(SSOProxyConstants.URL_PARAM) }, e); | |
35 | 35 | } |
36 | 36 | } |
37 | 37 |
@@ -2,7 +2,7 @@ | ||
2 | 2 | |
3 | 3 | import java.util.Map; |
4 | 4 | |
5 | -import jp.sf.ssoproxy.SSOProxyConstraints; | |
5 | +import jp.sf.ssoproxy.SSOProxyConstants; | |
6 | 6 | import jp.sf.ssoproxy.handler.html.HtmlHandler; |
7 | 7 | import jp.sf.ssoproxy.util.ElementHandlerUtil; |
8 | 8 |
@@ -24,11 +24,11 @@ | ||
24 | 24 | if (ElementHandler.HREF_ATTR.equals(attrName)) { |
25 | 25 | Map<String, Object> props = htmlHandler.getProperties(); |
26 | 26 | // store original url |
27 | - props.put(SSOProxyConstraints.ORIGINAL_URL_PARAM, props | |
28 | - .get(SSOProxyConstraints.URL_PARAM)); | |
27 | + props.put(SSOProxyConstants.ORIGINAL_URL_PARAM, props | |
28 | + .get(SSOProxyConstants.URL_PARAM)); | |
29 | 29 | // replace current url |
30 | 30 | String url = attributes.getValue(i); |
31 | - props.put(SSOProxyConstraints.URL_PARAM, url); | |
31 | + props.put(SSOProxyConstants.URL_PARAM, url); | |
32 | 32 | htmlHandler.write(ElementHandlerUtil.buildUrl(htmlHandler, |
33 | 33 | url)); |
34 | 34 | } else { |
@@ -4,7 +4,7 @@ | ||
4 | 4 | import java.net.URL; |
5 | 5 | import java.util.Map; |
6 | 6 | |
7 | -import jp.sf.ssoproxy.SSOProxyConstraints; | |
7 | +import jp.sf.ssoproxy.SSOProxyConstants; | |
8 | 8 | import jp.sf.ssoproxy.config.ProxyConfig; |
9 | 9 | import jp.sf.ssoproxy.handler.html.HtmlHandler; |
10 | 10 |
@@ -11,7 +11,7 @@ | ||
11 | 11 | public class ElementHandlerUtil { |
12 | 12 | public static String buildUrl(HtmlHandler htmlHandler, String url) { |
13 | 13 | Map<String, Object> props = htmlHandler.getProperties(); |
14 | - String currentUrl = (String) props.get(SSOProxyConstraints.URL_PARAM); | |
14 | + String currentUrl = (String) props.get(SSOProxyConstants.URL_PARAM); | |
15 | 15 | if (url.indexOf("://") < 0) { |
16 | 16 | try { |
17 | 17 | url = new URL(new URL(currentUrl), url).toString(); |
@@ -20,7 +20,7 @@ | ||
20 | 20 | } |
21 | 21 | } |
22 | 22 | ProxyConfig proxyConfig = (ProxyConfig) props |
23 | - .get(SSOProxyConstraints.PROXY_CONFIG_PARAM); | |
23 | + .get(SSOProxyConstants.PROXY_CONFIG_PARAM); | |
24 | 24 | return proxyConfig.buildProxyUrl(url); |
25 | 25 | } |
26 | 26 | } |
@@ -7,7 +7,7 @@ | ||
7 | 7 | import java.util.List; |
8 | 8 | import java.util.Map; |
9 | 9 | |
10 | -import jp.sf.ssoproxy.SSOProxyConstraints; | |
10 | +import jp.sf.ssoproxy.SSOProxyConstants; | |
11 | 11 | |
12 | 12 | import org.apache.commons.httpclient.NameValuePair; |
13 | 13 | import org.apache.commons.httpclient.methods.GetMethod; |
@@ -26,7 +26,7 @@ | ||
26 | 26 | } |
27 | 27 | |
28 | 28 | boolean alreadyAdded = false; |
29 | - if (url.indexOf(SSOProxyConstraints.REQUEST_PARAM_URL_SEPARATOR) >= 0) { | |
29 | + if (url.indexOf(SSOProxyConstants.REQUEST_PARAM_URL_SEPARATOR) >= 0) { | |
30 | 30 | alreadyAdded = true; |
31 | 31 | } |
32 | 32 |
@@ -38,14 +38,14 @@ | ||
38 | 38 | for (int i = 0; i < value.length; i++) { |
39 | 39 | if (alreadyAdded) { |
40 | 40 | query |
41 | - .append(SSOProxyConstraints.REQUEST_PARAM_QUERY_SEPARATOR); | |
41 | + .append(SSOProxyConstants.REQUEST_PARAM_QUERY_SEPARATOR); | |
42 | 42 | } else { |
43 | 43 | query |
44 | - .append(SSOProxyConstraints.REQUEST_PARAM_URL_SEPARATOR); | |
44 | + .append(SSOProxyConstants.REQUEST_PARAM_URL_SEPARATOR); | |
45 | 45 | alreadyAdded = true; |
46 | 46 | } |
47 | 47 | query.append(encode(key, encoding)); |
48 | - query.append(SSOProxyConstraints.REQUEST_PARAM_EQUAL); | |
48 | + query.append(SSOProxyConstants.REQUEST_PARAM_EQUAL); | |
49 | 49 | query.append(encode(value[i], encoding)); |
50 | 50 | } |
51 | 51 | } |
@@ -8,7 +8,7 @@ | ||
8 | 8 | import javax.servlet.http.HttpServletRequest; |
9 | 9 | import javax.servlet.http.HttpServletResponse; |
10 | 10 | |
11 | -import jp.sf.ssoproxy.SSOProxyConstraints; | |
11 | +import jp.sf.ssoproxy.SSOProxyConstants; | |
12 | 12 | import jp.sf.ssoproxy.SSOProxyException; |
13 | 13 | import jp.sf.ssoproxy.servlet.ProxyServlet; |
14 | 14 |
@@ -45,8 +45,8 @@ | ||
45 | 45 | // TODO response status code |
46 | 46 | response.setStatus(500); |
47 | 47 | |
48 | - request.setAttribute(SSOProxyConstraints.ERROR_CODE, errorCode); | |
49 | - request.setAttribute(SSOProxyConstraints.ERROR_MESSAGE, errorMessage); | |
48 | + request.setAttribute(SSOProxyConstants.ERROR_CODE, errorCode); | |
49 | + request.setAttribute(SSOProxyConstants.ERROR_MESSAGE, errorMessage); | |
50 | 50 | |
51 | 51 | RequestDispatcher rd = request.getRequestDispatcher(errorPage); |
52 | 52 | rd.forward(request, response); |
@@ -141,6 +141,11 @@ | ||
141 | 141 | </exclusions> |
142 | 142 | </dependency> |
143 | 143 | <dependency> |
144 | + <groupId>commons-fileupload</groupId> | |
145 | + <artifactId>commons-fileupload</artifactId> | |
146 | + <version>1.2.1</version> | |
147 | + </dependency> | |
148 | + <dependency> | |
144 | 149 | <groupId>commons-httpclient</groupId> |
145 | 150 | <artifactId>commons-httpclient</artifactId> |
146 | 151 | <version>3.1</version> |