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


001:        /*
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
004:         */
005:        package com.sun.im.portal.servlet;
006:
007:        import java.io.*;
008:        import java.net.*;
009:        import javax.servlet.http.*;
010:        import javax.servlet.*;
011:        import com.iplanet.am.util.*;
012:        import com.iplanet.sso.*;
013:
014:        import com.sun.portal.log.common.PortalLogger;
015:        import java.util.logging.Logger;
016:        import java.util.logging.Level;
017:
018:        // This is basically a URL scraper.  It pulls data from the im provider and returns it to the client. 
019:        // During the read it checks for a xml descriptor.  If found it will set the content type to 
020:        // application/x-java-jnlp-file.  Needed because desktop providers are unable to set content type.
021:        public class LaunchServlet extends HttpServlet {
022:
023:            private static Logger debugLogger = PortalLogger
024:                    .getLogger("com.sun.portal.im.servlet");
025:
026:            public void doGet(HttpServletRequest request,
027:                    HttpServletResponse response) throws ServletException,
028:                    IOException {
029:                // Passing thru the improvider's getLaunchContent
030:                // The following attributes are required:
031:                //		launch - Type of launch.  jnlp for webstart, plugin for java applet
032:                //		provider - Name of the provider to use
033:                //
034:                // The following attributes are optional:
035:                //		username - User to start dialoge with
036:                //		msg - Message to send user on starting dialoge, ignored when username is missing
037:                //	
038:                String provider = request.getParameter("provider");
039:                String launch = request.getParameter("launch");
040:                if ((provider == null) || (launch == null))
041:                    throw new ServletException(
042:                            "Null values for required attributes");
043:                String username = request.getParameter("username");
044:                String msg = request.getParameter("msg");
045:
046:                String host = request.getServerName();
047:                int port = request.getServerPort();
048:                String proto = request.getScheme();
049:                String cookieName = SystemProperties.get(
050:                        "com.iplanet.am.cookie.name", "iPlanetDirectoryPro");
051:                String encoding = "UTF-8";
052:                StringBuffer ncURI = new StringBuffer(request.getContextPath());
053:                ncURI.append("/dt?provider=");
054:                ncURI.append(URLEncoder.encode(provider, encoding));
055:                ncURI.append("&launch=");
056:                ncURI.append(URLEncoder.encode(launch, encoding));
057:                if (username != null) {
058:                    ncURI.append("&username=");
059:                    ncURI.append(URLEncoder.encode(username, encoding));
060:                    if (msg != null) {
061:                        ncURI.append("&msg=");
062:                        ncURI.append(URLEncoder.encode(msg, encoding));
063:                    }
064:                }
065:                // Pass thru the gateway header info if available
066:                String gateway_url = request.getHeader("x-ps-gw-url");
067:                if (gateway_url != null) {
068:                    debugLogger.log(Level.FINEST,
069:                            "LaunchServlet.doGet: Found gateway url: {0}",
070:                            gateway_url);
071:                    ncURI.append("&gateway_url=");
072:                    ncURI.append(URLEncoder.encode(gateway_url, encoding));
073:                }
074:                ncURI.append("&last=false"); // Needed so that the provider doesn't consume the desktop
075:                URL nc = new URL(proto, host, port, ncURI.toString());
076:                HttpURLConnection ncc = (HttpURLConnection) nc.openConnection();
077:                ncc.setDoOutput(false);
078:                ncc.setDoInput(true);
079:                ncc.setUseCaches(false);
080:                try {
081:                    ncc.setRequestProperty("Cookie", cookieName
082:                            + "="
083:                            + URLEncoder.encode(SSOTokenManager.getInstance()
084:                                    .createSSOToken(request).getTokenID()
085:                                    .toString(), encoding));
086:                } catch (SSOException se) {
087:                    throw new ServletException("LaunchServlet", se);
088:                }
089:
090:                debugLogger.log(Level.FINEST,
091:                        "LaunchServlet.doGet: Finished creating url: {0}", nc
092:                                .toString());
093:                InputStream in = ncc.getInputStream();
094:                BufferedReader br = new BufferedReader(
095:                        new InputStreamReader(in));
096:                StringBuffer sb = new StringBuffer();
097:                String line;
098:                boolean isJnlp = false;
099:                debugLogger.log(Level.FINEST,
100:                        "LaunchServlet.doGet: Reading input stream");
101:                while ((line = br.readLine()) != null) {
102:                    if (line.startsWith("<?xml")) {
103:                        // Assume this is a jnlp file
104:                        debugLogger
105:                                .log(Level.FINEST,
106:                                        "LaunchServlet.doGet: Found xml descriptor string");
107:                        isJnlp = true;
108:                    }
109:                    sb.append(line);
110:                    sb.append('\n');
111:                }
112:                debugLogger
113:                        .log(Level.FINEST,
114:                                "LaunchServlet.doGet: Finished reading to StringBuffer");
115:                if (isJnlp) {
116:                    response
117:                            .setContentType("application/x-java-jnlp-file;charset=UTF-8");
118:                } else {
119:                    response.setContentType("text/html;charset=UTF-8");
120:                }
121:                // Must get writer after setting content type
122:                debugLogger.log(Level.FINEST,
123:                        "LaunchServlet.doGet: Now encoding is: {0}", response
124:                                .getCharacterEncoding());
125:                PrintWriter writer = response.getWriter();
126:                writer.write(sb.toString());
127:                debugLogger.log(Level.FINEST,
128:                        "LaunchServlet.doGet: Finished writing to PrintWriter");
129:            }
130:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.