01: /**
02: * $Id: CookiesConnectionHandler.java,v 1.5 2004/03/17 01:31:38 mjain Exp $
03: * Copyright 2003 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.wsrp.consumer.resourceproxy;
14:
15: import javax.servlet.http.HttpServletRequest;
16: import java.net.URLConnection;
17: import java.io.IOException;
18:
19: import com.sun.xml.rpc.client.http.CookieJar;
20:
21: /**
22: * Created by IntelliJ IDEA.
23: * User: tucu
24: * Date: Oct 30, 2003
25: * Time: 3:20:23 PM
26: * To change this template use Options | File Templates.
27: */
28: public class CookiesConnectionHandler implements ConnectionHandler {
29:
30: CookieJar _cookieJar = null;
31:
32: public CookiesConnectionHandler(HttpServletRequest req,
33: String cookieJarKey) {
34: if (cookieJarKey != null && cookieJarKey.length() > 0) {
35: _cookieJar = (CookieJar) req.getSession(true).getAttribute(
36: cookieJarKey);
37: }
38:
39: }
40:
41: public void preConnection(URLConnection conn) throws IOException {
42: if (_cookieJar != null) {
43: //System.out.println("Found the cookie Jar:");
44: _cookieJar.applyRelevantCookies(conn);
45: } else {
46: //System.out.println("Didnot find the cookie Jar");
47: }
48: }
49:
50: public void postConnection(URLConnection conn) throws IOException {
51: if (_cookieJar != null) {
52: _cookieJar.recordAnyCookies(conn);
53: }
54: }
55:
56: }
|