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


001:        /**
002:         * $Id: SSOAdapterSession.java,v 1.5 2005/08/24 16:57:06 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;
014:
015:        import java.util.Locale;
016:        import java.util.List;
017:        import java.util.Properties;
018:        import java.security.Principal;
019:        import com.iplanet.sso.SSOToken;
020:        import com.iplanet.sso.SSOTokenManager;
021:        import com.iplanet.sso.SSOTokenListener;
022:        import com.iplanet.sso.SSOTokenEvent;
023:        import com.iplanet.sso.SSOException;
024:        import com.iplanet.am.util.AMClientDetector;
025:
026:        import javax.servlet.http.HttpServletRequest;
027:
028:        /**
029:         * This class is a wrapper for SSOToken and other inputs to the SSOAdapter.
030:         * @version 1.0
031:         * @see com.sun.ssoadapter.SSOAdapterFactory
032:         * @see com.sun.ssoadapter.SSOAdapterException
033:         */
034:
035:        public class SSOAdapterSession {
036:            /**
037:             * The SSOToken reqd for the session .
038:             */
039:            private SSOToken token;
040:            /**
041:             * the clientType as String
042:             */
043:            private String clientType;
044:            /**
045:             * locale to get localized error message
046:             */
047:            private Locale locale;
048:            /**
049:             * Incase of authless ( where SSOToken is not valid ) pass the authlessUId
050:             */
051:            private String authlessUid;
052:            /**
053:             * the instanceName with which you want to dealwith
054:             */
055:            private String instanceName;
056:
057:            /**
058:             * clientDetector
059:             */
060:            private static AMClientDetector cd = new AMClientDetector();
061:            /**
062:             * Token Manger
063:             */
064:            private static SSOTokenManager tokenMgr = null;
065:
066:            /**
067:             * the SSOToken is stored in the httpRequest
068:             */
069:            private static final String SSO_TOKEN = "ps.session";
070:
071:            /**
072:             * The Constructor
073:             * @param tokenParam SSOToken 
074:             * @param clientTypeParam the clientType
075:             * @param localeParam locale
076:             * @param authlessUidParam the authlessUID
077:             * @param instanceNameParam instanceName
078:             */
079:            public SSOAdapterSession(SSOToken tokenParam,
080:                    String clientTypeParam, Locale localeParam,
081:                    String authlessUidParam, String instanceNameParam) {
082:                this .token = tokenParam;
083:                this .clientType = clientTypeParam;
084:                this .locale = localeParam;
085:                this .authlessUid = authlessUidParam;
086:                this .instanceName = instanceNameParam;
087:            }
088:
089:            /**
090:             * An Constructor with HttpServletRequest
091:             * @param requestParam 
092:             * @param localeParam 
093:             * @param authlessUidParam 
094:             * @param instanceNameParam 
095:             */
096:            public SSOAdapterSession(HttpServletRequest requestParam,
097:                    Locale localeParam, String authlessUidParam,
098:                    String instanceNameParam) {
099:                this (getSSOToken(requestParam), getClientType(requestParam),
100:                        localeParam, authlessUidParam, instanceNameParam);
101:            }
102:
103:            /**
104:             * An Constructor with HttpServletRequest
105:             * @param requestParam 
106:             */
107:            public SSOAdapterSession(HttpServletRequest requestParam) {
108:                this (requestParam, null, null, null);
109:            }
110:
111:            /**
112:             * An Constructor with SSOToken
113:             * @param tokenParam 
114:             */
115:            public SSOAdapterSession(SSOToken tokenParam) {
116:                this (tokenParam, null, null, null, null);
117:            }
118:
119:            /**
120:             * 
121:             * @return SSOToken 
122:             */
123:            public SSOToken getSSOToken() {
124:                return token;
125:            }
126:
127:            /**
128:             * 
129:             * @return clientType 
130:             */
131:            public String getClientType() {
132:                return clientType;
133:            }
134:
135:            /**
136:             * 
137:             * @return the authlessUID if provided
138:             */
139:            public String getAuthlessUID() {
140:                return authlessUid;
141:            }
142:
143:            /**
144:             * 
145:             * @return the instanceName if provided
146:             */
147:            public String getInstanceName() {
148:                return instanceName;
149:            }
150:
151:            /**
152:             * 
153:             * @return checks if session is Valid
154:             */
155:            public boolean isSessionValid() {
156:                boolean isValid = false;
157:                if (token != null && getSSOTokenManager().isValidToken(token)) {
158:                    String uid = getUserID();
159:                    if (uid != null) {
160:                        isValid = true;
161:                    }
162:                }
163:                return isValid;
164:            }
165:
166:            /**
167:             * 
168:             * @return gets theUserId from SSOToken if possible
169:             */
170:            private String getUserID() {
171:                Principal p = null;
172:                try {
173:                    if (token == null) {
174:                        return null;
175:                    }
176:                    p = token.getPrincipal();
177:                } catch (SSOException ssoe) {
178:                    return null;
179:                }
180:                return p.toString();
181:            }
182:
183:            /**
184:             * 
185:             * @return gets the SSOToken as String
186:             */
187:            public String getSessionID() {
188:                String tokenID = null;
189:                if (token != null) {
190:                    tokenID = token.getTokenID().toString();
191:                }
192:                return tokenID;
193:            }
194:
195:            /**
196:             * 
197:             * @return locale
198:             */
199:            public Locale getLocale() {
200:                return locale;
201:            }
202:
203:            /**
204:             * 
205:             * @param listner 
206:             * @throws com.iplanet.sso.SSOException 
207:             */
208:            public void addSSOTokenListener(SSOTokenListener listner)
209:                    throws SSOException {
210:                if (token != null)
211:                    token.addSSOTokenListener(listner);
212:            }
213:
214:            /**
215:             * 
216:             * @param request 
217:             * @return clientType
218:             */
219:            public static String getClientType(HttpServletRequest request) {
220:                return cd.getClientType(request);
221:            }
222:
223:            /**
224:             * 
225:             * @return the SSOTokenManager
226:             */
227:            public static SSOTokenManager getSSOTokenManager() {
228:                if (tokenMgr != null)
229:                    return tokenMgr;
230:                try {
231:                    tokenMgr = SSOTokenManager.getInstance();
232:                } catch (SSOException ex) {
233:                    throw new IllegalStateException(
234:                            "SSOAdapterSession.getSSOTokenManager():Failed to get SSOTokenManager.getInstance().  "
235:                                    + ex);
236:
237:                }
238:
239:                return tokenMgr;
240:            }
241:
242:            /**
243:             * 
244:             * @param request 
245:             * @return SSOToken : gets the SSOToken from the HttpServletRequest
246:             */
247:            public static SSOToken getSSOToken(HttpServletRequest request) {
248:                //
249:                // try to get the token from the request. this saves
250:                // us creating >1 sso tokens for multiple
251:                // per-request calls into this api
252:                //
253:                SSOToken token = (SSOToken) request.getAttribute(SSO_TOKEN);
254:                if (token == null) {
255:                    try {
256:                        token = getSSOTokenManager().createSSOToken(request);
257:                        //
258:                        // put the token into the request, so multiple calls
259:                        // into this api per request can use this value
260:                        //
261:                        request.setAttribute(SSO_TOKEN, token);
262:                    } catch (SSOException se) {
263:                        // This means that SSOToken is invalid
264:                        //
265:                        token = null;
266:                    }
267:                }
268:
269:                return token;
270:            }
271:
272:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.