001: /**
002: * $Id: ClientAwareUserContext.java,v 1.2 2005/07/15 00:17:25 rakeshn Exp $
003: * Copyright 2002 Sun Microsystems, Inc. Allrights reserved. Use of
004: * this product is subjectto license terms. Federal Acquisitions:
005: * Commercial Software -- Government Users Subject to Standard License
006: * Terms and Conditions.
007: *
008: * Sun, Sun Microsystems, the Sun logo, and Sun ONE are trademarks or
009: * registered trademarks of Sun Microsystems,Inc. in the United States
010: * and other countries.
011: */package com.sun.ssoadapter.config;
012:
013: import java.util.Hashtable;
014: import java.util.List;
015: import java.util.Map;
016: import java.util.Locale;
017: import java.util.Set;
018: import java.util.Properties;
019:
020: import java.io.File;
021: import java.io.IOException;
022: import java.io.FileNotFoundException;
023: import java.util.MissingResourceException;
024:
025: import com.sun.ssoadapter.SSOAdapterSession;
026:
027: /**
028: * Copied from hana_ws/ps/desktop/src/com/sun/portal/
029: * desktop/context/DesktopContext.java
030: *
031: * <p>This object encapsulates objects with user session - ServiceUserContext,
032: * SessionUserContext and (global) ClientContext, DebugContext
033: * & FileLookupContext.
034: *
035: * <p>
036: * Till DSAME supports client-aware attribute storage and reteival,
037: * the get*Attribute() & set*Attribute() methods of this object will get &
038: * set attributes in a client-aware fashion.
039: *
040: * <p>
041: * The get and set methods depend on the schema definition of the attribute
042: * to decide if the client-aware lookup needs to be done. The "any" attribute
043: * of the attribute definition in the schema must contain the keyword
044: * "client-aware". The "any" attribute now uses only "display", the new
045: * definition will become "display,client-aware". Also the attribute must
046: * be defined as a"list".
047: *
048: * <p>
049: * Assume a mailservice attribute for url requiring client specific attributes:
050: * <br>
051: * <code>
052: * <AttributeSchema name="iplanet-mailservice-urls" <br>
053: * type="list" syntax="string" i18nKey="URLs" any="display,client-aware" >
054: *
055: * <p>
056: *
057: * <DefaultValues><br>
058: * <Value> genericHTML|http://mail.com </Value>
059: * <br>
060: * <Value> WML|http://wap.mail.com </Value>
061: * <br>
062: * <Value> Nokia|http://wap.mail.com/Nokia </Value>
063: * <br>
064: * </DefaultValues><br>
065: *
066: * </AttributeSchema >
067: * </code>
068: *
069: * <p>
070: * get & set *Attributes() look at the clientType in the session.
071: * get*Attribute() - Hierarchial lookup will not be done, if a clientType
072: * specific attribute is not found, the value of genericHTML will be returned.
073: * <p>
074: * set*Attribute() - will always set the attribute for the clientType in the
075: * session.
076: */
077:
078: public interface ClientAwareUserContext {
079: /**
080: * Initializes the session aware context for the user.
081: *
082: * @param session
083: * @param caAppContext The session-less context (optional - can be null)
084: * Useful if some session-less objects are required in this object
085: * @throws java.lang.IllegalStateException
086: * @throws com.sun.ssoadapter.config.SAALException
087: */
088: public void init(SSOAdapterSession session,
089: ClientAwareAppContext caAppContext)
090: throws IllegalStateException, SAALException;
091:
092: /**
093: * Write out any modified data to the persistent store, if necessary.
094: */
095: public void store();
096:
097: //
098: // service
099: //
100:
101: /**
102: * Gets the attribute. 'Attributes' are service attributes
103: * @param service A list of properties required by the backend service.
104: * Ex: DSAME requires a name of the service to get any attributes in the
105: * Global/Organization scope. The name of the service is referenced
106: * by the keyword "serviceName".
107: * <b> Note: If service is null or if the serviceName
108: * is not specified in the Map, then the implementation for DSAME
109: * assumes a scope of User/Dynamic. </b>
110: *
111: * @param clientType The clientType specific attribute to look for. If this
112: * is null, the session's clientType value is used.
113: * @param attrName The attribute name.
114: * @return The attribute value in String format. If property is
115: * not found, return null.
116: *
117: * @exception
118: * IllegalStateException If the session is not valid
119: * @exception IOException If the value could not be retrieved from the
120: * data store.
121: *
122: */
123: public String getStringAttribute(Map service, String clientType,
124: String attrName) throws IllegalStateException, IOException;
125:
126: /**
127: * Gets the attribute. 'Attributes' are service attributes
128: * @param service A list of properties required by the backend service.
129: * Ex: DSAME requires a name of the service to get any attributes in the
130: * Global/Organization scope. The name of the service is referenced
131: * by the keyword "serviceName".
132: * <b> Note: If service is null or if the serviceName
133: * is not specified in the Map, then the implementation for DSAME
134: * assumes a scope of User/Dynamic. </b>
135: *
136: * @param attrName The attribute name.
137: * @return The attribute value in String format. If property is
138: * not found, return null.
139: *
140: * @exception
141: * IllegalStateException If the session is not valid
142: * @exception IOException If the value could not be retrieved from the
143: * data store.
144: *
145: */
146: public String getStringAttribute(Map service, String attrName)
147: throws IllegalStateException, IOException;
148:
149: /**
150: * Gets the attributes multi-vals. 'Attributes' are service attributes
151: * @param service A list of properties required by the backend service.
152: * Ex: DSAME requires a name of the service to get any attributes in the
153: * Global/Organization scope. The name of the service is referenced
154: * by the keyword "serviceName".
155: * <b> Note: If service is null or if the serviceName
156: * is not specified in the Map, then the implementation for DSAME
157: * assumes a scope of User/Dynamic. </b>
158: *
159: * @param clientType The clientType specific attribute to look for. If this
160: * is null, the session's clientType value is used.
161: * @param attrName The attribute name.
162: *
163: * @return The attribute values as Set. If property is
164: * not found, return null.
165: *
166: * @exception
167: * IllegalStateException If the session is not valid
168: * @exception IOException If the value could not be retrieved from the
169: * data store.
170: */
171: public Set getAttribute(Map service, String clientType,
172: String attrName) throws IllegalStateException, IOException;
173:
174: /**
175: * Gets the attributes multi-vals. 'Attributes' are service attributes
176: * @param service A list of properties required by the backend service.
177: * Ex: DSAME requires a name of the service to get any attributes in the
178: * Global/Organization scope. The name of the service is referenced
179: * by the keyword "serviceName".
180: * <b> Note: If service is null or if the serviceName
181: * is not specified in the Map, then the implementation for DSAME
182: * assumes a scope of User/Dynamic. </b>
183: *
184: * @param attrName The attribute name.
185: *
186: * @return The attribute values as Set. If property is
187: * not found, return null.
188: *
189: * @exception
190: * IllegalStateException If the session is not valid
191: * @exception IOException If the value could not be retrieved from the
192: * data store.
193: */
194: public Set getAttribute(Map service, String attrName)
195: throws IllegalStateException, IOException;
196:
197: /**
198: * Sets the attribute value. New data is persisted immediately.
199: * Uses the clientType of the session if necessary.
200: *
201: * @param service A list of properties required by the backend service.
202: * Ex: DSAME requires a name of the service to set any attributes in the
203: * Global/Organization scope. The name of the service is referenced
204: * by the keyword "serviceName". The Map "must" contain this property
205: * to work with DSAME. If this property is not found in the map, the
206: * DSAME implementation throws a MissingResourceException.
207: *
208: * @param attrName The attribute name.
209: * @param val The attribute value.
210: * @param forceClientAwareness If true and existing attributes are not
211: * client-aware, modifies the old values with "default|" and stores the
212: * new values as "clienttype|value"
213: *
214: * @exception
215: * IllegalStateException If the session is not valid
216: * @exception IOException If the value could not be set in the
217: * data store.
218: * @exception
219: * MissingResourceException If any of the properties required by the
220: * backend service were missing the the service MAP
221: */
222: public void setStringAttribute(Map service, String attrName,
223: String val, boolean forceClientAwareness)
224: throws IllegalStateException, MissingResourceException,
225: IOException;
226:
227: /**
228: * Sets the attribute value. New data is persisted immediately.
229: * @param service A list of properties required by the backend service.
230: * Ex: DSAME requires a name of the service to set any attributes in the
231: * Global/Organization scope. The name of the service is referenced
232: * by the keyword "serviceName". The Map "must" contain this property
233: * to work with DSAME. If this property is not found in the map, the
234: * DSAME implementation throws a MissingResourceException.
235: *
236: * @param clientType The value is to be set for this clientType. Implicitly
237: * turns forceClientAwareness to TRUE
238: * @param attrName The attribute name.
239: * @param val The attribute value.
240: *
241: * @exception
242: * IllegalStateException If the session is not valid
243: * @exception IOException If the value could not be set in the
244: * data store.
245: * @exception
246: * MissingResourceException If any of the properties required by the
247: * backend service were missing the the service MAP
248: */
249: public void setStringAttribute(Map service, String clientType,
250: String attrName, String val) throws IllegalStateException,
251: MissingResourceException, IOException;
252:
253: /**
254: * Sets the attribute value. New data is persisted immediately.
255: * The implicit value for forceClientAwareness is FALSE and the clientType
256: * in the sesion will be used if necessary.
257: *
258: * @param service A list of properties required by the backend service.
259: * Ex: DSAME requires a name of the service to set any attributes in the
260: * Global/Organization scope. The name of the service is referenced
261: * by the keyword "serviceName". The Map "must" contain this property
262: * to work with DSAME. If this property is not found in the map, the
263: * DSAME implementation throws a MissingResourceException.
264: *
265: * @param attrName The attribute name.
266: * @param val The attribute value.
267: *
268: * @exception
269: * IllegalStateException If the session is not valid
270: * @exception IOException If the value could not be set in the
271: * data store.
272: * @exception
273: * MissingResourceException If any of the properties required by the
274: * backend service were missing the the service MAP
275: */
276: public void setStringAttribute(Map service, String attrName,
277: String val) throws IllegalStateException,
278: MissingResourceException, IOException;
279:
280: /**
281: * Sets the attribute values.
282: * @param service A list of properties required by the backend service.
283: * Ex: DSAME requires a name of the service to set any attributes in the
284: * Global/Organization scope. The name of the service is referenced
285: * by the keyword "serviceName". The Map "must" contain this property
286: * to work with DSAME. If this property is not found in the map, the
287: * DSAME implementation throws a MissingResourceException.
288: *
289: * @param attrName The attribute name.
290: * @param vals The attribute values.
291: * @param forceClientAwareness If true and existing attributes are not
292: * client-aware, modifies the old values with "default|" and stores the
293: * new values as "clienttype|value"
294: *
295: * @exception
296: * IllegalStateException If the session is not valid
297: * @exception IOException If the value could not be set in the
298: * data store.
299: * @exception
300: * MissingResourceException If any of the properties required by the
301: * backend service were missing the the service MAP
302: */
303: public void setAttribute(Map service, String attrName, Set vals,
304: boolean forceClientAwareness) throws IllegalStateException,
305: MissingResourceException, IOException;
306:
307: /**
308: * Sets the attribute values.
309: * @param service A list of properties required by the backend service.
310: * Ex: DSAME requires a name of the service to set any attributes in the
311: * Global/Organization scope. The name of the service is referenced
312: * by the keyword "serviceName". The Map "must" contain this property
313: * to work with DSAME. If this property is not found in the map, the
314: * DSAME implementation throws a MissingResourceException.
315: *
316: * @param clientType The value is to be set for this clientType. Implicitly
317: * turns forceClientAwareness to TRUE
318: * @param attrName The attribute name.
319: * @param vals The attribute values.
320: *
321: * @exception
322: * IllegalStateException If the session is not valid
323: * @exception IOException If the value could not be set in the
324: * data store.
325: * @exception
326: * MissingResourceException If any of the properties required by the
327: * backend service were missing the the service MAP
328: */
329: public void setAttribute(Map service, String clientType,
330: String attrName, Set vals) throws IllegalStateException,
331: MissingResourceException, IOException;
332:
333: /**
334: * Sets the attribute value. New data is persisted immediately.
335: * The implicit value for forceClientAwareness is FALSE and the clientType
336: * in the sesion will be used if necessary.
337: *
338: * @param service A list of properties required by the backend service.
339: * Ex: DSAME requires a name of the service to set any attributes in the
340: * Global/Organization scope. The name of the service is referenced
341: * by the keyword "serviceName". The Map "must" contain this property
342: * to work with DSAME. If this property is not found in the map, the
343: * DSAME implementation throws a MissingResourceException.
344: *
345: * @param attrName The attribute name.
346: * @param vals The attribute values.
347: *
348: * @exception
349: * IllegalStateException If the session is not valid
350: * @exception IOException If the value could not be set in the
351: * data store.
352: * @exception
353: * MissingResourceException If any of the properties required by the
354: * backend service were missing the the service MAP
355: */
356: public void setAttribute(Map service, String attrName, Set vals)
357: throws IllegalStateException, MissingResourceException,
358: IOException;
359:
360: /**
361: * Remove an attribute
362: *
363: * @param service A list of properties required by the backend service.
364: * Ex: DSAME requires a name of the service to set any attributes in the
365: * Global/Organization scope. The name of the service is referenced
366: * by the keyword "serviceName". The Map "must" contain this property
367: * to work with DSAME. If this property is not found in the map, the
368: * DSAME implementation throws a MissingResourceException.
369: *
370: * @param attrName The attribute name.
371: *
372: * @exception
373: * IllegalStateException If the session is not valid
374: * @exception IOException If the value could not be set in the
375: * data store.
376: * @exception
377: * MissingResourceException If any of the properties required by the
378: * backend service were missing the the service MAP
379: */
380: public void removeAttribute(Map service, String attrName)
381: throws IllegalStateException, MissingResourceException,
382: IOException;
383:
384: }
|