vulnerabilityutil.java
来自「opennms得相关源码 请大家看看」· Java 代码 · 共 467 行 · 第 1/2 页
JAVA
467 行
//// This file is part of the OpenNMS(R) Application.//// OpenNMS(R) is Copyright (C) 2002-2003 The OpenNMS Group, Inc. All rights reserved.// OpenNMS(R) is a derivative work, containing both original code, included code and modified// code that was published under the GNU General Public License. Copyrights for modified // and included code are below.//// OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.//// Copyright (C) 1999-2001 Oculan Corp. 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.//// For more information contact:// OpenNMS Licensing <license@opennms.org>// http://www.opennms.org/// http://www.opennms.com///package org.opennms.web.vulnerability;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.StringTokenizer;import javax.servlet.http.HttpServletRequest;import org.opennms.web.Util;import org.opennms.web.event.Event;import org.opennms.web.vulnerability.filter.CreationDateAfterFilter;import org.opennms.web.vulnerability.filter.CreationDateBeforeFilter;import org.opennms.web.vulnerability.filter.Filter;import org.opennms.web.vulnerability.filter.IPLikeFilter;import org.opennms.web.vulnerability.filter.InterfaceFilter;import org.opennms.web.vulnerability.filter.NegativeInterfaceFilter;import org.opennms.web.vulnerability.filter.NegativeNodeFilter;import org.opennms.web.vulnerability.filter.NegativePortFilter;import org.opennms.web.vulnerability.filter.NegativeProtocolFilter;import org.opennms.web.vulnerability.filter.NegativeSeverityFilter;import org.opennms.web.vulnerability.filter.NodeFilter;import org.opennms.web.vulnerability.filter.NodeNameLikeFilter;import org.opennms.web.vulnerability.filter.PortFilter;import org.opennms.web.vulnerability.filter.ProtocolFilter;import org.opennms.web.vulnerability.filter.ResolvedDateAfterFilter;import org.opennms.web.vulnerability.filter.ResolvedDateBeforeFilter;import org.opennms.web.vulnerability.filter.SeverityFilter;/** * Convenient Java methods and constants for use in the vulnerability user * interface. * * <p> * <code>VulnerabilityUtil</code> is a place to put user interface-specific * code that is common among many JSPs or servlets. * </p> */public abstract class VulnerabilityUtil extends Object { protected static final HashMap colors; protected static final HashMap labels; protected static final HashMap icons; protected static final HashMap sortStyles; protected static final HashMap resTypes; protected static final List severities; public static final String FILTER_SERVLET_URL_BASE = "vulnerability/list"; static { // this lowest to highest order is mandatory, lots of code depends on it severities = new java.util.ArrayList(); severities.add(new Integer(Event.INDETERMINATE_SEVERITY)); severities.add(new Integer(Event.CLEARED_SEVERITY)); severities.add(new Integer(Event.NORMAL_SEVERITY)); severities.add(new Integer(Event.WARNING_SEVERITY)); severities.add(new Integer(Event.MINOR_SEVERITY)); severities.add(new Integer(Event.MAJOR_SEVERITY)); severities.add(new Integer(Event.CRITICAL_SEVERITY)); colors = new java.util.HashMap(); colors.put(new Integer(Event.INDETERMINATE_SEVERITY), "lightblue"); colors.put(new Integer(Event.CLEARED_SEVERITY), "white"); colors.put(new Integer(Event.NORMAL_SEVERITY), "green"); colors.put(new Integer(Event.WARNING_SEVERITY), "cyan"); colors.put(new Integer(Event.MINOR_SEVERITY), "yellow"); colors.put(new Integer(Event.MAJOR_SEVERITY), "orange"); colors.put(new Integer(Event.CRITICAL_SEVERITY), "red"); labels = new java.util.HashMap(); labels.put(new Integer(Event.INDETERMINATE_SEVERITY), "Indeterminate"); labels.put(new Integer(Event.CLEARED_SEVERITY), "Cleared"); labels.put(new Integer(Event.NORMAL_SEVERITY), "Normal"); labels.put(new Integer(Event.WARNING_SEVERITY), "Warning"); labels.put(new Integer(Event.MINOR_SEVERITY), "Minor"); labels.put(new Integer(Event.MAJOR_SEVERITY), "Major"); labels.put(new Integer(Event.CRITICAL_SEVERITY), "Critical"); // note several of these are null, for those use no icon icons = new java.util.HashMap(); icons.put(new Integer(Event.INDETERMINATE_SEVERITY), "images/alert_indeterminate_s.gif"); icons.put(new Integer(Event.CLEARED_SEVERITY), "images/alert_cleared_s.gif"); icons.put(new Integer(Event.NORMAL_SEVERITY), "images/alert_normal_s.gif"); icons.put(new Integer(Event.WARNING_SEVERITY), "images/alert_warning_s.gif"); icons.put(new Integer(Event.MINOR_SEVERITY), "images/alert_minor_s.gif"); icons.put(new Integer(Event.MAJOR_SEVERITY), "images/alert_major_s.gif"); icons.put(new Integer(Event.CRITICAL_SEVERITY), "images/alert_critical_s.gif"); sortStyles = new java.util.HashMap(); sortStyles.put("severity", VulnerabilityFactory.SortStyle.SEVERITY); sortStyles.put("node", VulnerabilityFactory.SortStyle.NODE); sortStyles.put("interface", VulnerabilityFactory.SortStyle.INTERFACE); sortStyles.put("service", VulnerabilityFactory.SortStyle.SERVICE); sortStyles.put("id", VulnerabilityFactory.SortStyle.ID); sortStyles.put("ctime", VulnerabilityFactory.SortStyle.CREATE_TIME); sortStyles.put("rtime", VulnerabilityFactory.SortStyle.RESOLVED_TIME); sortStyles.put("port", VulnerabilityFactory.SortStyle.PORT); sortStyles.put("protocol", VulnerabilityFactory.SortStyle.PROTOCOL); sortStyles.put("rev_severity", VulnerabilityFactory.SortStyle.REVERSE_SEVERITY); sortStyles.put("rev_node", VulnerabilityFactory.SortStyle.REVERSE_NODE); sortStyles.put("rev_interface", VulnerabilityFactory.SortStyle.REVERSE_INTERFACE); sortStyles.put("rev_service", VulnerabilityFactory.SortStyle.REVERSE_SERVICE); sortStyles.put("rev_id", VulnerabilityFactory.SortStyle.REVERSE_ID); sortStyles.put("rev_ctime", VulnerabilityFactory.SortStyle.REVERSE_CREATE_TIME); sortStyles.put("rev_rtime", VulnerabilityFactory.SortStyle.REVERSE_RESOLVED_TIME); sortStyles.put("rev_port", VulnerabilityFactory.SortStyle.REVERSE_PORT); sortStyles.put("rev_protocol", VulnerabilityFactory.SortStyle.REVERSE_PROTOCOL); sortStyles.put(VulnerabilityFactory.SortStyle.SEVERITY, "severity"); sortStyles.put(VulnerabilityFactory.SortStyle.NODE, "node"); sortStyles.put(VulnerabilityFactory.SortStyle.INTERFACE, "interface"); sortStyles.put(VulnerabilityFactory.SortStyle.SERVICE, "service"); sortStyles.put(VulnerabilityFactory.SortStyle.ID, "id"); sortStyles.put(VulnerabilityFactory.SortStyle.CREATE_TIME, "ctime"); sortStyles.put(VulnerabilityFactory.SortStyle.RESOLVED_TIME, "rtime"); sortStyles.put(VulnerabilityFactory.SortStyle.PORT, "port"); sortStyles.put(VulnerabilityFactory.SortStyle.PROTOCOL, "protocol"); sortStyles.put(VulnerabilityFactory.SortStyle.REVERSE_SEVERITY, "rev_severity"); sortStyles.put(VulnerabilityFactory.SortStyle.REVERSE_NODE, "rev_node"); sortStyles.put(VulnerabilityFactory.SortStyle.REVERSE_INTERFACE, "rev_interface"); sortStyles.put(VulnerabilityFactory.SortStyle.REVERSE_SERVICE, "rev_service"); sortStyles.put(VulnerabilityFactory.SortStyle.REVERSE_ID, "rev_id"); sortStyles.put(VulnerabilityFactory.SortStyle.REVERSE_CREATE_TIME, "rev_ctime"); sortStyles.put(VulnerabilityFactory.SortStyle.REVERSE_RESOLVED_TIME, "rev_rtime"); sortStyles.put(VulnerabilityFactory.SortStyle.REVERSE_PORT, "rev_port"); sortStyles.put(VulnerabilityFactory.SortStyle.REVERSE_PROTOCOL, "rev_protocol"); resTypes = new java.util.HashMap(); resTypes.put("res", VulnerabilityFactory.ResolutionType.RESOLVED); resTypes.put("open", VulnerabilityFactory.ResolutionType.OPEN); resTypes.put("both", VulnerabilityFactory.ResolutionType.BOTH); resTypes.put(VulnerabilityFactory.ResolutionType.RESOLVED, "res"); resTypes.put(VulnerabilityFactory.ResolutionType.OPEN, "open"); resTypes.put(VulnerabilityFactory.ResolutionType.BOTH, "both"); } public static List getSeverityList() { return severities; } public static int getSeverityId(int index) { return ((Integer) severities.get(index)).intValue(); } public static String getSeverityColor(int severity) { return ((String) colors.get(new Integer(severity))); } public static String getSeverityLabel(int severity) { return getSeverityLabel(new Integer(severity)); } public static String getSeverityLabel(Integer severity) { if (severity == null) { throw new IllegalArgumentException("Cannot take null parameters."); } return (String) labels.get(severity); } /** * Can return null, in that case, use no icon. */ public static String getSeverityIcon(int severity) { return getSeverityIcon(new Integer(severity)); } /** * Can return null, in that case, use no icon. */ public static String getSeverityIcon(Integer severity) { if (severity == null) { throw new IllegalArgumentException("Cannot take null parameters."); } return (String) icons.get(severity); } public static VulnerabilityFactory.SortStyle getSortStyle(String sortStyleString) { if (sortStyleString == null) { throw new IllegalArgumentException("Cannot take null parameters."); } return (VulnerabilityFactory.SortStyle) sortStyles.get(sortStyleString.toLowerCase()); } public static String getSortStyleString(VulnerabilityFactory.SortStyle sortStyle) { if (sortStyle == null) { throw new IllegalArgumentException("Cannot take null parameters."); } return (String) sortStyles.get(sortStyle); } public static VulnerabilityFactory.ResolutionType getResolutionType(String resTypeString) { if (resTypeString == null) { throw new IllegalArgumentException("Cannot take null parameters."); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?