Source Code Cross Referenced for ExchangeMailHelper.java in  » Portal » Open-Portal » com » sun » portal » providers » mail » 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.portal.providers.mail 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *  $Id: ExchangeMailHelper.java,v 1.21 2005/09/21 10:48:02 dg154973 Exp $
003:         *  Copyright 2002 Sun Microsystems, Inc. All rights reserved. Use of this
004:         *  product is subject to license terms. Federal Acquisitions: Commercial
005:         *  Software -- Government Users Subject to Standard License Terms and
006:         *  Conditions. Sun, Sun Microsystems, the Sun logo, and iPlanet are trademarks
007:         *  or registered trademarks of Sun Microsystems, Inc. in the United States and
008:         *  other countries.
009:         */package com.sun.portal.providers.mail;
010:
011:        import java.io.BufferedReader;
012:        import com.sun.portal.providers.context.Theme;
013:        import java.io.InputStreamReader;
014:        import java.io.IOException;
015:        import java.net.HttpURLConnection;
016:        import java.net.MalformedURLException;
017:        import java.net.URL;
018:        import java.net.URLEncoder;
019:        import java.util.Date;
020:        import java.util.Properties;
021:        import java.util.Hashtable;
022:        import java.util.Enumeration;
023:        import java.util.List;
024:        import java.util.Map;
025:        import java.util.Map.Entry;
026:        import java.util.ResourceBundle;
027:        import java.util.Set;
028:        import java.util.StringTokenizer;
029:        import java.util.Iterator;
030:        import java.util.logging.Logger;
031:        import java.util.logging.Level;
032:        import javax.mail.Folder;
033:        import javax.mail.Message;
034:        import javax.mail.UIDFolder;
035:        import javax.servlet.http.HttpServletRequest;
036:        import javax.servlet.http.HttpServletResponse;
037:        import com.iplanet.sso.*;
038:        import com.iplanet.sso.SSOToken;
039:        import com.iplanet.sso.SSOException;
040:        import com.sun.ssoadapter.SSOAdapter;
041:        import com.sun.ssoadapter.SSOAdapterException;
042:        import com.sun.ssoadapter.SSOAdapterFactory;
043:        import com.sun.portal.providers.context.ProviderContext;
044:        import com.sun.portal.providers.context.ProviderContextException;
045:        import com.sun.portal.providers.Provider;
046:        import com.sun.portal.providers.ProfileProviderAdapter;
047:        import com.sun.portal.providers.ApplicationHelper;
048:        import com.sun.portal.providers.ProviderException;
049:        import com.sun.portal.providers.ProviderEditUtility;
050:        import com.sun.portal.providers.util.ProviderProperties;
051:        import com.sun.portal.log.common.PortalLogger;
052:
053:        /**
054:         *  This class implements MailSSOHelper and MailApplicationHelper functionality
055:         *  specific to the Sun One Portal and Mail services. <p>
056:         *
057:         *  Specific features include:
058:         *  <ul>
059:         *    <li> Support for username/password style authentication.</li>
060:         *    <li> Ability to generate web application URLs for the following:
061:         *    <ul>
062:         *      <li> Messenger Express</li>
063:         *      <li> MAP JSP Mail application. The URL generated in this case will
064:         *      specify a configuration index via the query string parameter: "mi".
065:         *      </li>
066:         *    </ul>
067:         *    </li>
068:         *  </ul>
069:         *  <p>
070:         *
071:         *  At the present time, username/password is stored in the clear. <p>
072:         *
073:         *  This MailSSOHelper implementation consumes the following Configuration
074:         *  properties:
075:         *  <ul>
076:         *    <li> <b>protocol</b> : Required value. Must be either "imap" or "pop3".
077:         *
078:         *    <li> <b>uid</b> : Required value. Username (uid) of imap user.
079:         *    <li> <b>password</b> : Required value. Password of imap user.
080:         *    <li> <b>host</b> : Required value. Name of host providing IMAP service.
081:         *
082:         *    <li> <b>winDomain</b> : Optional value. NT domain to which user belongs.
083:         *
084:         *    <li> <b>port</b> : Optional value. Port number of IMAP server. Defaults to
085:         *    "143" when protocol is "imap", and "110" when protocol is "pop3".
086:         *    <li> <b>smtpServer</b> : Optional value. Specifies name of outgoing mail
087:         *    server. Defaults to value of host property.
088:         *    <li> <b>clientProtocol</b> : Protocol to specify within URLs that activate
089:         *    web application functionality. Defaults to "http".
090:         *    <li> <b>clientPort</b> : Port to specify within URLs that that activate
091:         *    web application functionality. Defaults to "80".
092:         *    <li> <b>jspContextPath</b> : The "request context path" to use when
093:         *    forming a URL that activates MAP JSP application functionality. Defaults
094:         *    to request.getContextPath().
095:         *    <li> <b>jspLaunch</b> : The document path to use when forming a URL that
096:         *    activates MAP JSP application functionality. Defaults to
097:         *    "/jsp/default/launchMail.jsp".
098:         *    <li> <b>exchangeContextPath</b> : The "request context path" to use when
099:         *    forming a URL that activates Exchange OWA functionality. Defaults to
100:         *    "/exchange".
101:         *    <li> <b>exchangeOperation</b> : The operation to be invoked within
102:         *    Exchange OWA. Defaults to null, but should be set to "inbox" for Exchange
103:         *    2000 installations.
104:         *  </ul>
105:         *
106:         *
107:         *@author     Administrator
108:         *@created    December 2, 2003
109:         *@version    1.0
110:         *@see        com.sun.ssoadapter.SSOAdapter
111:         *@see        com.sun.ssoadapter.SSOAdapterFactory
112:         */
113:
114:        public class ExchangeMailHelper extends ApplicationHelper implements 
115:                MailApplicationHelper {
116:
117:            /**
118:             *  Mail Provider instance
119:             */
120:            public MailProvider provider = null;
121:            /**
122:             *  SSOAdapter instance
123:             */
124:            public SSOAdapter ssoAdapter = null;
125:            /**
126:             *  SSOAdapter properties
127:             */
128:            public Properties adapterProperties = null;
129:            /**
130:             *  Application name
131:             */
132:            protected String appName = "";
133:            /**
134:             *  Container name
135:             */
136:            protected String containerName = "";
137:
138:            // Create a logger for this class
139:            private static Logger debugLogger = PortalLogger
140:                    .getLogger(ExchangeMailHelper.class);
141:
142:            /**
143:             *  Initialize Helper.
144:             *
145:             *@param  ssoAdapter     SSOAdapter object
146:             *@param  provider       MailProvider instance
147:             *@exception  Exception
148:             */
149:            public void init(MailProvider provider, SSOAdapter ssoAdapter)
150:                    throws Exception {
151:                super .init((ProfileProviderAdapter) provider, ssoAdapter);
152:                this .provider = provider;
153:                this .ssoAdapter = ssoAdapter;
154:
155:                if (ssoAdapter != null) {
156:                    this .adapterProperties = ssoAdapter.getProperties();
157:                }
158:
159:            }
160:
161:            /**
162:             *  Returns a client URL, if supported by the service.
163:             *
164:             *@param  provider    MailProvider
165:             *@param  request     Description of the Parameter
166:             *@return             The startURL value
167:             */
168:            public String getStartURL(MailProvider provider,
169:                    HttpServletRequest request) {
170:                String url = null;
171:
172:                try {
173:                    url = getApplicationURL(provider, request);
174:                    ProviderContext pc = provider.getProviderContext();
175:                    url = pc.escape(url);
176:                } catch (Exception e) {
177:                    debugLogger.log(Level.FINE, "PSMC_CSPPM0001", e);
178:                }
179:
180:                return url;
181:            }
182:
183:            /**
184:             *  Returns client aware URL for mail application access to service associated
185:             *  with a particular instance of a ExchangeMailHelper.
186:             *
187:             *@param  provider       MailProvider
188:             *@param  request        HttpServletRequest
189:             *@return                The applicationURL value
190:             *@exception  Exception
191:             */
192:            public String getApplicationURL(MailProvider provider,
193:                    HttpServletRequest request) throws Exception {
194:
195:                //webview: http://ex-server/exchange/uid/Inbox/subject.EML/1_multipart/1_text.txt?Security=2
196:                String host = adapterProperties.getProperty("host");
197:                String clientPort = adapterProperties.getProperty("clientPort",
198:                        adapterProperties.getProperty("port", "80"));
199:                String clientProtocol = adapterProperties.getProperty(
200:                        "clientProtocol", "http");
201:                String exchangeContextPath = adapterProperties.getProperty(
202:                        "exchangeContextPath", "/exchange");
203:
204:                String clientURL = clientProtocol + "://" + host + ":"
205:                        + clientPort + exchangeContextPath;
206:
207:                // check for valid session, if not valid then return base url
208:                SSOToken tok = ssoAdapter.getSSOToken();
209:
210:                if (tok != null) {
211:                    String exchangeOperation = adapterProperties
212:                            .getProperty("exchangeOperation");
213:
214:                    if (exchangeOperation != null) {
215:                        clientURL += "/" + adapterProperties.getProperty("uid")
216:                                + "/" + exchangeOperation;
217:                    }
218:                }
219:
220:                return clientURL;
221:            }
222:
223:            /**
224:             *  Returns client aware URL for message access to service associated with a
225:             *  particular instance of a ExchangeMailHelper.
226:             *
227:             *@param  provider       MailProvider instance
228:             *@param  request        Servlet request
229:             *@param  message        Message to generate a link for
230:             *@return                The messageURL value
231:             *@exception  Exception
232:             */
233:            public String getMessageURL(MailProvider provider,
234:                    HttpServletRequest request, Message message)
235:                    throws Exception {
236:                //msgview: http://ex-server/exchange/uid/Inbox/subject.EML?Cmd=open
237:                return null;
238:            }
239:
240:            /**
241:             *  Returns the contents of the MailProviders edit page
242:             *
243:             *@param  mprov  Mail Provider Instance
244:             *@param  req    Servlet request
245:             *@param  res    Servlet response
246:             *@return        The appPrefsEdit value
247:             */
248:            public StringBuffer getAppPrefsEdit(MailProvider mprov,
249:                    HttpServletRequest req, HttpServletResponse res) {
250:                setEditContainer(mprov.editContainer);
251:                setContainerName(mprov.containerName);
252:                setTargetProvider(mprov.targetProvider);
253:                return super .getAppPrefsEdit((Provider) mprov, req, res);
254:            }
255:
256:            /**
257:             *  Processes values returned from the MailProvider edit page
258:             *
259:             *@param  mprov  Instance of Mail Provider
260:             *@param  req    servlet request
261:             *@param  res    servlet response
262:             */
263:            public URL processAppPrefsEdit(MailProvider mprov,
264:                    HttpServletRequest request, HttpServletResponse response)
265:                    throws ProviderException {
266:                setEditContainer(mprov.editContainer);
267:                setContainerName(mprov.containerName);
268:                setTargetProvider(mprov.targetProvider);
269:                return super .processAppPrefsEdit((Provider) mprov, request,
270:                        response);
271:            }
272:
273:            /**
274:             *  Returns a HTML link containing encoding specific for the app helper
275:             *
276:             *@param  req  servlet request
277:             *@param  pc   current ProviderContext
278:             *@return      The appHelperEditLink value
279:             */
280:
281:            public String getAppHelperEditLink(HttpServletRequest req,
282:                    ProviderContext pc) {
283:
284:                Hashtable tagTable = new Hashtable();
285:                StringBuffer link = new StringBuffer();
286:                try {
287:                    link.append(pc.getDesktopURL(req));
288:                } catch (Exception e) {
289:                    return "";
290:                }
291:                link.append("?action=edit&provider=");
292:                link.append(ProviderEditUtility.getRequestParameter("provider",
293:                        req));
294:                link.append("&targetprovider=" + provider.getName());
295:                link.append("&containerName=");
296:                link.append(ProviderEditUtility.getRequestParameter(
297:                        "containerName", req));
298:                link.append("&appPref=" + this .getName());
299:
300:                tagTable.put("editLink", link.toString());
301:                String content = null;
302:
303:                try {
304:                    String fontTag = pc.getStringProperty(provider.getName(),
305:                            "fontFace1", "Sans-serif");
306:                    tagTable.put("iwtDesktop-fontFace1", fontTag);
307:                    ProviderEditUtility
308:                            .setDefaultPresentation(provider.getName(),
309:                                    provider.getProviderContext(), tagTable);
310:                    content = pc.getTemplate(provider.getName(),
311:                            "edit-link.template", tagTable).toString();
312:                    debugLogger.log(Level.FINER, "PSMC_CSPPM0002", content
313:                            .toString());
314:                } catch (Exception e) {
315:                    debugLogger.log(Level.INFO, "PSMC_CSPPM0003", e);
316:                    content = "";
317:                }
318:
319:                debugLogger.log(Level.FINER, "PSMC_CSPPM0004", content
320:                        .toString());
321:
322:                return content;
323:            }
324:
325:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.