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


001:        package com.sun.portal.proxylet.servlet;
002:
003:        import com.iplanet.am.util.AMClientDetector;
004:        import com.iplanet.am.util.SystemProperties;
005:        import com.iplanet.services.cdm.Client;
006:        import com.iplanet.services.cdm.ClientException;
007:        import com.iplanet.sso.*;
008:        import com.sun.portal.proxylet.util.ProxyletConstants;
009:        import com.sun.identity.sm.ServiceManager;
010:        import com.sun.identity.sm.ServiceSchema;
011:        import com.sun.identity.sm.ServiceSchemaManager;
012:        import com.sun.identity.sm.SMSException;
013:
014:        import java.util.logging.Logger;
015:        import java.util.*;
016:        import java.net.*;
017:        import javax.servlet.http.*;
018:
019:        public class ClientInfo {
020:            HttpServletRequest req;
021:
022:            private com.sun.portal.proxylet.servlet.UserAttributes userAttrs = null;
023:            private String HTMLcharsetname = null;
024:            private String enc = null;
025:            private String bindIP = null;
026:            private String bindPort = null;
027:            private String pacLocation = null;
028:            private ResourceBundle appletBundle = null;
029:            private SSOToken ssoToken = null;
030:            private ServiceManager serviceManager;
031:            private static Logger logger;
032:
033:            public Map globalattrs_1;
034:
035:            public static void setLogger(Logger l) {
036:                logger = l;
037:            }
038:
039:            public String getPlatformLoginURL() {
040:                return platformLoginURL;
041:            }
042:
043:            public int getSessionIdleTimeout() {
044:                return sessionIdleTimeout;
045:            }
046:
047:            private String platformLoginURL = null;
048:            private int sessionIdleTimeout;
049:
050:            public ClientInfo(HttpServletRequest req) throws Exception {
051:                this .req = req;
052:                readUserPreferences();
053:            }
054:
055:            public SSOToken getSSOToken() {
056:                return ssoToken;
057:            }
058:
059:            public void readUserPreferences() throws Exception {
060:                logger.info("readUserPreferences function");
061:                ssoToken = createSSOToken();
062:                if (ssoToken == null) {
063:                    throw new SSOException("Can't get ssoToken");
064:                }
065:
066:                String ATTRIBUTE_PREFIX = "iplanet-am-platform-";
067:                String SERVICE_NAME = "iPlanetAMPlatformService";
068:
069:                serviceManager = new ServiceManager(ssoToken);
070:
071:                Map globalattrs = getGlobalAttributes(SERVICE_NAME, ssoToken);
072:
073:                // retrive platform config URL iplanet-am-platform-login-url
074:                platformLoginURL = AttributeExtractor.getString(globalattrs,
075:                        ATTRIBUTE_PREFIX + "login-url", null);
076:
077:                ATTRIBUTE_PREFIX = "iplanet-am-session-";
078:                SERVICE_NAME = "iPlanetAMSessionService";
079:                globalattrs_1 = getDynamicAttributes(SERVICE_NAME, ssoToken);
080:
081:                // retrive session timeout iplanet-am-session-max-idle-time
082:                sessionIdleTimeout = AttributeExtractor.getInt(globalattrs_1,
083:                        ATTRIBUTE_PREFIX + "max-idle-time", 0);
084:
085:                String c_applet_res_bundle = "srapProxyletApplet";
086:
087:                userAttrs = new com.sun.portal.proxylet.servlet.UserAttributes(
088:                        ssoToken, "iplanet-am-user-");
089:                enc = ssoToken.getProperty("Locale");
090:                appletBundle = ResourceBundle.getBundle(c_applet_res_bundle,
091:                        com.iplanet.am.util.Locale.getLocale(enc));
092:
093:                HTMLcharsetname = findHTMLCharset();
094:
095:                logger.info("User Attributes read");
096:                com.sun.portal.proxylet.util.UserAttributes attrs = new com.sun.portal.proxylet.util.UserAttributes(
097:                        ssoToken, ProxyletConstants.PROXYLET_SERVICE_NAME,
098:                        ProxyletConstants.PROXYLET_POLICY);
099:                if (attrs.isServiceAssigned() == false) {
100:                    logger.info("is service assigned false ");
101:                    throw new Exception("noPrivilege");
102:                }
103:                bindIP = attrs
104:                        .getString(ProxyletConstants.PROXYLET_CLIENT_BIND_IP);
105:                bindPort = attrs
106:                        .getString(ProxyletConstants.PROXYLET_CLIENT_BIND_PORT);
107:                pacLocation = attrs
108:                        .getString(ProxyletConstants.PROXYLET_PACFILE_LOCATION);
109:            }
110:
111:            public ResourceBundle getCustomizedLocale(String localefile) {
112:                ResourceBundle appBundle = ResourceBundle.getBundle(localefile,
113:                        com.iplanet.am.util.Locale.getLocale(enc));
114:                return appBundle;
115:            }
116:
117:            /*
118:             * Obtains the global service attributes given a service name.
119:             *
120:             * If service name is null or zero length, then null is returned.
121:             * In the event of an AMException, null is returned.
122:             *
123:             * @param szServiceName java.lang.String - name of the service
124:             *
125:             * @return java.util.Map - Global service attributes or null if an
126:             * exception has occured
127:             */
128:            private Map getGlobalAttributes(String szServiceName, SSOToken token) {
129:
130:                Map attrs = null;
131:
132:                if ((szServiceName == null) || (szServiceName.length() == 0))
133:                    return null;
134:
135:                try {
136:                    ServiceSchemaManager schemaMgr = new ServiceSchemaManager(
137:                            szServiceName, token);
138:                    ServiceSchema schema = schemaMgr.getGlobalSchema();
139:                    attrs = schema.getAttributeDefaults();
140:                    schema = null;
141:                } catch (SMSException smse) {
142:
143:                } catch (SSOException ssoe) {
144:
145:                }
146:                return attrs;
147:            }
148:
149:            private Map getDynamicAttributes(String szServiceName,
150:                    SSOToken token) {
151:
152:                Map attrs = null;
153:
154:                if ((szServiceName == null) || (szServiceName.length() == 0))
155:                    return null;
156:
157:                try {
158:                    ServiceSchemaManager schemaMgr = new ServiceSchemaManager(
159:                            szServiceName, token);
160:                    ServiceSchema schema = schemaMgr.getDynamicSchema();
161:                    attrs = schema.getAttributeDefaults();
162:                    schema = null;
163:                } catch (SMSException smse) {
164:
165:                } catch (SSOException ssoe) {
166:
167:                }
168:                return attrs;
169:            }
170:
171:            /**
172:             * Update session to indicate presence of proxylet
173:             * This will be used by the gateway to determine whether to rewrite or not
174:             */
175:
176:            public void updateSession(String key, String value) {
177:                //ssoToken.setProperty(key, value);
178:            }
179:
180:            public String getBindIP() {
181:                return bindIP;
182:            }
183:
184:            public String getBindPort() {
185:                return bindPort;
186:            }
187:
188:            public String getPacLocation() {
189:                return pacLocation;
190:            }
191:
192:            public String getHTMLcharsetname() {
193:                return HTMLcharsetname;
194:            }
195:
196:            public ResourceBundle getAppletBundle() {
197:                return appletBundle;
198:            }
199:
200:            public String getLocale() {
201:                return enc;
202:            }
203:
204:            public String findHTMLCharset() {
205:                AMClientDetector amCD = new AMClientDetector();
206:                String clientType = amCD.getClientType(req);
207:                String HTMLcharset = null;
208:
209:                try {
210:                    Client clientObj = Client.getInstance(clientType);
211:                    HTMLcharset = clientObj
212:                            .getCharset(com.iplanet.am.util.Locale
213:                                    .getLocale(getLocale()));
214:                } catch (ClientException ce) {
215:                    HTMLcharset = "ISO-8859-1";
216:
217:                }
218:                return HTMLcharset;
219:            }
220:
221:            private SSOToken createSSOToken() {
222:                SSOToken token = null;
223:                String cookieName = SystemProperties.get(
224:                        "com.iplanet.am.cookie.name", "iPlanetDirectoryPro");
225:                Cookie[] cks = req.getCookies();
226:
227:                if (cks != null) {
228:                    for (int i = 0; i < cks.length; i++) {
229:                        String cName = cks[i].getName();
230:                        if (cName != null && cName.equals(cookieName)) {
231:                            String sessID = cks[i].getValue();
232:                            try {
233:                                token = SSOTokenManager.getInstance()
234:                                        .createSSOToken(sessID);
235:                            } catch (SSOException ssoe) {
236:                                try {
237:                                    token = SSOTokenManager.getInstance()
238:                                            .createSSOToken(
239:                                                    URLDecoder.decode(sessID));
240:                                } catch (SSOException ssoe2) {
241:                                }
242:                            }
243:                            break;
244:                        }
245:                    }
246:                }
247:                return token;
248:            }
249:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.