01: /* Copyright 2002 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.security;
07:
08: import org.apache.commons.logging.Log;
09: import org.apache.commons.logging.LogFactory;
10: import org.jasig.portal.ChannelRuntimeData;
11: import org.jasig.portal.ChannelStaticData;
12:
13: /**
14: * <p>LocalConnectionContext allows channels to tailor backend connections
15: * to reflect local policy and implementation. Connections are provided
16: * as Objects: they may be URL, LDAP, database connections, etc.</p>
17: *
18: * <p>Channels using this need a way to determine which implementation to
19: * use. A standard way to do this is with a static data parameter
20: * 'upc_localConnContext', the value being the name of the implementing
21: * class. The default implementation handles the case where there are
22: * no local changes to standard behaviour.</p>
23: *
24: * @author Sarah Arnott, sarnott@mun.ca
25: * @author Andrew Draskoy, andrew@mun.ca
26: * @version $Revision: 36404 $
27: */
28: public abstract class LocalConnectionContext {
29: protected ChannelStaticData staticData;
30:
31: protected final Log log = LogFactory.getLog(getClass());
32:
33: /**
34: * Initialize LocalConnectionContext by setting static data.
35: * Parameters may be passed to the implementing class via static
36: * data (which includes access to IPerson). Must always be called
37: * before sendLocalData.
38: *
39: * @param sd The calling channel's ChannelStaticData.
40: */
41: public void init(ChannelStaticData sd) {
42: staticData = sd;
43: }
44:
45: /**
46: * Returns a descriptor such as a URL for opening a connection
47: * to the backend application. The descriptor should be modified
48: * as necessary, for example modifying the a URL to include new
49: * query string parameters.
50: *
51: * @param descriptor The original descriptor.
52: * @param rd The calling channel's ChannelRuntimeData.
53: */
54: public String getDescriptor(String descriptor, ChannelRuntimeData rd) {
55: return descriptor;
56: }
57:
58: /**
59: * Send any per-connection local data to the backend application.
60: * E.g. headers in an http POST request. The default implementation
61: * does nothing.
62: *
63: * @param connection The connection Object to the backend application
64: * (ie. HttpURLConnection, DirContext).
65: * @param rd The calling channel's ChannelRuntimeData.
66: */
67: public void sendLocalData(Object connection, ChannelRuntimeData rd) {
68: }
69:
70: }
|