Source Code Cross Referenced for NotesMailHelper.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: NotesMailHelper.java,v 1.21 2005/09/21 10:48:12 dg154973 Exp $ Copyright
003:         *  2002 Sun Microsystems, Inc. All rights reserved. Use of this product is
004:         *  subject to license terms. Federal Acquisitions: Commercial Software --
005:         *  Government Users Subject to Standard License Terms and Conditions. Sun, Sun
006:         *  Microsystems, the Sun logo, and iPlanet are trademarks or registered
007:         *  trademarks of Sun Microsystems, Inc. in the United States and other
008:         *  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.Level;
031:        import java.util.logging.Logger;
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>port</b> : Optional value. Port number of IMAP server. Defaults to
083:         *    "143" when protocol is "imap", and "110" when protocol is "pop3".
084:         *    <li> <b>smtpServer</b> : Optional value. Specifies name of outgoing mail
085:         *    server. Defaults to value of host property.
086:         *    <li> <b>clientProtocol</b> : Protocol to specify within URLs that activate
087:         *    web application functionality. Defaults to "http".
088:         *    <li> <b>clientPort</b> : Port to specify within URLs that that activate
089:         *    web application functionality. Defaults to "80".
090:         *    <li> <b>jspContextPath</b> : The "request context path" to use when
091:         *    forming a URL that activates MAP JSP application functionality. Defaults
092:         *    to request.getContextPath().
093:         *    <li> <b>jspLaunch</b> : The document path to use when forming a URL that
094:         *    activates MAP JSP application functionality.
095:         *  </ul>
096:         *
097:         *
098:         *@author     John Saare
099:         *@created    December 4, 2003
100:         *@version    1.0
101:         *@see        com.sun.ssoadapter.SSOAdapter
102:         *@see        com.sun.ssoadapter.SSOAdapterFactory
103:         */
104:
105:        public class NotesMailHelper extends ApplicationHelper implements 
106:                MailApplicationHelper {
107:
108:            /**  Description of the Field */
109:            public MailProvider provider = null;
110:            /**  Description of the Field */
111:            public SSOAdapter ssoAdapter = null;
112:            /**  Description of the Field */
113:            public Properties adapterProperties = null;
114:            protected String appName = "";
115:            protected String containerName = "";
116:
117:            // Create a logger for this class
118:            private static Logger debugLogger = PortalLogger
119:                    .getLogger(NotesMailHelper.class);
120:
121:            /**
122:             *  Initialize Helper.
123:             *
124:             *@param  ssoAdapter  SSOAdapter object
125:             *@param  provider    current MailProvider
126:             */
127:            public void init(MailProvider provider, SSOAdapter ssoAdapter)
128:                    throws Exception {
129:                super .init((ProfileProviderAdapter) provider, ssoAdapter);
130:                this .provider = provider;
131:                this .ssoAdapter = ssoAdapter;
132:
133:                if (ssoAdapter != null) {
134:                    this .adapterProperties = ssoAdapter.getProperties();
135:                }
136:
137:            }
138:
139:            /**
140:             *  Returns a client URL, if supported by the service.
141:             *
142:             *@param  provider    MailProvider
143:             *@param  request     servlet request
144:             *@return             The startURL value
145:             */
146:            public String getStartURL(MailProvider provider,
147:                    HttpServletRequest request) {
148:                String url = null;
149:
150:                try {
151:                    url = getApplicationURL(provider, request);
152:                    ProviderContext pc = provider.getProviderContext();
153:                    url = pc.escape(url);
154:                } catch (Exception e) {
155:                    debugLogger.log(Level.FINE, "PSMC_CSPPM0001", e);
156:                }
157:
158:                return url;
159:            }
160:
161:            /**
162:             *  Returns client aware URL for mail application access to service associated
163:             *  with a particular instance of a NotesMailHelper.
164:             *
165:             *@param  provider  MailProvider
166:             *@param  request   HttpServletRequest
167:             *@return           The applicationURL value
168:             */
169:            public String getApplicationURL(MailProvider provider,
170:                    HttpServletRequest request) throws Exception {
171:
172:                String clientProtocol = adapterProperties.getProperty(
173:                        "clientProtocol", "http");
174:                String clientPort = adapterProperties.getProperty("clientPort",
175:                        adapterProperties.getProperty("port", "80"));
176:                String host = adapterProperties.getProperty("host");
177:
178:                String clientURL = clientProtocol + "://" + host + ":"
179:                        + clientPort;
180:
181:                // check for valid session, if not valid then return base url
182:                SSOToken tok = ssoAdapter.getSSOToken();
183:
184:                if (tok != null) {
185:                    clientURL += "/mail/"
186:                            + adapterProperties.getProperty("uid") + ".nsf";
187:                }
188:
189:                return clientURL;
190:            }
191:
192:            /**
193:             *  Returns client aware URL for message access to service associated with a
194:             *  particular instance of a NotesMailHelper.
195:             *
196:             *@param  provider  current mail provider
197:             *@param  request   servlet request
198:             *@param  message   message to generate link for
199:             *@return           The messageURL value
200:             */
201:            public String getMessageURL(MailProvider provider,
202:                    HttpServletRequest request, Message message)
203:                    throws Exception {
204:                return null;
205:            }
206:
207:            /**
208:             *  Returns the contents of the MailProviders edit page
209:             *
210:             *@param  mprov  current mail provider
211:             *@param  req    servlet request
212:             *@param  res    servlet response
213:             *@return        The appPrefsEdit value
214:             */
215:            public StringBuffer getAppPrefsEdit(MailProvider mprov,
216:                    HttpServletRequest req, HttpServletResponse res) {
217:                setEditContainer(mprov.editContainer);
218:                setContainerName(mprov.containerName);
219:                setTargetProvider(mprov.targetProvider);
220:                return super .getAppPrefsEdit((Provider) mprov, req, res);
221:            }
222:
223:            /**
224:             *  Processes values returned from the MailProvider edit page
225:             *
226:             *@param  mprov  Instance of Mail Provider
227:             *@param  req    servlet request
228:             *@param  res    servlet response
229:             */
230:            public URL processAppPrefsEdit(MailProvider mprov,
231:                    HttpServletRequest request, HttpServletResponse response)
232:                    throws ProviderException {
233:                setEditContainer(mprov.editContainer);
234:                setContainerName(mprov.containerName);
235:                setTargetProvider(mprov.targetProvider);
236:                return super .processAppPrefsEdit((Provider) mprov, request,
237:                        response);
238:            }
239:
240:            /**
241:             *  Returns a HTML link containing encoding specific for the app helper
242:             *
243:             *@param  req  servlet request
244:             *@param  pc   provider context
245:             *@return      The appHelperEditLink value
246:             */
247:
248:            public String getAppHelperEditLink(HttpServletRequest req,
249:                    ProviderContext pc) {
250:
251:                Hashtable tagTable = new Hashtable();
252:                StringBuffer link = new StringBuffer();
253:                try {
254:                    link.append(pc.getDesktopURL(req));
255:                } catch (Exception e) {
256:                    return "";
257:                }
258:                link.append("?action=edit&provider=");
259:                link.append(ProviderEditUtility.getRequestParameter("provider",
260:                        req));
261:                link.append("&targetprovider=" + provider.getName());
262:                link.append("&containerName=");
263:                link.append(ProviderEditUtility.getRequestParameter(
264:                        "containerName", req));
265:                link.append("&appPref=" + this .getName());
266:
267:                tagTable.put("editLink", link.toString());
268:                String content = null;
269:
270:                try {
271:                    String fontTag = pc.getStringProperty(provider.getName(),
272:                            "fontFace1", "Sans-serif");
273:                    tagTable.put("iwtDesktop-fontFace1", fontTag);
274:                    ProviderEditUtility
275:                            .setDefaultPresentation(provider.getName(),
276:                                    provider.getProviderContext(), tagTable);
277:                    content = pc.getTemplate(provider.getName(),
278:                            "edit-link.template", tagTable).toString();
279:                    debugLogger.log(Level.FINER, "PSMC_CSPPM0002", content
280:                            .toString());
281:                } catch (Exception e) {
282:                    debugLogger.log(Level.INFO, "PSMC_CSPPM0003", e);
283:                    content = "";
284:                }
285:
286:                debugLogger.log(Level.FINER, "PSMC_CSPPM0004", content
287:                        .toString());
288:
289:                return content;
290:            }
291:
292:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.