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


001:        package com.sun.portal.comm.url;
002:
003:        import com.sun.ssoadapter.SSOAdapter;
004:
005:        import java.io.BufferedReader;
006:        import java.io.InputStreamReader;
007:
008:        import java.net.HttpURLConnection;
009:        import java.net.MalformedURLException;
010:        import java.net.URL;
011:
012:        public class SunABURLBuilder extends URLBuilder implements  ABURL {
013:
014:            protected String sid = null;
015:
016:            public void init(SSOAdapter ssoAdapter) {
017:                super .init(ssoAdapter);
018:                if (!serverSSOEnabled) {
019:                    getSession();
020:                }
021:            }
022:
023:            /**
024:             *	Checks whether the current sid for Messenger Express has
025:             *	timed out. This is done by checking if the page returned by sending a Get
026:             *	Mail WMAP command to messenger express contains string
027:             *	"parent.timeoutCB()". If yes, then the webmailSessionId has timed out.
028:             *
029:             *@return	boolean
030:             */
031:            public boolean isValidSession() {
032:
033:                if (sid == null) {
034:                    return false;
035:                }
036:                StringBuffer pageContent = new StringBuffer();
037:
038:                // Build the WMAP protocol's Get Mail command
039:                // Get 0 messages (count=0) to reduce the traffic
040:                StringBuffer urlstr = new StringBuffer(baseURL);
041:                urlstr
042:                        .append("/mbox.msc?security=false&mbox=INBOX&start=0&count=0&date=false");
043:                urlstr.append("&sid=");
044:                urlstr.append(encode(sid));
045:
046:                HttpURLConnection urlconn = null;
047:                try {
048:                    URL url = new URL(urlstr.toString());
049:                    urlconn = (HttpURLConnection) url.openConnection();
050:                    urlconn.setInstanceFollowRedirects(false);
051:                    BufferedReader in = new BufferedReader(
052:                            new InputStreamReader(urlconn.getInputStream()));
053:                    String inputLine = null;
054:                    // Getting the content of the page
055:                    while ((inputLine = in.readLine()) != null) {
056:                        pageContent.append(inputLine);
057:                    }
058:                    in.close();
059:                } catch (java.io.IOException ioe) {
060:                    return false;
061:                }
062:                // Check if the page contents contain string "parent.timeoutCB()"
063:                // If yes, then the webmailSessionId has timed out
064:                if ((pageContent.indexOf("parent.timeoutCB()")) > 0) {
065:                    sid = null;
066:                    return false;
067:                }
068:                return true;
069:            }
070:
071:            /**
072:             * Authenticate the user to Webmail / Messenger Express. If the return
073:             * cookie contains 'sid' then the user is considered authenticated.
074:             * Also sets the path to the authenticated location with the sid.
075:             *
076:             **/
077:            public void getSession() {
078:
079:                // Build WMAP protocol's Login command
080:                StringBuffer urlstr = new StringBuffer(baseURL);
081:                urlstr.append("/login.msc?");
082:                urlstr.append("password=");
083:                urlstr.append(encode(password));
084:                urlstr.append("&user=");
085:                urlstr.append(encode(user));
086:
087:                if (useProxyAuth) {
088:                    if ((proxyAuthUid != null) && (proxyAuthUid.length() > 0)) {
089:                        urlstr.append("&proxyauth=");
090:                        urlstr.append(encode(proxyAuthUid));
091:                    }
092:                }
093:
094:                if ((domain != null) && (domain.length() > 0)) {
095:                    urlstr.append("%40"); // URL encoding value for '@'
096:                    urlstr.append(encode(domain));
097:                }
098:
099:                HttpURLConnection urlconn = null;
100:                try {
101:                    URL url = new URL(urlstr.toString());
102:                    urlconn = (HttpURLConnection) url.openConnection();
103:                    urlconn.setInstanceFollowRedirects(false);
104:                } catch (MalformedURLException mfe) {
105:                    return;
106:                } catch (java.io.IOException ioe) {
107:                    return;
108:                }
109:                // Check if the headers of the response contain a Location field with
110:                // parameter 'sid' set.
111:                String location = urlconn.getHeaderField("Location");
112:                if (location != null) {
113:                    int sessionIdBegin = 0;
114:                    if ((sessionIdBegin = location.indexOf("sid")) < 0) {
115:                        // cannot authenticate to the Messenger Express
116:                        return;
117:                    } else {
118:                        setPath(location + "&view=portal");
119:                        String inter = location.substring(sessionIdBegin + 4);
120:                        int sessionIdEnd = inter.indexOf("&");
121:                        sid = inter.substring(0, sessionIdEnd);
122:                    }
123:                }
124:            }
125:
126:            /**
127:             * Lets invoking classes know if contact urls are available
128:             * in this URLBuilder.  
129:             *
130:             * @return	boolean	Are contact URLs available
131:             */
132:            public boolean allowsContactURL() {
133:                return false;
134:            }
135:
136:            /**
137:             * Return URL string for specific contact to be opened in ab client.
138:             *
139:             * @param	Object	contact
140:             * @return	String	View URL string
141:             */
142:            public String getContactURL(Object contact) {
143:                return getStartURL();
144:            }
145:
146:            /**
147:             *	Return the current ME session ID
148:             *
149:             *@return	String	The ME session ID
150:             */
151:            public String getSid() {
152:                return sid;
153:            }
154:
155:            /**
156:             *	Return the current session ID
157:             *
158:             *@param	String	The session ID
159:             */
160:            public void setSid(String sid) {
161:                this.sid = sid;
162:            }
163:
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.