001: /**
002: * $Id: AbstractSSOAdapter.java,v 1.1 2005/06/13 18:08:49 rakeshn Exp $
003: * Copyright 2002 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and iPlanet
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.ssoadapter;
014:
015: import java.util.Locale;
016: import java.util.List;
017: import java.util.Properties;
018: import com.iplanet.sso.SSOToken;
019: import com.iplanet.sso.SSOTokenListener;
020: import com.iplanet.sso.SSOTokenEvent;
021: import com.iplanet.sso.SSOException;
022:
023: /**
024: * This abstract class describes an object that implements SSOAdapter functionality.
025: * <p>The primary purpose of an AbstractSSOAdapter is to provide SSO enablement
026: * of servlet based middleware, in regards to access to back-end services, e.g.,
027: * mail, calendar, or addressbook.
028: * <p>An AbstractSSOAdapter acts as a bridge
029: * between the DSAME authentication and sessioning mechanism and
030: * whatever authentication and sessioning mechanism is employed
031: * by a particular back-end service.
032: * <p> The derived class of AbstractSSOAdapter must implement
033: * <ul>
034: * <li>if init(...) implemeted , it should invoke the init(...) of the base AbstractSSOAdapter
035: * <li>getConnection()
036: * <li>closeConnection()
037: * <li>ssoTokenChanged()
038: * </ul>
039: * <p>Other methods provided by a particular AbstractSSOAdapter implementation will
040: * probably depend on the API and service for which the helper is
041: * providing SSO enablement.
042: *
043: * @version 1.0
044: * @see com.sun.ssoadapter.SSOAdapterFactory
045: * @see com.sun.ssoadapter.SSOAdapterException
046: *
047: */
048:
049: public abstract class AbstractSSOAdapter implements SSOAdapter {
050: /**
051: * The adapterName
052: */
053: protected String adapterName;
054: /**
055: * TheadapterProperties
056: */
057: protected Properties adapterProperties;
058: /**
059: * the SSOToken
060: */
061: protected SSOToken token;
062: /**
063: * The locale for localized Error Message
064: */
065: protected Locale locale;
066: /**
067: * The identifier (DN) of the user
068: */
069: protected String identifier;
070: /**
071: * the user's PropertyList
072: */
073: protected List userPropertyList;
074: /**
075: * The encodedPropertyList
076: */
077: protected List encodedPropertyList;
078:
079: /**
080: * The no argument Constructor
081: */
082: protected AbstractSSOAdapter() {
083: }
084:
085: /**
086: * Performs AbstractSSOAdapter initialization.
087: * <p>When an AbstractSSOAdapter is instantiated by an SSOAdapterFactory,
088: * this method is invoked immediately following object creation.
089: * <p>The init() method should not be used to perform any sort
090: * of authencation nor should it establish a connection with any
091: * backend service.
092: * <p>The init() method is only invoked once during the lifetime of
093: * an AbstractSSOAdapter.
094: * @param adapterName Used to identify the AbstractSSOAdapter
095: * @param token Used to identify the user on who's behalf the request is
096: * being processed.
097: * @param adapterProperties Contains the adapter information that will drive
098: * the operation of this instance of an AbstractSSOAdapter.
099: * @param userPropertiesList a list on Strings , which contains the keys userConfigurableProperties
100: * @param encodedProperteisList a list on Strings , which contains the keys encodedConfigurableProperties
101: * @param locale locale if passed in to the SSOAdapterFactory.
102: * @throws com.sun.ssoadapter.SSOAdapterException If fails
103: */
104: public void init(String adapterName, SSOToken token,
105: Properties adapterProperties, List userPropertiesList,
106: List encodedProperteisList, Locale locale)
107: throws SSOAdapterException {
108: this .adapterName = adapterName;
109: this .token = token;
110: this .adapterProperties = adapterProperties;
111: this .userPropertyList = userPropertiesList;
112: this .encodedPropertyList = encodedProperteisList;
113: this .locale = locale;
114:
115: try {
116: identifier = "dn=" + token.getPrincipal().getName();
117: } catch (Exception e) {
118: identifier = " ";
119: }
120:
121: }
122:
123: /**
124: * Adapter specific Connection.
125: * It typically returns the MailStore for JavaMailSSOAdapter
126: * @return This can be any Object like JavaMailStore
127: */
128: public abstract Object getConnection();
129:
130: /**
131: * Returns the SSOToken bound to this SSOAdapter.
132: * @throws com.sun.ssoadapter.SSOAdapterException Exception if fails
133: * @return The SSOToken
134: */
135: public SSOToken getSSOToken() throws SSOAdapterException {
136: return token;
137: }
138:
139: /**
140: * Returns the Name of this SSOAdapter.
141: * @return The Name of this Adapter
142: */
143: public String getName() {
144: return this .adapterName;
145: }
146:
147: /**
148: * Returns the Properties bound to this SSOAdapter.
149: * @return A list of properties which are set
150: */
151: public Properties getProperties() {
152: return this .adapterProperties;
153: }
154:
155: /**
156: * If the sepcified Property is a User configurable it will return true else false
157: * @param propertyKey the key you want to check
158: * @return true if the argument is a UserProperty else false
159: * @since Portal 7
160: */
161: public boolean isUserProperty(String propertyKey) {
162: if (userPropertyList != null
163: && userPropertyList.contains(propertyKey)) {
164: return true;
165: }
166: return false;
167: }
168:
169: /**
170: * if this property can be configured only by Admin returns true else false
171: * @param propertyKey the key you want to test
172: * @return true if it is a admin Property else false
173: * @since Portal 7
174: */
175: public boolean isAdminProperty(String propertyKey) {
176: return !isUserProperty(propertyKey);
177: }
178:
179: /**
180: * If this is a Encoded property returns true else false
181: * @param propertyKey the key you want to test
182: * @return true if it is a EncodedProperty else false
183: * @since Portal 7
184: */
185: public boolean isEncodedProperty(String propertyKey) {
186: if (encodedPropertyList != null
187: && encodedPropertyList.contains(propertyKey)) {
188: return true;
189: }
190: return false;
191: }
192:
193: /**
194: * A List of the user Properties Keys. The values are available in getProperties
195: * @return the List containing UserProperties keys.
196: * @since Portal 7
197: */
198: public List getUserPropertiesList() {
199: return userPropertyList;
200: }
201:
202: /**
203: * A List of the encoded Properties Keys. The values are available in getProperties
204: * @return the List containing EncodedProperties keys.
205: * @since Portal 7
206: */
207: public List getEncodedPropertiesList() {
208: return encodedPropertyList;
209: }
210:
211: /**
212: * Adapter specific Connection termination.
213: * @return true on success , false otherwise
214: */
215: public abstract boolean closeConnection();
216:
217: /**
218: * Implements SSOTokenListener "ssoTokenChanged" method.
219: * @see com.iplanet.sso.SSOTokenListener
220: * @param evt This is passed by AM with
221: * clean if evtType != evt.SSO_TOKEN_DESTROY
222: * || evtType != evt.SSO_TOKEN_IDLE_TIMEOUT
223: * || evtType != evt.SSO_TOKEN_MAX_TIMEOUT
224: */
225: public abstract void ssoTokenChanged(SSOTokenEvent evt);
226:
227: }
|