Source Code Cross Referenced for APimCalStore.java in  » Portal » Open-Portal » com » sun » ssoadapter » calendar » pim » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.ssoadapter.calendar.pim 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: APimCalStore.java,v 1.15 2006/04/25 20:14:35 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.calendar.pim;
014:
015:        import java.util.*;
016:        import java.io.*;
017:        import com.sun.comclient.calendar.*;
018:
019:        import com.aligo.pim.interfaces.*;
020:        import com.aligo.pim.exceptions.*;
021:        import com.aligo.pim.*;
022:
023:        /**
024:         * Property attributes used by this class:
025:         * <ul>
026:         * <li><i>cal.exchange.domain</i> - Exchange NT domain name</li>
027:         * <li><i>cal.exchange.mbox</i> - Mailbox of user on the Exchange server (not used)</li>
028:         * <li><i>cal.exchange.ocxhost</i> - hostname of the ocx proxy</li>
029:         * <li><i>cal.pim.service</i> - Determines which service the PIM adapter is to use. Valid values are "exchange" and "notes"</li>
030:         * </ul>
031:         */
032:        public class APimCalStore extends CalendarStore {
033:
034:            PimContainer pimContainer = null;
035:            PimUserInfo pimUserInfo;
036:
037:            boolean connected = false;
038:
039:            String calid = null;
040:
041:            /**
042:             * PimCalstore constructor. 
043:             * <br><br>
044:             * The class <i>URLName</i>, while is not mail specific, comes
045:             * from the javamail package. I am reusing it here instead of 
046:             * creating my own.
047:             * <br><br>
048:             *
049:             * @param session     Session object that created this store.
050:             * @param url    Server host/port in url format.
051:             */
052:            public APimCalStore(CalendarSession session) {
053:                super (session);
054:
055:                // Make sure we have a TimeZone object.
056:                TimeZone tz = session.getTimeZone();
057:                if (tz == null) {
058:                    session.setTimeZone(TimeZone.getDefault());
059:                }
060:            }
061:
062:            /**
063:             * Method to connect and authenticate the user using the
064:             * property settings from the CalSession.
065:             * <br><br>
066:             *
067:             * @exception CalendarStoreException if unable to connect to back end service
068:             */
069:            protected void connectURL(URLName url)
070:                    throws CalendarStoreException {
071:                try {
072:                    CalendarSession session = getSession();
073:
074:                    String pimService = session.getProperty("cal.pim.service",
075:                            "exchange");
076:                    boolean debugEnabled = (new Boolean(session.getProperty(
077:                            "cal.pim.debug", "false"))).booleanValue();
078:
079:                    String username = url.getUsername();
080:                    String password = url.getPassword();
081:                    String host = url.getHost();
082:                    int port = url.getPort();
083:
084:                    if (pimService.equalsIgnoreCase("exchange")) {
085:
086:                        String NTDomain = session
087:                                .getProperty("cal.exchange.domain");
088:                        String pimInterfaceType = session.getProperty(
089:                                "cal.exchange.pimInterfaceType", "webdav");
090:                        String ocxhost = session.getProperty(
091:                                "cal.exchange.ocxhost", host);
092:
093:                        if (pimInterfaceType == null
094:                                || (!pimInterfaceType.equalsIgnoreCase("cdo"))) {
095:                            String usersBaseDn = session
096:                                    .getProperty("cal.exchange.usersBaseDn");
097:                            String webdavProtocol = session
098:                                    .getProperty("cal.exchange.webdavProtocol");
099:                            String webdavPort = session
100:                                    .getProperty("cal.exchange.webdavPort");
101:                            boolean webdavTaskFilter = (new Boolean(
102:                                    session
103:                                            .getProperty(
104:                                                    "cal.exchange.webdavCustomTaskFilter",
105:                                                    "true"))).booleanValue();
106:                            String activeDirectoryLdapPort = session
107:                                    .getProperty("cal.exchange.activeDirectoryLdapPort");
108:                            //System.out.println("activeDirectoryLdapPort="+activeDirectoryLdapPort);
109:
110:                            pimContainer = PimFactory
111:                                    .getContainer(PimContainerType.EXCHANGE_WEBDAV);
112:                            pimUserInfo = pimContainer.addUserInfo();
113:                            pimUserInfo.set(
114:                                    PimUserInfoParameter.EXCHANGE_MAILBOX,
115:                                    username);
116:                            String webdav_url = webdavProtocol + "://" + host
117:                                    + ":" + webdavPort;
118:                            pimUserInfo.set(
119:                                    PimUserInfoParameter.EXCHANGE_WEBDAV_URL,
120:                                    webdav_url);
121:                            if (debugEnabled)
122:                                System.out.println("webdav_url=" + webdav_url);
123:                            //For webdav the Acive Directory can be on a different m/c than the exchnage m/c
124:                            //In that case the AD server name should be provided in ocxhost
125:                            if ((ocxhost == null) || ocxhost.length() == 0) {
126:                                ocxhost = host;
127:                            }
128:                            pimUserInfo.set(
129:                                    PimUserInfoParameter.JNDI_LDAP_SERVER,
130:                                    ocxhost);
131:                            //ldapUserName should be like "chertseydomain\a"
132:                            String ldapUserName = NTDomain + "\\" + username;
133:                            if (debugEnabled)
134:                                System.out.println("ldap userName="
135:                                        + ldapUserName + " usersBaseDn="
136:                                        + usersBaseDn);
137:                            pimUserInfo.set(
138:                                    PimUserInfoParameter.JNDI_LDAP_USERNAME,
139:                                    ldapUserName);
140:                            pimUserInfo.set(
141:                                    PimUserInfoParameter.JNDI_LDAP_PASSWORD,
142:                                    password);
143:                            pimUserInfo.set(
144:                                    PimUserInfoParameter.JNDI_LDAP_PORT,
145:                                    activeDirectoryLdapPort);
146:
147:                            pimUserInfo.set(
148:                                    PimUserInfoParameter.JNDI_LDAP_AB_BASE,
149:                                    usersBaseDn);
150:                            //pimU.set(PimUserInfoParameter.JNDI_LDAP_AB_BASE,"ou=PLANET3,o=Sun Microsystems");
151:
152:                            pimUserInfo
153:                                    .set(
154:                                            PimUserInfoParameter.JNDI_LDAP_TRY_ANONYMOUS_FALLBACK,
155:                                            "true");
156:
157:                            if (webdavTaskFilter) {
158:                                //To fix Task bug#5079910 , do the following 
159:                                //But it may detoriate the performace for Large number of Tasks on User's Cal
160:                                pimUserInfo
161:                                        .set(
162:                                                PimUserInfoParameter.EXCHANGE_WEBDAV_SPECIAL_TASK_FILTER,
163:                                                "true");
164:                            }
165:
166:                        } else {
167:
168:                            pimContainer = PimFactory
169:                                    .getContainer(PimContainerType.EXCHANGE);
170:                            pimUserInfo = pimContainer.addUserInfo();
171:
172:                            pimUserInfo
173:                                    .set(
174:                                            PimUserInfoParameter.EXCHANGE_OCXHOST_LOCATION,
175:                                            ocxhost);
176:                            pimUserInfo.set(
177:                                    PimUserInfoParameter.EXCHANGE_NT_DOMAIN,
178:                                    NTDomain);
179:                            pimUserInfo.set(
180:                                    PimUserInfoParameter.EXCHANGE_SERVER, host);
181:
182:                        }
183:                        if (debugEnabled) {
184:                            pimUserInfo.set(PimUserInfoParameter.DEBUG, "true");
185:                        }
186:                        pimUserInfo.set(PimUserInfoParameter.EXCHANGE_USERNAME,
187:                                username);
188:                        pimUserInfo.set(PimUserInfoParameter.EXCHANGE_PASSWORD,
189:                                password);
190:
191:                    } else if (pimService.equalsIgnoreCase("notes")) {
192:                        pimContainer = PimFactory
193:                                .getContainer(PimContainerType.LOTUS);
194:                        pimUserInfo = pimContainer.addUserInfo();
195:                        if (debugEnabled) {
196:                            pimUserInfo.set(PimUserInfoParameter.DEBUG, "true");
197:                        }
198:
199:                        if (port > 0) {
200:                            host = host + ":" + port;
201:                        }
202:
203:                        //presenlty username null throws exception by aligo hence the workaround
204:                        if (username == null || username.equals("")
205:                                || username.equalsIgnoreCase("sso")) {
206:                            String ltpaToken = session.getProperty(
207:                                    "lotus.ltpatoken.value", "");
208:                            if (ltpaToken != null && (!ltpaToken.equals(""))) {
209:                                pimUserInfo.set(
210:                                        PimUserInfoParameter.LOTUS_LTPA_TOKEN,
211:                                        ltpaToken);
212:                                username = "sso";
213:                                password = "sso";
214:                            }
215:                        }
216:                        pimUserInfo.set(PimUserInfoParameter.LOTUS_USERNAME,
217:                                username);
218:                        pimUserInfo.set(PimUserInfoParameter.LOTUS_PASSWORD,
219:                                password);
220:                        pimUserInfo
221:                                .set(PimUserInfoParameter.LOTUS_SERVER, host);
222:
223:                    } else {
224:                        throw new CalendarStoreException(
225:                                "Unknown service specified");
226:                    }
227:
228:                    pimContainer.logon();
229:                    connected = true;
230:                    calid = username;
231:                    if (pimContainer.getCurrentUser() != null) {
232:                        calid = pimContainer.getCurrentUser().getName();
233:                    }
234:
235:                    if (pimService.equalsIgnoreCase("notes")) {
236:                        if (pimContainer.getCurrentUser() instanceof  com.aligo.pim.lotus.LotusPimAddressEntryItem) {
237:                            com.aligo.pim.lotus.LotusPimAddressEntryItem addrItem = (com.aligo.pim.lotus.LotusPimAddressEntryItem) pimContainer
238:                                    .getCurrentUser();
239:                            String mailFileName = addrItem.getMailFileName();
240:                            session.setProperty("lotus.mailFileName",
241:                                    mailFileName);
242:                            int i = mailFileName.lastIndexOf("/");
243:                            int j = mailFileName.lastIndexOf("\\");
244:                            int k = (i > j) ? i : j;
245:                            String userName = null;
246:                            if (k > 0)
247:                                userName = mailFileName.substring(k + 1);
248:                            if (userName != null)
249:                                session.setProperty("lotus.sso.user", userName);
250:                        }
251:                    }
252:                } catch (Exception e) {
253:                    e.printStackTrace();
254:                    throw new CalendarStoreException(e.getMessage());
255:                }
256:            }
257:
258:            /**
259:             * Method that disconnects from the calendar server and
260:             * close all connections.
261:             */
262:            public void disconnect() throws CalendarStoreException {
263:                try {
264:                    pimContainer.logoff();
265:                    connected = false;
266:                } catch (Exception e) {
267:                    e.printStackTrace();
268:                    throw new CalendarStoreException(e.getMessage());
269:                }
270:            }
271:
272:            /**
273:             * Method to determines if store has a valid connection
274:             * to the server.
275:             * <br><br>
276:             *
277:             * @return true if connected, false otherwise
278:             */
279:            public boolean isConnected() {
280:                return connected;
281:            }
282:
283:            public void importCalendar(String cid, DateTime start,
284:                    DateTime end, String contentFormat, InputStream inputStream)
285:                    throws CalendarStoreException,
286:                    OperationNotSupportedException {
287:                throw new OperationNotSupportedException(
288:                        "Method importCalendar() not supported");
289:            }
290:
291:            public void importCalendar(String cid, String contentFormat,
292:                    InputStream inputStream) throws CalendarStoreException,
293:                    OperationNotSupportedException {
294:                throw new OperationNotSupportedException(
295:                        "Method importCalendar() not supported");
296:            }
297:
298:            public BufferedReader exportCalendar(String cid, DateTime start,
299:                    DateTime end, String contentFormat)
300:                    throws CalendarStoreException,
301:                    OperationNotSupportedException {
302:                throw new OperationNotSupportedException(
303:                        "Method exportCalendar() not supported");
304:            }
305:
306:            public BufferedReader exportCalendar(String cid, DateTime start,
307:                    DateTime end, String contentFormat, String host, int port)
308:                    throws CalendarStoreException,
309:                    OperationNotSupportedException {
310:                throw new OperationNotSupportedException(
311:                        "Method exportCalendar() not supported");
312:            }
313:
314:            public void deleteCalendar(String cid)
315:                    throws CalendarStoreException,
316:                    OperationNotSupportedException {
317:                throw new OperationNotSupportedException(
318:                        "Method deleteCalendar() not supported");
319:            }
320:
321:            public ICalendar createCalendar(String cid, Properties props)
322:                    throws CalendarStoreException,
323:                    OperationNotSupportedException {
324:                throw new OperationNotSupportedException(
325:                        "Method createCalendar() not supported");
326:            }
327:
328:            public ICalendar createCalendar(String cid)
329:                    throws CalendarStoreException,
330:                    OperationNotSupportedException {
331:                throw new OperationNotSupportedException(
332:                        "Method createCalendar() not supported");
333:            }
334:
335:            public ICalendar[] searchCalendars(String searchFilter)
336:                    throws CalendarStoreException,
337:                    OperationNotSupportedException {
338:                throw new OperationNotSupportedException(
339:                        "Method searchCalendar() not supported");
340:            }
341:
342:            public ICalendar[] searchCalendars(String searchString,
343:                    int searchOpt, int maxResults)
344:                    throws CalendarStoreException,
345:                    OperationNotSupportedException {
346:                throw new OperationNotSupportedException(
347:                        "Method searchCalendar() not supported");
348:            }
349:
350:            public ICalendar[] searchCalendars(String searchFilter,
351:                    Properties requestProperties)
352:                    throws CalendarStoreException,
353:                    OperationNotSupportedException {
354:                throw new OperationNotSupportedException(
355:                        "This method searchCalendars(..) is not supported");
356:
357:            }
358:
359:            public ICalendar[] searchCalendars(String searchString,
360:                    int searchOpt, int maxResults, Properties requestProperties)
361:                    throws CalendarStoreException,
362:                    OperationNotSupportedException {
363:                throw new OperationNotSupportedException(
364:                        "This method searchCalendars(..) is not supported");
365:
366:            }
367:
368:            /**
369:             * Get the list of calendars id's owned by the user.  
370:             * <BR><BR>
371:             *
372:             * @return          array of owned calids    
373:             */
374:            public ICalendar[] getCalendars()
375:                    throws OperationNotSupportedException {
376:                throw new OperationNotSupportedException(
377:                        "Method getCalendars() not supported");
378:            }
379:
380:            /**
381:             * Get the list of calendar id's subscribed by the user.
382:             * <BR><BR>
383:             *
384:             * @return          array of owned calids    
385:             */
386:            public String[] getSubscribedCalenders()
387:                    throws CalendarStoreException,
388:                    OperationNotSupportedException {
389:                throw new OperationNotSupportedException(
390:                        "Method getSubscribedCalendars() not supported");
391:            }
392:
393:            /**
394:             * Method that takes a calendar ID, verifies it and returns
395:             * the fully qualified calendar ID. 
396:             * <BR><BR>
397:             *
398:             * @param cid calendar ID to be verified
399:             * @return fully qualified calendar id coorisponding to <b>cid</b>
400:             *
401:             * @exception InvalidCalendarIdException if <b>cid</b> is determined to be invalid  
402:             */
403:            public String verifyCalendarId(String cid)
404:                    throws OperationNotSupportedException {
405:
406:                throw new OperationNotSupportedException(
407:                        "Method verifyCalendarId(String) not supported");
408:            }
409:
410:            /**
411:             * Method to get this users default calendar id.
412:             * <BR><BR>
413:             *
414:             * @return The calendar id coorisponding to the authenticated user. 
415:             */
416:            protected String getDefaultCalendarId() {
417:                return calid;
418:            }
419:
420:            /**
421:             * Method to retrieve a calendar from the backend service.
422:             * <BR><BR>
423:             *
424:             * @param calId    A specific user calendar ID
425:             * @return             The specified users calendar 
426:             *
427:             * @exception CalendarStoreException if unable to load the specified calendar
428:             */
429:            protected ICalendar loadCalendar(String calId)
430:                    throws CalendarStoreException {
431:                try {
432:                    return new APimCalendar(this , calId);
433:                } catch (CalendarException cex) {
434:                    cex.printStackTrace();
435:                    throw new CalendarStoreException(cex.getMessage());
436:                }
437:            }
438:
439:            /**
440:             * Method to close a currently opened calendar 
441:             * <BR><BR>
442:             *
443:             * @param calId    A specific user calendar ID
444:             *
445:             * @exception CalendarStoreException if unable to close the specified calendar
446:             */
447:            protected void unloadCalendar(ICalendar cal)
448:                    throws CalendarStoreException {
449:                // nothing to do here at the moment
450:            }
451:
452:            public PimContainer getPimContainer() {
453:                return pimContainer;
454:            }
455:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.