Source Code Cross Referenced for EditAuthlessBean.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: EditAuthlessBean.java,v 1.4 2005/09/21 15:29:57 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:        import java.io.IOException;
018:
019:        import javax.faces.application.FacesMessage;
020:        import javax.faces.context.FacesContext;
021:        import javax.faces.validator.ValidatorException;
022:
023:        import javax.management.Attribute;
024:        import javax.management.ObjectName;
025:        import javax.management.MBeanServerConnection;
026:        import javax.management.MalformedObjectNameException;
027:
028:        import javax.servlet.http.HttpServletRequest;
029:
030:        import com.sun.data.provider.DataProvider;
031:        import com.sun.data.provider.impl.ObjectListDataProvider;
032:        import com.sun.web.ui.component.RadioButton;
033:        import com.sun.web.ui.component.Checkbox;
034:        import com.sun.web.ui.model.Option;
035:
036:        import com.sun.portal.admin.common.util.AdminClientUtil;
037:
038:        import com.sun.portal.admin.console.common.PSBaseBean;
039:
040:        public class EditAuthlessBean extends PSBaseBean {
041:
042:            //	public static final String ATTR_SELECTED_TEMPLATE = "ssoa.template.selected";
043:            public static final String RB_NAME = "ssoa";
044:
045:            protected Map rbMap;
046:
047:            // users is the ObjectListDataProvider that is based off a list of UserDnBeans
048:            protected DataProvider users = null;
049:            // usersList is a list of UserDnBeans
050:            protected List usersList = new ArrayList();
051:            // authorizedUsers is the list returned by the server MBean
052:            protected List authorizedUsers = null;
053:
054:            protected ObjectName objectName = null;
055:
056:            // Limit the search to users
057:            private Option[] objTypes = null;
058:
059:            /** Creates a new instance of EditAuthlessBean*/
060:            public EditAuthlessBean() {
061:                log(Level.FINEST, "Start constructor");
062:                // Get resource bundle
063:                rbMap = getResourceStringMap(RB_NAME);
064:
065:                // MBean path of SSOAdapter.
066:                LinkedList path = new LinkedList();
067:                path.addFirst(getDomain());
068:                path.addFirst("ssoadapter");
069:
070:                try {
071:                    objectName = AdminClientUtil.getResourceMBeanObjectName(
072:                            AdminClientUtil.SSOADAPTER_MBEAN_TYPE, path);
073:                } catch (MalformedObjectNameException e) {
074:                    log(
075:                            Level.SEVERE,
076:                            "EditAuthlessBean.EditAuthlessBean(): Exception when getting MBean object name",
077:                            e);
078:                }
079:                resetAuthlessList();
080:
081:                objTypes = new Option[1];
082:                objTypes[0] = new Option("1", "user");
083:            }
084:
085:            public DataProvider getUsers() {
086:                return users;
087:            }
088:
089:            public Option[] getObjTypes() {
090:                return objTypes;
091:            }
092:
093:            // Do the mbean server connection to pull the template names.  Will also reset the data
094:            // object to reflect the template names
095:            private void resetAuthlessList() {
096:                log(Level.FINEST, "Start resetting the Authless list");
097:                // SSOA templates names are returned by SSOAdapter MBean method resetAuthlessList
098:                MBeanServerConnection conn = getMBeanServerConnection();
099:                try {
100:                    // This can throw AttributeNotFoundException, MBeanException, InstanceNotFoundException
101:                    // ReflectionException, RuntimeOperationsException, or IOException
102:                    authorizedUsers = (List) conn.getAttribute(objectName,
103:                            "AuthorizedAuthlessUsers");
104:                } catch (Exception ex) {
105:                    log(
106:                            Level.SEVERE,
107:                            "EditAuthlessBean.resetAuthlessList(): Exception when trying to get the list of authorized authless users",
108:                            ex);
109:                }
110:                usersList = new ArrayList(authorizedUsers.size());
111:                Collections.sort(authorizedUsers);
112:                Iterator iter = authorizedUsers.iterator();
113:                while (iter.hasNext()) {
114:                    String dn = (String) iter.next();
115:                    usersList.add(new UserDnBean(dn));
116:                }
117:                users = new ObjectListDataProvider(usersList);
118:            }
119:
120:            // Do the mbean server connection to save the current authless user list.  Will also reset the data
121:            // object to reflect the latest authless users
122:            private void saveAuthlessList() {
123:                log(Level.FINEST, "Save authless list start");
124:                MBeanServerConnection conn = getMBeanServerConnection();
125:                try {
126:                    // This can throw AttributeNotFoundException, MBeanException, InstanceNotFoundException
127:                    // ReflectionException, RuntimeOperationsException, or IOException
128:                    Attribute att = new Attribute("AuthorizedAuthlessUsers",
129:                            authorizedUsers);
130:                    conn.setAttribute(objectName, att);
131:                } catch (Exception ex) {
132:                    log(
133:                            Level.SEVERE,
134:                            "EditAuthlessBean.saveAuthlessList(): Exception when trying to save the list of authorized authless users",
135:                            ex);
136:                }
137:                resetAuthlessList();
138:            }
139:
140:            public String gotoConfigurationsByDnHome() {
141:                String userDn = (String) RadioButton.getSelected("rb");
142:                setSessionAttribute(ATTR_CURRENT_LOCATION_DN, userDn);
143:                log(Level.FINEST, "gotoConfigurationsByDnHome: " + userDn);
144:                return "gotoConfigurationsByDnHome";
145:            }
146:
147:            public String gotoAddAuthlessUser() {
148:                log(Level.FINEST, "EditAuthlessBean.gotoAddAuthlessUser start");
149:                return "gotoAddAuthlessUser";
150:            }
151:
152:            // This will find the checkbox list of dns and add them one
153:            // at a time.  Then it will save the list and return the user to the
154:            // edit authless page
155:            public String addUsers() {
156:                log(Level.FINEST, "EditAuthlessBean.addUsers start");
157:                //RowKey[] rkey = amLocations.getRowKeys(1000, null);
158:                List selectedcbs = Checkbox.getSelected("dncb");
159:                for (Iterator i = selectedcbs.iterator(); i.hasNext();) {
160:                    String dn = (String) i.next();
161:                    addUser(dn);
162:                }
163:                saveAuthlessList();
164:                return back();
165:            }
166:
167:            public String cancel() {
168:                return "gotoAuthlessHome";
169:            }
170:
171:            public String back() {
172:                return "back";
173:            }
174:
175:            // This is a private class to add one user to the authorizedUsers list
176:            // It does not save the data to the store.
177:            private void addUser(String dn) {
178:                log(Level.FINEST, "EditAuthlessBean.addUser start");
179:                if (authorizedUsers.size() == 0) {
180:                    authorizedUsers = new ArrayList();
181:                }
182:                for (Iterator i = authorizedUsers.iterator(); i.hasNext();) {
183:                    String userdn = (String) i.next();
184:                    if (userdn.equalsIgnoreCase(dn)) {
185:                        log(Level.FINEST,
186:                                "EditAuthlessBean.addUser duplicate dn found: "
187:                                        + dn);
188:                        return;
189:                    }
190:                }
191:                log(Level.FINEST, "EditAuthlessBean.addUser adding dn: " + dn);
192:                authorizedUsers.add(dn);
193:            }
194:
195:            public void removeUsers() {
196:                log(Level.FINEST, "Remove users start");
197:                List selectedcbs = Checkbox.getSelected("dncb");
198:                for (Iterator i = selectedcbs.iterator(); i.hasNext();) {
199:                    String userDn = (String) i.next();
200:                    if ((userDn == null) || (userDn.length() == 0)) {
201:                        log(Level.WARNING, "Invalid user dn supplied");
202:                        continue;
203:                    }
204:                    log(Level.FINEST, "Removing user " + userDn + " from list");
205:                    authorizedUsers.remove(userDn);
206:                }
207:                //String userDn = (String)RadioButton.getSelected("rb"); 
208:                saveAuthlessList();
209:            }
210:
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.