Source Code Cross Referenced for DSAMEServiceContext.java in  » Portal » Open-Portal » com » sun » portal » desktop » context » 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.desktop.context 
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.portal.desktop.context;
006:
007:        import com.iplanet.am.util.Locale;
008:        import com.iplanet.am.util.SystemProperties;
009:        import com.sun.liberty.LibertyManager;
010:        import com.sun.portal.desktop.ROC;
011:        import com.sun.portal.desktop.RequestThreadLocalizer;
012:        import com.sun.portal.log.common.PortalLogger;
013:
014:        import javax.servlet.http.HttpServletRequest;
015:        import java.util.HashSet;
016:        import java.util.Set;
017:        import java.util.logging.Level;
018:        import java.util.logging.Logger;
019:
020:        import com.iplanet.sso.SSOToken;
021:
022:        public class DSAMEServiceContext implements  ServiceContext,
023:                DSAMEConstants {
024:            private static Set prefetchAttrs = new HashSet();
025:            private static DSAMEMultiPortalConstants dmpc = DSAMEMultiPortalConstants
026:                    .getInstance();
027:
028:            static {
029:                prefetchAttrs.add(dmpc.MP_ATTR_DEFAULTCHANNELNAME);
030:                prefetchAttrs.add(dmpc.MP_ATTR_EDITPROVIDERCONTAINERNAME);
031:                prefetchAttrs.add(dmpc.MP_ATTR_DESKTOP_TYPE);
032:                prefetchAttrs.add(ATTR_LOCALE);
033:                //prefetchAttrs.add(ATTR_EXECUTABLE);
034:                prefetchAttrs.add(dmpc.MP_ATTR_DP_DOCUMENT_USER);
035:                prefetchAttrs.add(dmpc.MP_ATTR_DP_LAST_MODIFIED_USER);
036:            }
037:
038:            protected DSAMEConnection dsameConn = null;
039:            protected static final String defaultLocaleString = java.util.Locale
040:                    .getDefault().toString();
041:            protected static final String LOCALE_STRING = "localeString";
042:            protected static String serverProtocol = SystemProperties
043:                    .get(AM_SERVER_PROTOCOL);
044:            protected static String serverPort = SystemProperties
045:                    .get(AM_SERVER_PORT);
046:            protected static String serverHost = SystemProperties
047:                    .get(AM_SERVER_HOST);
048:            protected static String serverURL = serverProtocol + "://"
049:                    + serverHost + ":" + serverPort;
050:            private static Logger logger = PortalLogger
051:                    .getLogger(DSAMEServiceContext.class);
052:
053:            public DSAMEServiceContext() {
054:            }
055:
056:            public void init(SSOToken ssoToken) {
057:                dsameConn = new DSAMEConnection(ssoToken);
058:                dsameConn.prefetchAttributes(prefetchAttrs);
059:            }
060:
061:            public void init(HttpServletRequest req) {
062:                dsameConn = new DSAMEConnection(req);
063:                dsameConn.prefetchAttributes(prefetchAttrs);
064:            }
065:
066:            public void init(HttpServletRequest req, String uid, String pw) {
067:                dsameConn = new DSAMEConnection(uid, pw);
068:                dsameConn.prefetchAttributes(prefetchAttrs);
069:            }
070:
071:            public String getLocaleString() {
072:                String localeString = null;
073:
074:                if (ROC.containsObject(LOCALE_STRING)) {
075:                    localeString = (String) ROC.getObject(LOCALE_STRING);
076:                } else {
077:                    localeString = dsameConn.getAttributeFromROC(ATTR_LOCALE);
078:                    if (localeString == null) {
079:                        // Obtain accept-language locale
080:                        localeString = Locale
081:                                .getLocaleStringFromAcceptLangHeader(RequestThreadLocalizer
082:                                        .getRequest().getHeader(
083:                                                "accept-language"));
084:                    }
085:                    if (localeString == null) {
086:                        // Assign the org level locale
087:                        localeString = dsameConn.getOrgAttributeFromROC(
088:                                DSAME_AUTH_SERVICE, ATTR_AUTHLOCALE);
089:                    }
090:                    if (localeString == null) {
091:                        // Default locale
092:                        localeString = defaultLocaleString;
093:                    }
094:                    ROC.setObject(LOCALE_STRING, localeString);
095:                }
096:                return localeString;
097:            }
098:
099:            public String getDesktopType() {
100:                return dsameConn.getAttributeFromROC(dmpc.MP_ATTR_DESKTOP_TYPE);
101:            }
102:
103:            public String getDefaultChannelName() {
104:                return dsameConn
105:                        .getAttributeFromROC(dmpc.MP_ATTR_DEFAULTCHANNELNAME);
106:            }
107:
108:            public String getEditProviderContainerName() {
109:                return dsameConn
110:                        .getAttributeFromROC(dmpc.MP_ATTR_EDITPROVIDERCONTAINERNAME);
111:            }
112:
113:            public String getDPContextClassName() {
114:                return dsameConn.getGlobalAttributeFromROC(
115:                        dmpc.MP_SUN_DESKTOP_SERVICE, ATTR_DPCONTEXTCLASSNAME);
116:            }
117:
118:            public String getDPUserContextClassName() {
119:                return dsameConn.getGlobalAttributeFromROC(
120:                        dmpc.MP_SUN_DESKTOP_SERVICE,
121:                        ATTR_DPUSERCONTEXTCLASSNAME);
122:            }
123:
124:            public String getContainerProviderContextClassName() {
125:                return dsameConn.getGlobalAttributeFromROC(
126:                        dmpc.MP_SUN_DESKTOP_SERVICE,
127:                        ATTR_CONTAINERPROVIDERCONTEXTCLASSNAME);
128:            }
129:
130:            public String getProviderManagerContextClassName() {
131:                return dsameConn.getGlobalAttributeFromROC(
132:                        dmpc.MP_SUN_DESKTOP_SERVICE,
133:                        ATTR_PROVIDERMANAGERCONTEXTCLASSNAME);
134:            }
135:
136:            public String getPropertiesContextClassName() {
137:                return dsameConn.getGlobalAttributeFromROC(
138:                        dmpc.MP_SUN_DESKTOP_SERVICE,
139:                        ATTR_PROPERTIESCONTEXTCLASSNAME);
140:            }
141:
142:            public String getTemplateContextClassName() {
143:                return dsameConn.getGlobalAttributeFromROC(
144:                        dmpc.MP_SUN_DESKTOP_SERVICE,
145:                        ATTR_TEMPLATECONTEXTCLASSNAME);
146:            }
147:
148:            public String getClientContextClassName() {
149:                return dsameConn.getGlobalAttributeFromROC(
150:                        dmpc.MP_SUN_DESKTOP_SERVICE,
151:                        ATTR_CLIENTCONTEXTCLASSNAME);
152:            }
153:
154:            static boolean toBoolean(String name) {
155:                return ((name != null) && name.toLowerCase().equals("true"));
156:            }
157:
158:            public String getLogoutURL() {
159:                Boolean federationEnabled = Boolean.valueOf(dsameConn
160:                        .getGlobalAttributeFromROC(dmpc.MP_SUN_DESKTOP_SERVICE,
161:                                ATTR_ENABLE_FEDERATION));
162:                StringBuffer logoutURLBuff = new StringBuffer(serverURL);
163:
164:                if (federationEnabled.booleanValue()) {
165:                    String providerID = dsameConn.getGlobalAttributeFromROC(
166:                            dmpc.MP_SUN_DESKTOP_SERVICE,
167:                            ATTR_HOSTED_PROVIDER_ID);
168:                    String metaAlias = null;
169:                    if (providerID != null && providerID.length() != 0) {
170:                        try {
171:                            metaAlias = LibertyManager.getMetaAlias(providerID);
172:                        } catch (Exception e) {
173:                            logger.log(Level.INFO, "PSDT_CSPDC0034", e);
174:                            metaAlias = null;
175:                            //'misconfig' block will take care of this situation
176:                        }
177:                    }
178:                    if (providerID == null || providerID.length() == 0
179:                            || metaAlias == null || metaAlias.length() == 0) {
180:                        /* This is misconfiguration. So return the local logout url,
181:                         * because if liberty has been misconfigured, then it is 
182:                         * unlikely that the user is liberty signed-on.
183:                         */
184:                        return dsameConn.getGlobalAttributeFromROC(
185:                                DSAME_PLATFORM_SERVICE, ATTR_LOGOUTURL);
186:                    }
187:                    logoutURLBuff.append(
188:                            SystemProperties.get(DEPLOYMENT_DESCRIPTOR_KEY))
189:                            .append("/").append(LIBERTY_LOGOUT_PAGE_NAME)
190:                            .append("?").append(
191:                                    LibertyManager.getMetaAliasKey()).append(
192:                                    "=").append(metaAlias);
193:                    return logoutURLBuff.toString();
194:                } else {
195:                    String attrLogoutURL = dsameConn.getGlobalAttributeFromROC(
196:                            DSAME_PLATFORM_SERVICE, ATTR_LOGOUTURL);
197:                    if (attrLogoutURL != null) {
198:                        if (attrLogoutURL.indexOf("://") != -1) {
199:                            // If the URL in attribute is a complete URL
200:                            return attrLogoutURL;
201:                        } else {
202:                            // If URL in attribute is partial URL append to serverURL 
203:                            return logoutURLBuff.append(attrLogoutURL)
204:                                    .toString();
205:                        }
206:                    }
207:                    // Logout URL in attribute is null not much can be done
208:                    return null;
209:                }
210:            }
211:
212:            public String getLoginURL() {
213:                String attrLoginURL = dsameConn.getGlobalAttributeFromROC(
214:                        DSAME_PLATFORM_SERVICE, ATTR_LOGINURL);
215:                if (attrLoginURL != null) {
216:                    if (attrLoginURL.indexOf("://") != -1) {
217:                        // If the URL in attribute is a complete URL
218:                        return attrLoginURL;
219:                    } else {
220:                        // If URL in attribute is partial URL append to serverURL
221:                        StringBuffer loginURLBuff = new StringBuffer(serverURL);
222:                        return loginURLBuff.append(attrLoginURL).toString();
223:                    }
224:                }
225:                // Logout URL in attribute is null not much can be done
226:                return null;
227:            }
228:
229:            public String getDebugContextClassName() {
230:                return dsameConn
231:                        .getGlobalAttributeFromROC(dmpc.MP_SUN_DESKTOP_SERVICE,
232:                                ATTR_DEBUGCONTEXTCLASSNAME);
233:            }
234:
235:            public String getSessionContextClassName() {
236:                return dsameConn.getGlobalAttributeFromROC(
237:                        dmpc.MP_SUN_DESKTOP_SERVICE,
238:                        ATTR_SESSIONCONTEXTCLASSNAME);
239:            }
240:
241:            public String getAuthlessSessionContextClassName() {
242:                return dsameConn.getGlobalAttributeFromROC(
243:                        dmpc.MP_SUN_DESKTOP_SERVICE,
244:                        ATTR_AUTHLESSSESSIONCONTEXTCLASSNAME);
245:            }
246:
247:            public String getWSRPSessionContextClassName() {
248:                return dsameConn.getGlobalAttributeFromROC(
249:                        dmpc.MP_SUN_DESKTOP_SERVICE,
250:                        ATTR_WSRPSESSIONCONTEXTCLASSNAME);
251:            }
252:
253:            public String getStringAttribute(String name) {
254:                return dsameConn.getAttributeFromROC(name);
255:            }
256:
257:            public void setStringAttribute(String name, String val) {
258:                dsameConn.setAttribute(name, val);
259:            }
260:
261:            public String getStringAttribute(String name,
262:                    java.util.Locale locale) {
263:                String lang = locale.getLanguage().toLowerCase();
264:                String country = locale.getCountry().toLowerCase();
265:                String val = null;
266:
267:                if (country != null && country.length() > 0) {
268:                    val = getStringAttribute(name + ";lang-" + lang + "-"
269:                            + country);
270:                }
271:
272:                if ((val == null) || (val.length() == 0)) {
273:                    val = getStringAttribute(name + ";lang-" + lang);
274:                    if ((val == null) || (val.length() == 0)) {
275:                        val = getStringAttribute(name);
276:                    }
277:                }
278:                return val;
279:            }
280:
281:            public Set getRoles() {
282:                //return dsameConn.getRoleDNs();
283:                return dsameConn.getRoleDNsFromROC();
284:            }
285:
286:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.