📄 navigationbar.java
字号:
/*
* SSL-Explorer
*
* Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package com.sslexplorer.navigation;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.sslexplorer.core.CoreServlet;
import com.sslexplorer.core.CoreUtil;
import com.sslexplorer.core.MenuItem;
import com.sslexplorer.policyframework.Permission;
import com.sslexplorer.policyframework.PolicyConstants;
import com.sslexplorer.policyframework.ResourceType;
import com.sslexplorer.security.SessionInfo;
public class NavigationBar extends MenuTree {
public static final String NAV_BAR_MENU_TREE = "navBar";
final static Log log = LogFactory.getLog(NavigationBar.class);
public NavigationBar() {
super(NAV_BAR_MENU_TREE);
addMenuItem(null, new LaunchVPNClientMenuItem());
addMenuItem(null, new ShutdownVPNClientMenuItem());
addMenuItem(null, new MenuItem("home", "navigation", "/showHome.do", 200, true, "_self", SessionInfo.USER_CONSOLE_CONTEXT
| SessionInfo.MANAGEMENT_CONSOLE_CONTEXT));
addMenuItem(null, new MenuItem("managementConsole", "navigation", "/managementConsole.do", 300, true, "_self",
SessionInfo.USER_CONSOLE_CONTEXT) {
public boolean isAvailable(int checkNavigationContext, SessionInfo info, HttpServletRequest request) {
boolean available = super.isAvailable(checkNavigationContext, info, request);
if (available) {
try {
available = CoreServlet.getServlet().getPolicyDatabase().isAnyResourcePermissionAllowed(info.getUser(),
true, true, false)
&& CoreUtil.isMenuAvailable(request);
} catch (Exception e) {
log.error("Failed to determine delegation rights.", e);
available = false;
}
}
return available;
}
});
addMenuItem(null, new MenuItem("userConsole", "navigation", "/userConsole.do", 300, true, "_self",
SessionInfo.MANAGEMENT_CONSOLE_CONTEXT) {
public boolean isAvailable(int checkNavigationContext, SessionInfo info, HttpServletRequest request) {
boolean available = super.isAvailable(checkNavigationContext, info, request);
if (available) {
try {
available = CoreServlet.getServlet().getPolicyDatabase().isAnyResourcePermissionAllowed(info.getUser(),
true, true, false)
&& CoreUtil.isMenuAvailable(request);
} catch (Exception e) {
log.error("Failed to determine delegation rights.", e);
available = false;
}
}
return available;
}
});
addMenuItem(
null,
new MenuItem(
"help",
"navigation",
"javascript: this.blur(); windowRef = window.open('/help.do?source=help','help_win','left=20,top=20,width=320,height=480,toolbar=0,resizable=1,menubar=0,scrollbars=1'); windowRef.focus()",
400, true, "_self", SessionInfo.ALL_CONTEXTS));
addMenuItem(null, new MenuItem("logoff", "navigation", "/logoff.do", 500, true, "_self", SessionInfo.USER_CONSOLE_CONTEXT
| SessionInfo.MANAGEMENT_CONSOLE_CONTEXT));
}
class LaunchVPNClientMenuItem extends MenuItem {
LaunchVPNClientMenuItem() {
super("launchVPNClient", "navigation", "/launchVPNClient.do", 100, true, null, SessionInfo.USER_CONSOLE_CONTEXT
| SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, PolicyConstants.VPN_CLIENT_RESOURCE_TYPE,
new Permission[] { PolicyConstants.PERM_USE }, (ResourceType) null);
}
public boolean isAvailable(int checkNavigationContext, SessionInfo info, HttpServletRequest request) {
boolean available = super.isAvailable(checkNavigationContext, info, request);
if (available) {
available = !CoreUtil.isInWizard(request.getSession()) && !CoreUtil.isVPNClientAvailable(request.getSession())
&& CoreUtil.isMenuAvailable(request);
}
return available;
}
}
class ShutdownVPNClientMenuItem extends MenuItem {
ShutdownVPNClientMenuItem() {
super("shutdownVPNClient", "navigation", "/shutdownVPNClient.do", 100, true, null,
SessionInfo.USER_CONSOLE_CONTEXT | SessionInfo.MANAGEMENT_CONSOLE_CONTEXT,
PolicyConstants.VPN_CLIENT_RESOURCE_TYPE, new Permission[] { PolicyConstants.PERM_USE }, null);
}
public boolean isAvailable(int checkNavigationContext, SessionInfo info, HttpServletRequest request) {
boolean available = super.isAvailable(checkNavigationContext, info, request);
if (available) {
available = !CoreUtil.isInWizard(request.getSession()) && CoreUtil.isVPNClientAvailable(request.getSession())
&& CoreUtil.isMenuAvailable(request);
}
return available;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -