Source Code Cross Referenced for SEUsersPortlet.java in  » EJB-Server-geronimo » plugins » org » apache » geronimo » console » securitymanager » 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 » EJB Server geronimo » plugins » org.apache.geronimo.console.securitymanager 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */package org.apache.geronimo.console.securitymanager;
017:
018:        import java.io.IOException;
019:        import java.util.Collection;
020:        import java.util.Hashtable;
021:
022:        import javax.portlet.ActionRequest;
023:        import javax.portlet.ActionResponse;
024:        import javax.portlet.PortletConfig;
025:        import javax.portlet.PortletContext;
026:        import javax.portlet.PortletException;
027:        import javax.portlet.RenderRequest;
028:        import javax.portlet.RenderResponse;
029:        import javax.portlet.WindowState;
030:
031:        import org.apache.geronimo.console.util.SERealmGroupHelper;
032:        import org.apache.geronimo.console.util.SERealmUserHelper;
033:
034:        /**
035:         * @version $Rev: 540258 $ $Date: 2007-05-21 13:01:37 -0700 (Mon, 21 May 2007) $
036:         */
037:        public class SEUsersPortlet extends AbstractSecurityManagerPortlet {
038:
039:            protected void doView(RenderRequest renderRequest,
040:                    RenderResponse renderResponse) throws PortletException,
041:                    IOException {
042:                if (WindowState.MINIMIZED
043:                        .equals(renderRequest.getWindowState())) {
044:                    return;
045:                }
046:
047:                String errorMessage = renderRequest
048:                        .getParameter("errorMessage");
049:
050:                if (errorMessage != null) {
051:                    renderRequest.setAttribute("errorMessage", errorMessage);
052:                    errorView.include(renderRequest, renderResponse);
053:                } else {
054:                    try {
055:                        String[] users = SERealmUserHelper.getUsers();
056:
057:                        Hashtable userInfo = new Hashtable();
058:                        for (int i = 0; i < users.length; i++) {
059:                            String currentUser = users[i];
060:                            // We really shouldn't be attaching everyone's password as portlet data!!!
061:                            // And the current Portlet doesn't use it, so why send it....
062:                            // userInfo.put(currentUser, SERealmUserHelper.getPassword(currentUser.toString()));
063:                            userInfo.put(currentUser, currentUser.toString());
064:                        }
065:
066:                        String currAction = renderRequest
067:                                .getParameter("currAction");
068:                        renderRequest.setAttribute("message", renderRequest
069:                                .getParameter("message"));
070:
071:                        if ("new".equals(currAction)) {
072:                            String[] groups = SERealmGroupHelper.getGroups();
073:                            Hashtable groupsInfo = new Hashtable();
074:                            for (int i = 0; i < groups.length; i++) {
075:                                String currentGroup = groups[i];
076:                                groupsInfo.put(currentGroup, SERealmGroupHelper
077:                                        .getUsers(currentGroup));
078:                            }
079:                            renderRequest
080:                                    .setAttribute("groupsInfo", groupsInfo);
081:                            addMaximizedView.include(renderRequest,
082:                                    renderResponse);
083:                        } else if ("edit".equals(currAction)) {
084:                            String user = renderRequest.getParameter("user");
085:                            renderRequest.setAttribute("userID", user);
086:                            // We really shouldn't be sending the user's password as portlet data!!!
087:                            // And the current Portlet doesn't use it, so why send it....
088:                            //renderRequest.setAttribute("password", SERealmUserHelper.getPassword(user));
089:                            // Current Portlet doesn't use groupsInfo, so why send it 
090:                            //renderRequest.setAttribute("groupsInfo", groupsInfo);
091:                            addMaximizedView.include(renderRequest,
092:                                    renderResponse);
093:                        } else {
094:                            if (WindowState.NORMAL.equals(renderRequest
095:                                    .getWindowState())) {
096:                                renderRequest
097:                                        .setAttribute("userInfo", userInfo);
098:                                normalView.include(renderRequest,
099:                                        renderResponse);
100:                            } else {
101:                                renderRequest
102:                                        .setAttribute("userInfo", userInfo);
103:                                maximizedView.include(renderRequest,
104:                                        renderResponse);
105:                            }
106:                        }
107:                    } catch (Exception e) {
108:                        errorMessage = e.getMessage();
109:                        renderRequest
110:                                .setAttribute("errorMessage", errorMessage);
111:                        errorView.include(renderRequest, renderResponse);
112:                    }
113:                }
114:            }
115:
116:            public void init(PortletConfig portletConfig)
117:                    throws PortletException {
118:                super .init(portletConfig);
119:                PortletContext pc = portletConfig.getPortletContext();
120:                normalView = pc
121:                        .getRequestDispatcher("/WEB-INF/view/securityrealmmanager/se/users/normal.jsp");
122:                addNormalView = pc
123:                        .getRequestDispatcher("/WEB-INF/view/securityrealmmanager/se/users/addnormal.jsp");
124:                maximizedView = pc
125:                        .getRequestDispatcher("/WEB-INF/view/securityrealmmanager/se/users/maximized.jsp");
126:                addMaximizedView = pc
127:                        .getRequestDispatcher("/WEB-INF/view/securityrealmmanager/se/users/addmaximized.jsp");
128:                helpView = pc
129:                        .getRequestDispatcher("/WEB-INF/view/securityrealmmanager/se/users/help.jsp");
130:                errorView = pc
131:                        .getRequestDispatcher("/WEB-INF/view/securityrealmmanager/derby/groups/error.jsp");
132:            }
133:
134:            public void processAction(ActionRequest actionRequest,
135:                    ActionResponse actionResponse) throws PortletException,
136:                    IOException {
137:                String action = actionRequest.getParameter("action").trim();
138:                String cancel = actionRequest.getParameter("cancel");
139:                String currAction = "";
140:                if (cancel != null) {
141:                    action = "";
142:                }
143:                String user = actionRequest.getParameter("userId");
144:                String password = actionRequest.getParameter("password");
145:                String group = actionRequest.getParameter("group");
146:
147:                try {
148:                    if ("delete".equals(action)) {
149:                        try {
150:                            String[] groups = SERealmGroupHelper.getGroups();
151:                            for (int i = 0; i < groups.length; i++) {
152:                                String currentGroup = groups[i];
153:                                if (SERealmGroupHelper.isGroupMember(
154:                                        currentGroup, user)) {
155:                                    Collection list = SERealmGroupHelper
156:                                            .getUsers(currentGroup);
157:                                    list.remove(user);
158:                                    String[] groupUsers = (String[]) list
159:                                            .toArray(new String[0]);
160:                                    SERealmGroupHelper.updateGroup(
161:                                            currentGroup, groupUsers);
162:                                }
163:                            }
164:                            SERealmUserHelper.deleteUser(user);
165:                        } catch (Exception e) {
166:                            actionResponse.setRenderParameter("message",
167:                                    "ERROR: Error in SEUsersPortlet while deleting user "
168:                                            + user + ". Cause: "
169:                                            + e.getMessage());
170:                        }
171:                    } else if ("update".equals(action)) {
172:                        if (password != null && !password.equals("")) {
173:                            // Update the password only when it is not blank.
174:                            SERealmUserHelper.updateUser(user, password);
175:                        }
176:                    } else if ("add".equals(action)) {
177:                        try {
178:                            SERealmUserHelper.addUser(user, password);
179:                            if ((group != null) && (!group.equals(""))) {
180:                                Collection list = SERealmGroupHelper
181:                                        .getUsers(group);
182:                                list.add(user);
183:                                String[] groupUsers = (String[]) list
184:                                        .toArray(new String[0]);
185:                                SERealmGroupHelper.updateGroup(group,
186:                                        groupUsers);
187:                            }
188:                        } catch (Exception e) {
189:                            actionResponse.setRenderParameter("message",
190:                                    "ERROR: Error in SEUsersPortlet while adding user "
191:                                            + user + " to group " + group
192:                                            + ". Cause: " + e.getMessage());
193:                        }
194:                    } else if ("new".equals(action)) {
195:                        currAction = "new";
196:                    } else if ("edit".equals(action)) {
197:                        currAction = "edit";
198:                    }
199:                    actionResponse.setRenderParameter("currAction", currAction);
200:                    if (user != null) {
201:                        actionResponse.setRenderParameter("user", user);
202:                    }
203:                } catch (Exception e) {
204:                    actionResponse.setRenderParameter("message",
205:                            "Error encountered in SEUsersPortlet. Cause: "
206:                                    + e.getMessage());
207:                }
208:            }
209:
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.