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


001:        /*
002:         * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without
005:         * modification, are permitted provided that the following conditions
006:         * are met:
007:         *
008:         * - Redistributions of source code must retain the above copyright
009:         *   notice, this list of conditions and the following disclaimer.
010:         *
011:         * - Redistribution in binary form must reproduce the above copyright
012:         *   notice, this list of conditions and the following disclaimer in
013:         *   the documentation and/or other materials provided with the
014:         *   distribution.
015:         *
016:         * Neither the name of Sun Microsystems, Inc. or the names of
017:         * contributors may be used to endorse or promote products derived
018:         * from this software without specific prior written permission.
019:         *
020:         * This software is provided "AS IS," without a warranty of any
021:         * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
022:         * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
023:         * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
024:         * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
025:         * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
026:         * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
027:         * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
028:         * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
029:         * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
030:         * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
031:         * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
032:         *
033:         * You acknowledge that Software is not designed, licensed or intended
034:         * for use in the design, construction, operation or maintenance of
035:         * any nuclear facility.
036:         */
037:        package com.sun.portal.iwayutil.ssoadapterutils;
038:
039:        import java.util.*;
040:        import java.util.logging.*;
041:        import com.sun.ssoadapter.SSOAdapter;
042:        import com.sun.ssoadapter.SSOAdapterSession;
043:        import com.sun.ssoadapter.SSOAdapterException;
044:        import com.sun.ssoadapter.SSOAdapterFactory;
045:        import javax.servlet.http.HttpServletRequest;
046:        import com.sun.portal.iwayutil.logger.EAILogger;
047:
048:        /*
049:         * This class provides the utility methods
050:         * to Create/Edit/Delete SSOAdapter configurations
051:         */
052:        public class EAISSOAdapterConfigUtils implements  EAISSOAdapterConstants {
053:
054:            String configName = null;
055:            String userConfigName = null;
056:            String channelName = null;
057:            SSOAdapterFactory adapterFactory = null;
058:            Logger logger = null;
059:
060:            /** Creates a new instance of EAISSOAdapterConfigUtils */
061:            public EAISSOAdapterConfigUtils(String configName,
062:                    String channleName) {
063:                initialize(configName, channleName);
064:                this .adapterFactory = SSOAdapterFactory.getInstance();
065:            }
066:
067:            /*
068:             * This method reads the configuration file and
069:             * stores the configuration values in the property object.
070:             */
071:            private void initialize(String configName, String channleName) {
072:
073:                try {
074:                    this .configName = configName;
075:                    this .channelName = channleName;
076:                    logger = EAILogger.getLogger();
077:                    Properties ssoaProps = new Properties();
078:                    ssoaProps.put(SSO_ADAPTER_CONFIG_NAME, configName);
079:                    debug("initialize()", "configName : " + this .configName);
080:                    ssoaProps.put(CHANNEL_NAME, channleName);
081:                    debug("initialize()", "channelName : " + this .channelName);
082:                    this .userConfigName = configName + CHANNEL_NAME_SEPARATOR
083:                            + channelName;
084:                    debug("initialize()", "userConfigName : "
085:                            + this .userConfigName);
086:                } catch (Exception ex) {
087:                    debug("initialize()", "ex : " + ex);
088:                }
089:            }
090:
091:            /*
092:             * This method returns the ssoAdapter configuration.
093:             * First it tries to get the instance of the configuration.
094:             * If the instance is not found, returns the configuration
095:             * defined at the user level.
096:             */
097:            public SSOAdapter getSSOAdapter(HttpServletRequest httpReq) {
098:                SSOAdapter ssoAdapter = null;
099:                boolean foundUserConfig = false;
100:                boolean foundConfig = false;
101:                String name = null;
102:                try {
103:                    debug("getSSOAdapter()", "Getting Configuration Names");
104:                    SSOAdapterSession session = new SSOAdapterSession(httpReq);
105:                    Enumeration configNames = adapterFactory
106:                            .getConfigurationNames(session);
107:                    debug("getSSOAdapter()", "configNames : " + configNames);
108:
109:                    while (configNames.hasMoreElements()) {
110:                        name = (String) configNames.nextElement();
111:
112:                        if (name.equals(userConfigName)) {
113:                            foundUserConfig = true;
114:                            if (foundConfig)
115:                                break;
116:                        }
117:
118:                        if (name.equals(configName)) {
119:                            foundConfig = true;
120:                            if (foundUserConfig)
121:                                break;
122:                        }
123:                    }
124:                } catch (Exception ex) {
125:                    debug("getSSOAdapter()",
126:                            "Exception in Getting Configuration Names : " + ex);
127:                }
128:
129:                if (foundUserConfig) {
130:                    debug("getSSOAdapter()", "Getting SSOAdapterUserConfig");
131:                    try {
132:                        ssoAdapter = getSSOAdapterUserConfig(httpReq);
133:                    } catch (Exception ex) {
134:                        debug("getSSOAdapter()",
135:                                "Exception in Getting SSOAdapterUserConfig : "
136:                                        + ex);
137:                        ssoAdapter = null;
138:                    }
139:                } else if (foundConfig) {
140:
141:                    if (ssoAdapter == null) {
142:                        try {
143:                            debug("getSSOAdapter()", "Getting SSOAdapterConfig");
144:                            ssoAdapter = getSSOAdapterConfig(httpReq);
145:                        } catch (Exception ex) {
146:                            debug("getSSOAdapter()",
147:                                    "Exception in Getting SSOAdapterConfig : "
148:                                            + ex);
149:                            ssoAdapter = null;
150:                        }
151:                    }
152:                }
153:                return ssoAdapter;
154:            }
155:
156:            /*
157:             * This method returns the user level ssoAdapter configuration.
158:             */
159:            public SSOAdapter getSSOAdapterConfig(HttpServletRequest httpReq) {
160:                return getSSOAdapter(configName, httpReq);
161:            }
162:
163:            /*
164:             * This method returns the instance of ssoAdapter configuration.
165:             */
166:            public SSOAdapter getSSOAdapterUserConfig(HttpServletRequest httpReq) {
167:                return getSSOAdapter(userConfigName, httpReq);
168:            }
169:
170:            /*
171:             * This method returns a SSOAdapter specified by adapterName.
172:             */
173:            public SSOAdapter getSSOAdapter(String adapterName,
174:                    HttpServletRequest httpReq) {
175:                SSOAdapter ssoAdapter = null;
176:                try {
177:                    debug("getSSOAdapter()", "Getting Adapter Session");
178:                    SSOAdapterSession session = new SSOAdapterSession(httpReq);
179:                    debug("getSSOAdapter()", "Getting Adapter Config");
180:                    ssoAdapter = (SSOAdapter) adapterFactory.getSSOAdapter(
181:                            adapterName, session);
182:                } catch (Exception ex) {
183:                    debug("getSSOAdapter()", "EX : " + ex);
184:                }
185:                return ssoAdapter;
186:            }
187:
188:            /*
189:             * This method returns the attributes of the SSOAdapter configuration.
190:             */
191:            public Properties getSSOAdapterAttributes(HttpServletRequest httpReq) {
192:
193:                Properties attrs = null;
194:                debug("getSSOAdapterAttributes", "Initializing");
195:
196:                try {
197:                    SSOAdapter ssoAdapter = getSSOAdapter(httpReq);
198:                    if (ssoAdapter != null) {
199:                        debug("getSSOAdapterAttributes", "Getting Attributes");
200:                        attrs = ssoAdapter.getProperties();
201:                        debug("getSSOAdapterAttributes", "Got Attributes");
202:                    }
203:                } catch (Exception ex) {
204:                    debug("getSSOAdapterAttributes", "Exception : " + ex);
205:                    attrs = null;
206:                }
207:                return attrs;
208:            }
209:
210:            /*
211:             * This method sets the attributes of a SSOAdapter configuration and
212:             * returns the newly created SSOAdapter configuration.
213:             */
214:            public SSOAdapter setSSOAdapterAttributes(Properties attrs,
215:                    HttpServletRequest httpReq) {
216:
217:                SSOAdapter ssoAdapter = null;
218:                SSOAdapter newSSOAdapter = null;
219:                try {
220:                    SSOAdapterSession session = new SSOAdapterSession(httpReq);
221:                    //ssoAdapter = getSSOAdapter(httpReq);
222:                    ssoAdapter = getSSOAdapterConfig(httpReq);
223:                    attrs.put(CHANNEL_ATTR_NAME, channelName);
224:                    debug("setSSOAdapterAttributes", "setting props : ");
225:                    newSSOAdapter = adapterFactory.setSSOAdapter(ssoAdapter,
226:                            attrs, session);
227:                    Properties attr = newSSOAdapter.getProperties();
228:                    debug("setSSOAdapterAttributes", "set  props : ");
229:                } catch (Exception ex) {
230:                    debug("setSSOAdapterAttributes", "EX : " + ex);
231:                }
232:                return newSSOAdapter;
233:            }
234:
235:            /*
236:             * This method removes the instance of SSOAdapter configuration.
237:             */
238:            public void removeSSOAdapterAttributes(HttpServletRequest httpReq) {
239:
240:                try {
241:                    SSOAdapterSession session = new SSOAdapterSession(httpReq);
242:                    debug("removeSSOAdapterAttributes",
243:                            "Removing User Config : " + userConfigName);
244:                    adapterFactory.removeConfiguration(userConfigName, session);
245:                    debug("removeSSOAdapterAttributes",
246:                            "Removed User Config : ");
247:                } catch (Exception ex) {
248:                    debug("removeSSOAdapterAttributes", "EX : " + ex);
249:                }
250:            }
251:
252:            /*
253:             * This method logs the debug messages
254:             */
255:            private void debug(String methodName, String msg) {
256:                logger.log(Level.INFO,
257:                        "com.sun.portal.iwayutil.ssoadapterutils.EAISSOAdapterConfigUtils:"
258:                                + methodName + ":" + msg);
259:            }
260:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.