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


001:        /*
002:         * Copyright 2004 Sun Microsystems, Inc. All 
003:         * rights reserved. Use of this product is subject 
004:         * to license terms. Federal Acquisitions: 
005:         * Commercial Software -- Government Users 
006:         * Subject to Standard License Terms and 
007:         * Conditions. 
008:         * 
009:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE 
010:         * are trademarks or registered trademarks of Sun Microsystems, 
011:         * Inc. in the United States and other countries. 
012:         */
013:        package com.sun.portal.taskadmin.context;
014:
015:        import java.util.Iterator;
016:        import java.util.TreeSet;
017:        import java.util.Set;
018:        import java.util.Map;
019:
020:        import javax.servlet.http.HttpServletRequest;
021:        import javax.servlet.http.HttpServletResponse;
022:
023:        import com.sun.portal.taskadmin.TaskAdminException;
024:        import com.sun.portal.taskadmin.TaskAdminConstants;
025:
026:        import com.sun.portal.desktop.context.ContextError;
027:        import com.sun.portal.desktop.context.DPContext;
028:        import com.sun.portal.desktop.context.DSAMEAdminDPContext;
029:        import com.sun.portal.desktop.context.DSAMEConstants;
030:        import com.sun.portal.desktop.dp.DPError;
031:        import com.sun.portal.desktop.dp.xml.XMLDPFactory;
032:
033:        import com.iplanet.am.sdk.AMStoreConnection;
034:        import com.iplanet.am.sdk.AMObject;
035:        import com.iplanet.am.sdk.AMUser;
036:        import com.iplanet.am.sdk.AMException;
037:        import com.iplanet.am.sdk.AMConstants;
038:
039:        import com.sun.identity.sm.ServiceManager;
040:        import com.sun.identity.sm.ServiceSchema;
041:        import com.sun.identity.sm.ServiceSchemaManager;
042:        import com.sun.identity.sm.SMSException;
043:
044:        import com.iplanet.sso.SSOTokenManager;
045:        import com.iplanet.sso.SSOToken;
046:        import com.iplanet.sso.SSOException;
047:
048:        /**
049:         * This class provides the implementation for Desktop Content
050:         * Management
051:         */
052:
053:        public class TaskAdminISConnection {
054:            // lazy instantiation: use getXXX() to access
055:            private static SSOTokenManager _tokenMgr = null;
056:
057:            protected AMStoreConnection connection = null;
058:            protected String userDN = null;
059:            protected AMUser user = null;
060:            protected SSOToken ssoToken = null;
061:            protected String sid = null;
062:            protected ServiceManager serviceManager = null;
063:
064:            public TaskAdminISConnection(HttpServletRequest httpreq)
065:                    throws TaskAdminException {
066:                this (getSSOToken(httpreq));
067:            }
068:
069:            public TaskAdminISConnection(SSOToken token)
070:                    throws TaskAdminException {
071:                ssoToken = token;
072:                try {
073:                    connection = new AMStoreConnection(token);
074:                    ;
075:                    userDN = token.getPrincipal().toString();
076:                    user = connection.getUser(userDN);
077:                    initSessionID(token);
078:                    serviceManager = new ServiceManager(ssoToken);
079:                } catch (SMSException smse) {
080:                    throw new TaskAdminException(
081:                            "TaskAdminISConnection.init(): "
082:                                    + "Failed to get ServiceManager.  ", smse);
083:                } catch (SSOException se) {
084:                    // This means that SSOToken is invalid
085:                    throw new TaskAdminException(
086:                            "TaskAdminISConnection.init(): "
087:                                    + "Failed to get SSOToken.  ", se);
088:                }
089:            }
090:
091:            public AMStoreConnection getConnection() {
092:                return connection;
093:            }
094:
095:            public AMUser getUser() {
096:                return user;
097:            }
098:
099:            public static SSOToken getSSOToken(HttpServletRequest request)
100:                    throws TaskAdminException {
101:                SSOToken token = null;
102:                try {
103:                    token = getSSOTokenManager().createSSOToken(request);
104:                } catch (SSOException se) {
105:                    // This means that SSOToken is invalid
106:                    throw new TaskAdminException("TaskAdmin.getSSOToken(): "
107:                            + "Failed to get SSOToken.  ", se);
108:                }
109:                return token;
110:            }
111:
112:            public SSOToken getSSOToken() {
113:                return ssoToken;
114:            }
115:
116:            private static synchronized SSOTokenManager getSSOTokenManager()
117:                    throws TaskAdminException {
118:                if (_tokenMgr == null) {
119:                    try {
120:                        _tokenMgr = SSOTokenManager.getInstance();
121:                        if (_tokenMgr == null) {
122:                            throw new TaskAdminException(
123:                                    "TaskAdmin.getSSOTokenMgr(): "
124:                                            + "Failed to get SSOTokenManager. ");
125:                        }
126:                    } catch (SSOException se) {
127:                        throw new TaskAdminException(
128:                                "TaskAdmin.getSSOTokenMgr(): "
129:                                        + "Failed to get SSOTokenManager.  ",
130:                                se);
131:                    }
132:                }
133:
134:                return _tokenMgr;
135:            }
136:
137:            protected void initSessionID(SSOToken token) {
138:                this .sid = token.getTokenID().toString();
139:            }
140:
141:            public String getSessionID() {
142:                return sid;
143:            }
144:
145:            /**
146:             * Gets USER/DYNAMIC attribute.
147:             * @param attributeName Name of the attribute to retrieve
148:             * @return The attribute value in String format.  If property is
149:             * not not found, return null.  If DSAME returns multi-value,
150:             * warning is issued and only the first value is returned.
151:             */
152:            public String getAttribute(String attributeName) {
153:                String val = null;
154:                Set vals = getAttributeMultiVal(attributeName);
155:
156:                if (vals != null && vals.size() > 0) {
157:                    Iterator iter = vals.iterator();
158:                    val = (String) iter.next();
159:                }
160:
161:                return val;
162:            }
163:
164:            /**
165:             * Gets multi-valued USER/DYNAMIC attribute.
166:             * @param attributeName Name of the attribute to retrieve
167:             * @return Set of String values.  If property is
168:             * not not found, return null.
169:             */
170:            public Set getAttributeMultiVal(String attributeName) {
171:                Set vals = null;
172:
173:                try {
174:                    vals = user.getAttribute(attributeName);
175:                } catch (Exception e) {
176:                    throw new ContextError(
177:                            "TaskAdminISConnection.getAttributeMultiVal(): "
178:                                    + "attributeName=" + attributeName, e);
179:                }
180:                return vals;
181:            }
182:
183:            public String getGlobalAttribute(String serviceName,
184:                    String attributeName) {
185:                Set vals = getGlobalAttributeMultiValue(serviceName,
186:                        attributeName);
187:                if (vals == null || vals.size() < 1) {
188:                    return null;
189:                }
190:
191:                Iterator iter = vals.iterator();
192:                String val = (String) iter.next();
193:
194:                return val;
195:            }
196:
197:            public Set getGlobalAttributeMultiValue(String serviceName,
198:                    String attributeName) {
199:                Map attrs = getGlobalAttributes(serviceName);
200:                Set vals = (Set) attrs.get(attributeName);
201:                return vals;
202:            }
203:
204:            public Map getGlobalAttributes(String serviceName) {
205:                Map attrs = null;
206:
207:                try {
208:                    ServiceSchemaManager schemaMgr = serviceManager
209:                            .getSchemaManager(serviceName, "1.0");
210:                    ServiceSchema schema = schemaMgr.getGlobalSchema();
211:                    attrs = schema.getReadOnlyAttributeDefaults();
212:                } catch (Exception ex) {
213:                    throw new ContextError(
214:                            "TaskAdminISConnection.getGlobalAttributes(): "
215:                                    + serviceName, ex);
216:                }
217:
218:                return attrs;
219:            }
220:
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.