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


001:        /**
002:         * $Id: SSOAObjectSearchBean.java,v 1.2 2005/09/21 15:29:58 fo160993 Exp $
003:         * Copyright 2005 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 Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.admin.console.ssoa;
014:
015:        import java.util.*;
016:        import java.util.logging.Level;
017:
018:        import java.io.IOException;
019:
020:        //JMX
021:        import javax.management.MBeanServerConnection;
022:        import javax.management.ObjectName;
023:        import javax.management.MBeanException;
024:        import javax.management.ReflectionException;
025:        import javax.management.MalformedObjectNameException;
026:        import javax.management.InstanceNotFoundException;
027:
028:        //JSF
029:        import javax.faces.validator.Validator;
030:        import javax.faces.validator.ValidatorException;
031:        import javax.faces.context.FacesContext;
032:        import javax.faces.el.VariableResolver;
033:        import javax.faces.component.UIComponent;
034:        import javax.faces.application.FacesMessage;
035:        import javax.faces.event.ActionEvent;
036:        import javax.faces.event.ValueChangeListener;
037:        import javax.faces.event.ValueChangeEvent;
038:
039:        import com.sun.web.ui.model.Option;
040:
041:        import com.sun.portal.admin.common.PSMBeanException;
042:        import com.sun.portal.admin.common.util.AdminClientUtil;
043:
044:        import com.sun.portal.admin.console.common.PSBaseBean;
045:
046:        /**
047:         * Most stolen from AMObjectSearchBean
048:         */
049:        public class SSOAObjectSearchBean extends PSBaseBean implements 
050:                ValueChangeListener {
051:
052:            // public static final String ATTR_LOCATION_DNs = "common.locationdn.list";
053:            private Option[] locationDNs = null;
054:            private Object newLocationDN = "";
055:            //private static final String GLOBAL_LABEL = "TopLevel";
056:            private String globalLabel = null;
057:            private String defaultOrg = null;
058:
059:            protected ObjectName objectName = null;
060:            public static final String RB_NAME = "ssoa";
061:            protected Map rbMap;
062:
063:            public SSOAObjectSearchBean() {
064:                //defaultOrg = getDefaultOrgDN();
065:                //Object currentDN = "o=DeveloperSample," + defaultOrg;
066:                //if (getSessionAttribute(ATTR_LOCATION_DNs) == null) {
067:                //    setSessionAttribute(ATTR_LOCATION_DNs, getBookmarkDNs());
068:                //}
069:                rbMap = getResourceStringMap(RB_NAME);
070:                globalLabel = (String) rbMap.get("ssoa.global.dn.label");
071:                if (getSessionAttribute(ATTR_CURRENT_LOCATION_DN) == null) {
072:                    setSessionAttribute(ATTR_CURRENT_LOCATION_DN,
073:                            GLOBAL_LOCATION_DN);
074:                }
075:                // MBean path of SSOAdapter.
076:                LinkedList path = new LinkedList();
077:                path.addFirst(getDomain());
078:                path.addFirst("ssoadapter");
079:
080:                try {
081:                    objectName = AdminClientUtil.getResourceMBeanObjectName(
082:                            AdminClientUtil.SSOADAPTER_MBEAN_TYPE, path);
083:                } catch (MalformedObjectNameException e) {
084:                    log(
085:                            Level.SEVERE,
086:                            "SSOAObjectSearchBean.SSOAObjectSearchBean(): Exception when getting MBean object name",
087:                            e);
088:                }
089:            }
090:
091:            // Get all orgs and roles that have an SSO Configuration defined
092:            public Option[] getLocationDNs() {
093:                log(Level.FINEST, "Start getLocationDNs");
094:                //Map bookmarks = (Map)getSessionAttribute(ATTR_LOCATION_DNs);
095:                MBeanServerConnection conn = getMBeanServerConnection();
096:                List locationDNsList = null;
097:                try {
098:                    // This can throw AttributeNotFoundException, MBeanException, InstanceNotFoundException
099:                    // ReflectionException, RuntimeOperationsException, or IOException
100:                    locationDNsList = (List) conn.getAttribute(objectName,
101:                            "DnsWithConfigurations");
102:                } catch (Exception ex) {
103:                    log(
104:                            Level.SEVERE,
105:                            "SSOAObjectSearchBean.getLocationDNs(): Exception when trying to get the list of dns with configurations",
106:                            ex);
107:                }
108:                locationDNs = new Option[locationDNsList.size() + 1];
109:                locationDNs[0] = new Option(GLOBAL_LOCATION_DN, globalLabel);
110:                int j = 1;
111:                for (Iterator i = locationDNsList.iterator(); i.hasNext(); j++) {
112:                    String dn = (String) i.next();
113:                    //String label = (String)bookmarks.get(dn);
114:                    //locationDNs[j] = new Option(dn, label);
115:                    locationDNs[j] = new Option(dn, dn);
116:                }
117:                return locationDNs;
118:            }
119:
120:            public Object getCurrentLocationDN() {
121:                log(Level.FINEST, "Start getCurrentLocationDN");
122:                log(Level.FINEST, "getCurrentDN = " + getCurrentDN());
123:
124:                return getCurrentDN();
125:            }
126:
127:            public Object getNewLocationDN() {
128:                return newLocationDN;
129:            }
130:
131:            // This is supposed to add the service template to the new DN
132:            // Vetod for now, changing to a search task
133:            public void setNewLocationDN(Object newLocationDN) {
134:                /*if ( !this.newLocationDN.equals(newLocationDN) && !newLocationDN.equals("")) {
135:                    this.newLocationDN = newLocationDN;
136:                    if ( !newLocationDN.equals("") ) {
137:                        HashMap bookmarks = (HashMap)getSessionAttribute(ATTR_LOCATION_DNs);
138:                        if ( newLocationDN.equals(GLOBAL_LOCATION_DN)) {
139:                            bookmarks.put(newLocationDN, GLOBAL_LABEL);
140:                        } else {
141:                            bookmarks.put(newLocationDN, newLocationDN);
142:                        }
143:                        setSessionAttribute(ATTR_LOCATION_DNs, bookmarks);
144:                        setCurrentDN(newLocationDN);
145:                    }
146:                }*/
147:            }
148:
149:            public void setCurrentLocationDN(Object locationDN) {
150:                setCurrentDN(locationDN);
151:            }
152:
153:            public String changeLocationDN() {
154:                return "";
155:            }
156:
157:            public Map getBookmarkDNs() {
158:                Map bookmarks = new HashMap();
159:                /*bookmarks.put(GLOBAL_LOCATION_DN, GLOBAL_LABEL);
160:                bookmarks.put(defaultOrg, defaultOrg);
161:                bookmarks.put("o=DeveloperSample," + defaultOrg,
162:                        "o=DeveloperSample," + defaultOrg);*/
163:                return bookmarks;
164:            }
165:
166:            /*private String getDefaultOrgDN() {
167:                String orgDN = null;
168:                MBeanServerConnection msc = null;
169:                try {
170:                    msc = getMBeanServerConnection();
171:                    ObjectName objName = getAMObjectSearchMBeanObjectName();
172:                    Object[] params = new Object[] { };
173:                    String[] signature = new String[] { };
174:                    orgDN = (String)msc.invoke(objName, "queryDefaultOrgDN", params, signature);            
175:                } catch (InstanceNotFoundException infe) {
176:                    log(Level.SEVERE, "Exception message is: " +
177:                            infe.getCause().getMessage());
178:                    //throw infe
179:                } catch (MBeanException me) {
180:                    log(Level.SEVERE, "Exception message is: " +
181:                            me.getCause().getMessage());
182:                    //me.printStackTrace();
183:                    //throw me;
184:                } catch (ReflectionException re) {
185:                    log(Level.SEVERE, "Exception message is: " +
186:                            re.getCause().getMessage());
187:                    //re.printStackTrace();
188:                    //throw re;
189:                } catch (IOException ioe) {
190:                    log(Level.SEVERE, "Exception message is: " +
191:                            ioe.getCause().getMessage());
192:                    //throw ioe
193:                } catch (Exception e) {
194:                    log(Level.SEVERE, "Exception message is: " +
195:                            e.getCause().getMessage());
196:                    
197:                    //e.printStackTrace();
198:                    //throw e;
199:                }
200:                return orgDN;
201:                
202:            }*/
203:
204:            public void validateDN(FacesContext ctx, UIComponent comp,
205:                    Object value) {
206:                String dn = (String) value;
207:                if (!isValidEntry(dn)) {
208:                    throw new ValidatorException(new FacesMessage(
209:                            "validation error", "Please Enter a Valid DN"));
210:                }
211:            }
212:
213:            private boolean isValidEntry(String dn) {
214:                boolean valid = false;
215:                MBeanServerConnection msc = null;
216:                try {
217:                    msc = getMBeanServerConnection();
218:                    ObjectName objName = getAMObjectSearchMBeanObjectName();
219:                    Object[] params = new Object[] { dn };
220:                    String[] signature = new String[] { "java.lang.String" };
221:                    valid = ((Boolean) msc.invoke(objName, "isValidDN", params,
222:                            signature)).booleanValue();
223:                } catch (InstanceNotFoundException infe) {
224:                    log(Level.SEVERE, "SSOAObjectSearchBean.isValidEntry()",
225:                            infe);
226:                    //throw infe            
227:                } catch (MBeanException me) {
228:                    log(Level.SEVERE, "SSOAObjectSearchBean.isValidEntry()", me);
229:                    //throw me            
230:                } catch (ReflectionException re) {
231:                    log(Level.SEVERE, "SSOAObjectSearchBean.isValidEntry()", re);
232:                    //throw re           
233:                } catch (IOException ioe) {
234:                    log(Level.SEVERE, "SSOAObjectSearchBean.isValidEntry()",
235:                            ioe);
236:                    //throw ioe            
237:                } catch (Exception e) {
238:                    log(Level.SEVERE, "SSOAObjectSearchBean.isValidEntry()", e);
239:                }
240:                return valid;
241:            }
242:
243:            private ObjectName getAMObjectSearchMBeanObjectName() {
244:                ObjectName objName = null;
245:                try {
246:                    LinkedList path = new LinkedList();
247:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
248:                    path.addFirst("amobjsearch");
249:                    objName = AdminClientUtil.getResourceMBeanObjectName(
250:                            AdminClientUtil.AMOBJECTSEARCH_MBEAN_TYPE, path);
251:                } catch (MalformedObjectNameException mone) {
252:                    //throw mone
253:                    log(
254:                            Level.SEVERE,
255:                            "SSOAObjectSearchBean.getAMObjectSearchMBeanObjectName(): Exception getting MBean Object",
256:                            mone);
257:                }
258:                return objName;
259:            }
260:
261:            public void processValueChange(ValueChangeEvent evt) {
262:                Object currentDN = evt.getNewValue();
263:                log(Level.FINEST,
264:                        "Processing Value Change for Location DN: New DN="
265:                                + currentDN);
266:                setCurrentDN(currentDN);
267:            }
268:
269:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.