001: /**
002: * $Id: NotesABStore.java,v 1.4 2005/06/13 21:56:23 rakeshn Exp $
003: * Copyright 2002 Sun Microsystems, Inc. All rights reserved. Use of this
004: * product is subject to license terms. Federal Acquisitions:
005: * Commercial Software -- Government Users Subject to Standard License Terms
006: * 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.ab.notes;
012:
013: import com.sun.addressbook.ABSession;
014: import com.sun.addressbook.ABStoreException;
015: import com.sun.ssoadapter.ab.pim.JPimABStore;
016:
017: import com.sun.addressbook.MissingPropertiesException;
018:
019: import com.aligo.pim.PimContainerType;
020: import com.aligo.pim.PimUserInfoParameter;
021: import com.aligo.pim.interfaces.PimUserInfo;
022:
023: //the following are required only for DominoSSO
024: import com.aligo.pim.interfaces.PimContainer;
025: import com.aligo.pim.exceptions.PimException; //The following is a private api of Aligo
026: import com.aligo.pim.lotus.*;
027:
028: public class NotesABStore extends JPimABStore {
029: public static final String LTPA_TOKEN = "lotus.ltpatoken.value";
030:
031: /**
032: * Returns the Container Type corresponding to the notes backend
033: */
034: protected PimContainerType getPimContainerType(ABSession session) {
035: return PimContainerType.LOTUS;
036: }
037:
038: public void init(ABSession session, PimUserInfo pimU)
039: throws MissingPropertiesException {
040: String userName = session.getProperty(USERNAME);
041: String userPasswd = session.getProperty(USERPASSWD);
042: String jPimHost = session.getProperty(JPIMHOST);
043: String jPimPort = session.getProperty(JPIMPORT);
044: String ltpaToken = session.getProperty(LTPA_TOKEN);
045:
046: if (ltpaToken != null) {
047: pimU.set(PimUserInfoParameter.LOTUS_LTPA_TOKEN, ltpaToken);
048: //To workaround the Aligo bug which throws exception for null user
049: userName = "sso";
050: userPasswd = "sso";
051: }
052:
053: if (userName == null) {
054: throw new MissingPropertiesException(
055: "Cannot connect to JPim server:: Missing Property: "
056: + USERNAME);
057: }
058:
059: if (userPasswd == null) {
060: throw new MissingPropertiesException(
061: "Cannot connect to JPim server:: Missing Property: "
062: + USERPASSWD);
063: }
064:
065: if (jPimHost == null) {
066: throw new MissingPropertiesException(
067: "Cannot connect to JPim server:: Missing Property: "
068: + JPIMHOST);
069: }
070:
071: if (jPimPort != null) {
072: jPimHost += ":" + jPimPort; // host:port format
073: }
074:
075: pimU.set(PimUserInfoParameter.LOTUS_USERNAME, userName);
076: pimU.set(PimUserInfoParameter.LOTUS_PASSWORD, userPasswd);
077: pimU.set(PimUserInfoParameter.LOTUS_SERVER, jPimHost);
078:
079: boolean debugEnabled = (new Boolean(session
080: .getProperty("ab.pim.debug"))).booleanValue();
081: if (debugEnabled) {
082: pimU.set(PimUserInfoParameter.DEBUG, "true");
083: }
084: }
085:
086: /**
087: * This postConnect does the required stuff
088: * like getting the CurrentUser info from the remote server
089: * used for Notes in case of SSO
090: */
091: protected void postConnect(PimContainer pimContainer)
092: throws ABStoreException {
093: try {
094: if (pimContainer.getCurrentUser() instanceof LotusPimAddressEntryItem) {
095: LotusPimAddressEntryItem addrItem = (LotusPimAddressEntryItem) pimContainer
096: .getCurrentUser();
097: String mailFileName = addrItem.getMailFileName();
098: session.setProperty("lotus.mailFileName", mailFileName);
099: int i = mailFileName.lastIndexOf("/");
100: int j = mailFileName.lastIndexOf("\\");
101: int k = (i > j) ? i : j;
102: String userName = null;
103: if (k > 0)
104: userName = mailFileName.substring(k + 1);
105: if (userName != null)
106: session.setProperty("lotus.sso.user", userName);
107: }
108: } catch (PimException ex) {
109: throw new ABStoreException("failed in postConnect" + ex);
110: }
111: }
112:
113: }
|