Source Code Cross Referenced for ListRealmsAction.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » webapp » jonasadmin » security » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas.webapp.jonasadmin.security 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: ListRealmsAction.java 9864 2006-11-24 10:14:22Z danesa $
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.webapp.jonasadmin.security;
027:
028:        import java.io.IOException;
029:        import java.util.ArrayList;
030:        import java.util.Collections;
031:
032:        import javax.management.ObjectName;
033:        import javax.servlet.ServletException;
034:        import javax.servlet.http.HttpServletRequest;
035:        import javax.servlet.http.HttpServletResponse;
036:
037:        import org.apache.struts.action.ActionForm;
038:        import org.apache.struts.action.ActionForward;
039:        import org.apache.struts.action.ActionMapping;
040:        import org.objectweb.jonas.jmx.CatalinaObjectName;
041:        import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx;
042:        import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
043:
044:        /**
045:         * @author Michel-Ange ANTON
046:         */
047:
048:        public class ListRealmsAction extends BaseMemoryRealmAction {
049:
050:            // --------------------------------------------------------- Public Methods
051:
052:            public ActionForward executeAction(ActionMapping p_Mapping,
053:                    ActionForm p_Form, HttpServletRequest p_Request,
054:                    HttpServletResponse p_Response) throws IOException,
055:                    ServletException {
056:
057:                WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
058:                        .getAttribute(WhereAreYou.SESSION_NAME);
059:                String serverName = oWhere.getCurrentJonasServerName();
060:
061:                // Realms to list
062:                String sTypeRealm = p_Request.getParameter("realm");
063:                if (sTypeRealm == null) {
064:                    sTypeRealm = (String) m_Session.getAttribute("typeRealm");
065:                } else {
066:                    m_Session.setAttribute("typeRealm", sTypeRealm);
067:                }
068:                // Force view all realm if null
069:                if (sTypeRealm == null) {
070:                    sTypeRealm = "all";
071:                    m_Session.setAttribute("typeRealm", sTypeRealm);
072:                }
073:
074:                // Populate list
075:                try {
076:                    String sSecurityRealmUsed = null;
077:                    // Detect realm used by the security service
078:                    if (m_WhereAreYou.isCatalinaServer()) {
079:                        try {
080:                            // Object name used Realm
081:                            ObjectName oObjectName = CatalinaObjectName
082:                                    .catalinaRealm(m_WhereAreYou
083:                                            .getCurrentCatalinaDomainName());
084:                            // Populate
085:                            sSecurityRealmUsed = getStringAttribute(
086:                                    oObjectName, "resourceName");
087:                        } catch (Exception e) {
088:                            // no action
089:                            // Exception because catalina realm don't exists
090:                        }
091:                    }
092:
093:                    ArrayList alRealms = new ArrayList();
094:                    // Detect the realm type
095:                    if (sTypeRealm.equals("all")) {
096:                        // all Realms
097:                        addRealmItem(alRealms, "memory", sSecurityRealmUsed,
098:                                serverName);
099:                        addRealmItem(alRealms, "datasource",
100:                                sSecurityRealmUsed, serverName);
101:                        addRealmItem(alRealms, "ldap", sSecurityRealmUsed,
102:                                serverName);
103:                        // Force the node selected in tree
104:                        m_WhereAreYou.selectNameNode(
105:                                getTreeBranchName(DEPTH_SERVER)
106:                                        + WhereAreYou.NODE_SEPARATOR
107:                                        + "security", true);
108:                    }
109:                    // Memory realm factories
110:                    else if (sTypeRealm.equals("memory")) {
111:                        addRealmItem(alRealms, "memory", sSecurityRealmUsed,
112:                                serverName);
113:                        // Force the node selected in tree
114:                        m_WhereAreYou.selectNameNode(
115:                                getTreeBranchName(DEPTH_SERVER)
116:                                        + WhereAreYou.NODE_SEPARATOR
117:                                        + "security"
118:                                        + WhereAreYou.NODE_SEPARATOR
119:                                        + "factory.memory", true);
120:                    }
121:                    // Datasource realm factories
122:                    else if (sTypeRealm.equals("datasource")) {
123:                        addRealmItem(alRealms, "datasource",
124:                                sSecurityRealmUsed, serverName);
125:                        // Force the node selected in tree
126:                        m_WhereAreYou.selectNameNode(
127:                                getTreeBranchName(DEPTH_SERVER)
128:                                        + WhereAreYou.NODE_SEPARATOR
129:                                        + "security"
130:                                        + WhereAreYou.NODE_SEPARATOR
131:                                        + "factory.datasource", true);
132:                    }
133:                    // Ldap realm factories
134:                    else if (sTypeRealm.equals("ldap")) {
135:                        addRealmItem(alRealms, "ldap", sSecurityRealmUsed,
136:                                serverName);
137:                        // Force the node selected in tree
138:                        m_WhereAreYou.selectNameNode(
139:                                getTreeBranchName(DEPTH_SERVER)
140:                                        + WhereAreYou.NODE_SEPARATOR
141:                                        + "security"
142:                                        + WhereAreYou.NODE_SEPARATOR
143:                                        + "factory.ldap", true);
144:                    }
145:                    // Unknown
146:                    else {
147:                        String sMess = m_Resources.getMessage(
148:                                "error.security.factory.realms.type.unknown",
149:                                sTypeRealm);
150:                        throw new Exception(sMess);
151:                    }
152:                    // Sort
153:                    Collections.sort(alRealms, new RealmItemByNameComparator());
154:                    // Send list to display
155:                    m_Session.setAttribute("listRealms", alRealms);
156:
157:                } catch (Throwable t) {
158:                    addGlobalError(t);
159:                    saveErrors(p_Request, m_Errors);
160:                    return (p_Mapping.findForward("Global Error"));
161:                }
162:                // Forward to the jsp.
163:                return (p_Mapping.findForward("Realms"));
164:            }
165:
166:            // --------------------------------------------------------- Protected Methods
167:            /**
168:             * Add <code>RealmItem</code> in the list.
169:             *
170:             * @param p_Realms List to add found items
171:             * @param p_Type Type item to add (memory or datasource or ldap)
172:             * @param p_SecurityRealmUsed Name of realm used by the security service
173:             * or null if nothing used
174:             * @throws Exception
175:             */
176:            protected void addRealmItem(ArrayList p_Realms, String p_Type,
177:                    String p_SecurityRealmUsed, String serverName)
178:                    throws Exception {
179:
180:                ArrayList al = null;
181:
182:                // Memory realm factories
183:                if (p_Type.equals("memory")) {
184:                    al = JonasAdminJmx.getSecurityMemoryFactories(serverName);
185:                }
186:                // Datasource realm factories
187:                else if (p_Type.equals("datasource")) {
188:                    al = JonasAdminJmx
189:                            .getSecurityDatasourceFactories(serverName);
190:                }
191:                // Ldap realm factories
192:                else if (p_Type.equals("ldap")) {
193:                    al = JonasAdminJmx.getSecurityLdapFactories(serverName);
194:                }
195:                // Add
196:                if (al != null) {
197:                    for (int i = 0; i < al.size(); i++) {
198:                        if (p_SecurityRealmUsed != null) {
199:                            p_Realms.add(new RealmItem(al.get(i).toString(),
200:                                    p_Type, p_SecurityRealmUsed.equals(al
201:                                            .get(i).toString())));
202:                        } else {
203:                            p_Realms.add(new RealmItem(al.get(i).toString(),
204:                                    p_Type));
205:                        }
206:                    }
207:                }
208:            }
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.