KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > core > PageTaskMenuTree


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.core;
21
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23
24 import com.sslexplorer.navigation.MenuTree;
25 import com.sslexplorer.policyframework.Permission;
26 import com.sslexplorer.policyframework.PolicyConstants;
27 import com.sslexplorer.security.SessionInfo;
28
29 /**
30  * Menu tree used for <i>Page Tasks</i>.
31  *
32  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
33  */

34 public class PageTaskMenuTree extends MenuTree {
35     
36     /**
37      * Menuu tree id
38      */

39     public static final String JavaDoc PAGE_TASK_MENU_TREE = "pageTask";
40
41     /**
42      * Constructor.
43      *
44      */

45     public PageTaskMenuTree() {
46         super(PageTaskMenuTree.PAGE_TASK_MENU_TREE);
47
48         // User Profiles Page Tasks
49
addMenuItem(null, new MenuItem("showUserProfiles", null, null, 100, false, SessionInfo.ALL_CONTEXTS));
50         addMenuItem("showUserProfiles", new MenuItem("createUserProfile", "properties",
51             "/showUserProfiles.do?actionTarget=create&profileScope=personal", 100, true, null,
52             SessionInfo.USER_CONSOLE_CONTEXT, PolicyConstants.PERSONAL_PROFILE_RESOURCE_TYPE, new Permission[] {
53                 PolicyConstants.PERM_MAINTAIN
54             }, null));
55
56         // Globa Profiles Page Tasks
57
addMenuItem(null, new MenuItem("showGlobalProfiles", null, null, 100, false, SessionInfo.ALL_CONTEXTS));
58         addMenuItem("showGlobalProfiles", new MenuItem("createGlobalProfile", "properties",
59             "?actionTarget=create&profileScope=global", 100, true, PolicyConstants.PROFILE_RESOURCE_TYPE,
60             new Permission[] {
61                 PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN
62             }) {
63
64             public boolean isAvailable(int checkNavigationContext, SessionInfo info, HttpServletRequest JavaDoc request) {
65                 return super.isAvailable(checkNavigationContext, info, request);
66             }
67         });
68
69         // Show Available Roles
70
addMenuItem(null, new MenuItem("showAvailableRoles", null, null, 100, false, SessionInfo.ALL_CONTEXTS));
71         addMenuItem("showAvailableRoles", new MenuItem("createRole", "security",
72             "?actionTarget=create", 100, true,
73             PolicyConstants.ACCOUNTS_AND_GROUPS_RESOURCE_TYPE, new Permission[] {
74                     PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN
75             }) {
76             public boolean isAvailable(int checkNavigationContext, SessionInfo info, HttpServletRequest JavaDoc request) {
77                 boolean available = super.isAvailable(checkNavigationContext, info, request);
78                 if (available) {
79                     try {
80                         available = UserDatabaseManager.getInstance().getUserDatabase(info.getUser().getRealm()).supportsAccountCreation();
81                     } catch (Exception JavaDoc e1) {
82                         available = false;
83                 }
84                 }
85                 return available;
86             }
87         });
88         
89         // Show Available IP Restrictions
90
addMenuItem(null, new MenuItem("showAvailableIpRestrictions", null, null, 100, false, SessionInfo.ALL_CONTEXTS));
91         addMenuItem("showAvailableIpRestrictions", new MenuItem("createIpRestriction", "security",
92             "?actionTarget=create", 100, true,
93             PolicyConstants.IP_RESTRICTIONS_RESOURCE_TYPE, new Permission[] {
94                     PolicyConstants.PERM_CREATE
95             }));
96
97         // Show Available Accounts
98
addMenuItem(null, new MenuItem("showAvailableAccounts", null, null, 100, false, SessionInfo.ALL_CONTEXTS));
99         addMenuItem("showAvailableAccounts", new MenuItem("createAccount", "security",
100             "?actionTarget=create", 100, true,
101             PolicyConstants.ACCOUNTS_AND_GROUPS_RESOURCE_TYPE, new Permission[] {
102                 PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN
103             }) {
104             public boolean isAvailable(int checkNavigationContext, SessionInfo info, HttpServletRequest JavaDoc request) {
105                 boolean available = super.isAvailable(checkNavigationContext, info, request);
106                 if (available) {
107                     try {
108                         available = UserDatabaseManager.getInstance().getUserDatabase(info.getUser().getRealm()).supportsAccountCreation();
109                     } catch (Exception JavaDoc e1) {
110                         available = false;
111                 }
112                 }
113                 return available;
114             }
115         });
116
117         // Edit Account Page
118
addMenuItem(null, new MenuItem("editAccount", null, null, 100, false, SessionInfo.ALL_CONTEXTS));
119         addMenuItem("editAccount", new MenuItem("resetUserAttributes", "security",
120                         "javascript: setActionTarget('resetUserAttributes'); document.forms[0].submit();", 200, true, "_self",
121                         SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, PolicyConstants.ACCOUNTS_AND_GROUPS_RESOURCE_TYPE,
122                         new Permission[] { PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN }));
123         
124         // Authentication Schemes Page
125
addMenuItem(null, new MenuItem("showAuthenticationSchemes", null, null, 100, false, SessionInfo.ALL_CONTEXTS));
126         addMenuItem("showAuthenticationSchemes", new MenuItem("createAuthenticationScheme", "security",
127             "/athenticationSchemeDetails.do", 100, true, "_self",
128             SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, PolicyConstants.AUTHENTICATION_SCHEMES_RESOURCE_TYPE, new Permission[] {
129                 PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN
130             }));
131         
132         // User attribute definitions
133
addMenuItem(null, new MenuItem("showAttributeDefinitions", null, null, 100, false, SessionInfo.ALL_CONTEXTS));
134         addMenuItem("showAttributeDefinitions", new MenuItem("createAttributeDefinition", "properties",
135             "?actionTarget=create&propertyClassName=userAttributes", 100, true,
136             PolicyConstants.ATTRIBUTE_DEFINITIONS_RESOURCE_TYPE, new Permission[] {
137                     PolicyConstants.PERM_MAINTAIN
138             }));
139
140
141         // User attributes
142
addMenuItem(null, new MenuItem("userAttributes", null, null, 100, false, SessionInfo.ALL_CONTEXTS));
143         addMenuItem("userAttributes", new MenuItem("resetAttributes", "security",
144                         "?actionTarget=resetUserAttributes", 100, true, "_self",
145                         SessionInfo.USER_CONSOLE_CONTEXT, PolicyConstants.ATTRIBUTES_RESOURCE_TYPE, new Permission[] {
146                             PolicyConstants.PERM_MAINTAIN
147                         }));
148
149         // Policies
150
addMenuItem(null, new MenuItem("policies", null, null, 100, false, SessionInfo.ALL_CONTEXTS));
151         addMenuItem("policies", new MenuItem("createPolicy", "policyframework", "/policyDetails.do", 100, true, null,
152             SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, PolicyConstants.POLICY_RESOURCE_TYPE, new Permission[] {
153                 PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN
154             }, null));
155
156         // Configure Policies (breaks out from resource creation wizard)
157
addMenuItem(null, new MenuItem("configurePolicies", null, null, 100, false, SessionInfo.ALL_CONTEXTS));
158         addMenuItem("configurePolicies", new MenuItem("createPolicy", "policyframework", "/policyDetails.do", 100, true,
159             null, SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, PolicyConstants.POLICY_RESOURCE_TYPE, new Permission[] {
160                 PolicyConstants.PERM_CREATE
161             }, null));
162         addMenuItem("configurePolicies", new MenuItem("cancelConfigurePolicies", "policyframework",
163             "javascript: setActionTarget('cancel'); document.forms[0].submit()", 100, true, "_self",
164             SessionInfo.MANAGEMENT_CONSOLE_CONTEXT));
165
166         // Resource Permissions
167
addMenuItem(null, new MenuItem("accessRightsList", null, null, 100, false, SessionInfo.ALL_CONTEXTS));
168         
169         addMenuItem("accessRightsList", new MenuItem("createDelegationAccessRights", "policyframework",
170                         "/accessRightsDetails.do?class=delegation", 100, true, null, SessionInfo.MANAGEMENT_CONSOLE_CONTEXT,
171                         PolicyConstants.ACCESS_RIGHTS_RESOURCE_TYPE,
172                         new Permission[] { PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN }));
173         
174         addMenuItem("accessRightsList", new MenuItem("createSystemAccessRights", "policyframework",
175                         "/accessRightsDetails.do?class=system", 200, true, null, SessionInfo.MANAGEMENT_CONSOLE_CONTEXT,
176                         PolicyConstants.ACCESS_RIGHTS_RESOURCE_TYPE,
177                         new Permission[] { PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN }));
178
179         addMenuItem("accessRightsList", new MenuItem("createPersonalAccessRights", "policyframework",
180                         "/accessRightsDetails.do?class=personal", 300, true, null, SessionInfo.MANAGEMENT_CONSOLE_CONTEXT,
181                         PolicyConstants.ACCESS_RIGHTS_RESOURCE_TYPE,
182                         new Permission[] { PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN }));
183
184         // Message Queue
185
addMenuItem(null, new MenuItem("messageQueue", null, null, 100, false, SessionInfo.MANAGEMENT_CONSOLE_CONTEXT));
186         addMenuItem("messageQueue", new MenuItem("sendMessage", "setup",
187             "?actionTarget=sendMessage", 100, true, null,
188             SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, PolicyConstants.MESSAGE_QUEUE_RESOURCE_TYPE, new Permission[] {
189                 PolicyConstants.PERM_SEND
190             }, null));
191         addMenuItem("messageQueue", new MenuItem("clearQueue", "setup",
192             "?actionTarget=confirmClearQueue", 200, true, null,
193             SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, PolicyConstants.MESSAGE_QUEUE_RESOURCE_TYPE, new Permission[] {
194                 PolicyConstants.PERM_CLEAR
195             }, null));
196
197         
198         // Create Replacements
199
addMenuItem(null, new MenuItem("showReplacements", null, null, 100, false, SessionInfo.MANAGEMENT_CONSOLE_CONTEXT));
200         addMenuItem("showReplacements", new MenuItem("createReplacement", "services", "/showReplacements.do?actionTarget=create", 100, true,
201             "_self", SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, PolicyConstants.REPLACEMENTS_RESOURCE_TYPE,
202             new Permission[] { PolicyConstants.PERM_CHANGE}));
203         
204         // Extension Manager
205
addMenuItem(null, new MenuItem("showExtensionStore", null, null, 100, false, SessionInfo.MANAGEMENT_CONSOLE_CONTEXT));
206         addMenuItem("showExtensionStore", new MenuItem("uploadExtension", "extensions", "/installed.do?subForm=installedExtensionsForm&amp;actionTarget=upload", 100, true,
207             "_self", SessionInfo.MANAGEMENT_CONSOLE_CONTEXT));
208         addMenuItem("showExtensionStore", new MenuItem("refreshExtensionStore", "extensions", "?subForm=updateableExtensionsForm&amp;actionTarget=refresh", 100, true,
209                         "_self", SessionInfo.MANAGEMENT_CONSOLE_CONTEXT));
210         
211         // SSL Certificates
212
addMenuItem(null, new MenuItem("showKeyStore", null, null, 100, false, SessionInfo.MANAGEMENT_CONSOLE_CONTEXT));
213         addMenuItem("showKeyStore", new MenuItem("keyStoreImport", "keystore", "/keyStoreImportType.do", 100, true,
214             "_self", SessionInfo.MANAGEMENT_CONSOLE_CONTEXT));
215         addMenuItem("showKeyStore", new MenuItem("generateServerCertificateCSR", "keystore", "/generateServerCertificateCSR.do", 200, true,
216                         "_blank", SessionInfo.MANAGEMENT_CONSOLE_CONTEXT));
217         addMenuItem("showKeyStore", new MenuItem("downloadServerCertificateCSR", "keystore", "/downloadServerCertificateCSR.do", 300, true,
218                         "_self", SessionInfo.MANAGEMENT_CONSOLE_CONTEXT));
219
220         // Shutdown page
221
addMenuItem(null, new MenuItem("showShutdown", null, null, 100, false, SessionInfo.MANAGEMENT_CONSOLE_CONTEXT));
222         addMenuItem("showShutdown", new MenuItem("broadcastShutdownMessage", "setup", "javascript: setActionTarget('sendMessage'); document.forms[0].submit();", 100, true,
223             "_self", SessionInfo.MANAGEMENT_CONSOLE_CONTEXT));
224
225     }
226 }
227
Popular Tags