1 19 20 package com.sslexplorer.table; 21 22 import javax.servlet.http.HttpServletRequest ; 23 24 import com.sslexplorer.core.AvailableMenuItem; 25 import com.sslexplorer.core.MenuItem; 26 import com.sslexplorer.extensions.itemactions.DisableExtensionAction; 27 import com.sslexplorer.extensions.itemactions.EnableExtensionAction; 28 import com.sslexplorer.extensions.itemactions.ExtensionInformationAction; 29 import com.sslexplorer.extensions.itemactions.InstallExtensionAction; 30 import com.sslexplorer.extensions.itemactions.RemoveExtensionAction; 31 import com.sslexplorer.extensions.itemactions.StartExtensionAction; 32 import com.sslexplorer.extensions.itemactions.StopExtensionAction; 33 import com.sslexplorer.extensions.itemactions.UpdateExtensionAction; 34 import com.sslexplorer.navigation.MenuTree; 35 import com.sslexplorer.navigation.itemactions.RemoveFavoriteAction; 36 import com.sslexplorer.policyframework.Permission; 37 import com.sslexplorer.policyframework.PolicyConstants; 38 import com.sslexplorer.policyframework.ResourceType; 39 import com.sslexplorer.policyframework.itemactions.CloneResourceAction; 40 import com.sslexplorer.policyframework.itemactions.EditResourceAction; 41 import com.sslexplorer.policyframework.itemactions.RemovePolicyAction; 42 import com.sslexplorer.policyframework.itemactions.RemoveResourceAction; 43 import com.sslexplorer.properties.itemactions.RemoveProfileAction; 44 import com.sslexplorer.properties.itemactions.ViewProfileAction; 45 import com.sslexplorer.security.LogonController; 46 import com.sslexplorer.security.SessionInfo; 47 import com.sslexplorer.security.UserItem; 48 import com.sslexplorer.security.itemactions.DisableAuthenticationSchemeAction; 49 import com.sslexplorer.security.itemactions.EditAccountTableAction; 50 import com.sslexplorer.security.itemactions.EnableAuthenticationSchemeAction; 51 import com.sslexplorer.security.itemactions.MoveAuthenticationSchemeDownAction; 52 import com.sslexplorer.security.itemactions.MoveAuthenticationSchemeUpAction; 53 54 59 public class TableItemActionMenuTree extends MenuTree { 60 63 public static final String MENU_TABLE_ITEM_ACTION_MENU_TREE = "tableItemAction"; 64 65 68 public TableItemActionMenuTree() { 69 super(TableItemActionMenuTree.MENU_TABLE_ITEM_ACTION_MENU_TREE); 70 addFavorites(); 71 addProfiles(); 72 addPersonalProfiles(); 73 addExtensions(); 74 addAccessRights(); 75 addUsers(); 76 addAuthenticationSchemes(); 77 addPolicies(); 78 } 79 80 private void addFavorites() { 81 addMenuItem(null, new MenuItem("favorites", "navigation", null, 100, false, SessionInfo.USER_CONSOLE_CONTEXT)); 82 addMenuItem("favorites", new RemoveFavoriteAction()); 83 } 84 85 private void addProfiles() { 86 addMenuItem(null, new MenuItem("profiles", "policyframework", null, 100, false, SessionInfo.ALL_CONTEXTS)); 87 addMenuItem("profiles", new ViewProfileAction()); 88 addMenuItem("profiles", new RemoveProfileAction()); 89 addMenuItem("profiles", new EditResourceAction(SessionInfo.ALL_CONTEXTS, "properties")); 90 addMenuItem("profiles", new CloneResourceAction(SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, "properties")); 91 } 92 93 private void addPersonalProfiles() { 94 addMenuItem(null, new MenuItem("personalProfiles", "policyframework", null, 100, false, SessionInfo.ALL_CONTEXTS)); 95 addMenuItem("personalProfiles", new ViewProfileAction()); 96 addMenuItem("personalProfiles", new RemoveProfileAction()); 97 addMenuItem("personalProfiles", new EditResourceAction(SessionInfo.USER_CONSOLE_CONTEXT, "properties")); 98 addMenuItem("personalProfiles", new CloneResourceAction(SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, "properties")); 99 } 100 101 private void addAuthenticationSchemes() { 102 addMenuItem(null, new MenuItem("authenticationSchemes", "security", null, 100, false, SessionInfo.ALL_CONTEXTS)); 103 addMenuItem("authenticationSchemes", new RemoveResourceAction(SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, "security")); 104 addMenuItem("authenticationSchemes", new EditResourceAction(SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, "security")); 105 addMenuItem("authenticationSchemes", new EnableAuthenticationSchemeAction()); 106 addMenuItem("authenticationSchemes", new DisableAuthenticationSchemeAction()); 107 addMenuItem("authenticationSchemes", new MoveAuthenticationSchemeUpAction()); 108 addMenuItem("authenticationSchemes", new MoveAuthenticationSchemeDownAction()); 109 } 110 111 private void addPolicies() { 112 addMenuItem(null, new MenuItem("policies", "security", null, 100, false, SessionInfo.ALL_CONTEXTS)); 113 addMenuItem("policies", new RemovePolicyAction(SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, "policyframework")); 114 addMenuItem("policies", new EditResourceAction(SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, "policyframework")); 115 } 116 117 private void addExtensions() { 118 addMenuItem(null, new MenuItem("extensionStore", "extensions", null, 100, false, SessionInfo.ALL_CONTEXTS)); 119 addMenuItem("extensionStore", new InstallExtensionAction()); 120 addMenuItem("extensionStore", new UpdateExtensionAction()); 121 addMenuItem("extensionStore", new RemoveExtensionAction()); 122 addMenuItem("extensionStore", new ExtensionInformationAction()); 123 addMenuItem("extensionStore", new EnableExtensionAction()); 124 addMenuItem("extensionStore", new DisableExtensionAction()); 125 addMenuItem("extensionStore", new StartExtensionAction()); 126 addMenuItem("extensionStore", new StopExtensionAction()); 127 } 128 129 private void addUsers() { 130 addMenuItem(null, new MenuItem("accounts", null, null, 100, false, SessionInfo.ALL_CONTEXTS)); 131 addMenuItem("accounts", getEditAccountAction()); 132 addMenuItem("accounts", getDeleteAccountAction()); 133 addMenuItem("accounts", getSetPasswordAction()); 134 addMenuItem("accounts", getEnableAccountAction()); 135 addMenuItem("accounts", getDisableAccountAction()); 136 addMenuItem("accounts", getResetPrivateKey()); 137 addMenuItem("accounts", getSendUserMessage()); 138 } 139 private void addAccessRights() { 140 addMenuItem(null, new MenuItem("accessRights", "policyframework", null, 100, false, SessionInfo.ALL_CONTEXTS)); 141 addMenuItem("accessRights", new EditResourceAction(SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, "policyframework")); 142 addMenuItem("accessRights", new RemoveResourceAction(SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, "policyframework")); 143 } 144 145 private static TableItemAction getEditAccountAction() { 146 return new EditAccountTableAction("edit", 100, true, "/editAccount.do?actionTarget=edit&username={0}"); 147 } 148 149 private static TableItemAction getDeleteAccountAction() { 150 return new EditAccountTableAction("remove", 150, true, "/showAvailableAccounts.do?actionTarget=confirmAccountDeletion&username={0}", false, true) { 151 @Override 152 public Permission[] getPermissions(ResourceType resourceType) { 153 return new Permission[] { resourceType.getPermission(PolicyConstants.PERM_DELETE_ID) }; 154 } 155 }; 156 } 157 158 private static TableItemAction getSetPasswordAction() { 159 return new EditAccountTableAction("setPassword", 210, false, "/showAvailableAccounts.do?actionTarget=password&username={0}", true, false); 160 } 161 162 private static TableItemAction getEnableAccountAction() { 163 return new EditAccountTableAction("enable", 200, false, "/showAvailableAccounts.do?actionTarget=enable&username={0}") { 164 @Override 165 public boolean isEnabled(UserItem userItem) throws Exception { 166 return LogonController.ACCOUNT_LOCKED == userItem.getStatus() || (LogonController.ACCOUNT_LOCKED != userItem.getStatus() && !userItem.getEnabled()); 167 } 168 }; 169 } 170 171 private static TableItemAction getDisableAccountAction() { 172 return new EditAccountTableAction("disable", 200, false, "/showAvailableAccounts.do?actionTarget=disable&username={0}") { 173 @Override 174 public boolean isEnabled(UserItem userItem) throws Exception { 175 return LogonController.ACCOUNT_LOCKED != userItem.getStatus() && userItem.getEnabled(); 176 } 177 }; 178 } 179 180 private static TableItemAction getResetPrivateKey() { 181 return new EditAccountTableAction("resetPrivateKey", 240, false, "/showAvailableAccounts.do?actionTarget=confirmResetPrivateKey&username={0}") { 182 @Override 183 public Permission[] getPermissions(ResourceType resourceType) { 184 return new Permission[] {}; 185 } 186 }; 187 } 188 189 private static TableItemAction getSendUserMessage() { 190 return new EditAccountTableAction("sendUserMessage", 290, false, "/showAvailableAccounts.do?actionTarget=sendMessage&username={0}") { 191 @Override 192 public Permission[] getPermissions(ResourceType resourceType) { 193 return new Permission[] {}; 194 } 195 }; 196 } 197 198 202 public AvailableMenuItem createAvailableMenuItem(MenuItem item, AvailableMenuItem parent, HttpServletRequest request, String referer, int checkNavigationContext, SessionInfo info) { 203 return new AvailableTableItemAction(item, parent, request, referer, checkNavigationContext, info); 204 } 205 } | Popular Tags |