From: Marcus <the...@us...> - 2004-03-21 17:39:22
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11632 Modified Files: ScannerConfig.java Log Message: removed standalone support Index: ScannerConfig.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner/ScannerConfig.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ScannerConfig.java 16 Dec 2003 10:55:15 -0000 1.3 --- ScannerConfig.java 21 Mar 2004 17:29:11 -0000 1.4 *************** *** 1,3 **** ! /* * juNK - a file search system for smb shares * --- 1,3 ---- ! /* * juNK - a file search system for smb shares * *************** *** 46,84 **** * plugin configuration key defining the sleep time of the scanner thread */ ! protected static final String THREAD_SLEEP_KEY = "thread-sleep"; ! /** plugin configuration key defining the scanning interval */ ! protected static final String SCAN_INTERVAL_KEY = "scan-interval"; ! /** plugin configuration key defining the ip range */ ! protected static final String IP_RANGE_KEY = "ip-range"; ! /** plugin configuration key defining the tcp timeout */ ! protected static final String TCP_TO_KEY = "tcp-timeout"; ! /** plugin configuration key defining the save map path */ ! protected static final String SAVE_MAP_KEY = "map-save-file"; ! /** log writer */ private Log log = LogFactory.getLog(ScannerPlugin.class); ! /** the time the scannerthread sleeps */ private long sleep = 10000; ! /** the scanning interval */ private long interval = 300000; ! /** the tcp timeout */ private int tcpTimeout = 100; ! /** the path to load and save the hostmap to */ private String savemappath = "data/hostmap"; ! /** the ip subnets to scan over */ private ArrayList ipSubnets = null; ! /** initial ipsubnetsString */ private String ipSubnetsString = null; ! /** Creates a new instance of ScannerConfig. * protected standard constructor to prevent instantiation outside --- 46,84 ---- * plugin configuration key defining the sleep time of the scanner thread */ ! protected static final String KEY_THREAD_SLEEP = "thread-sleep"; ! /** plugin configuration key defining the scanning interval */ ! protected static final String KEY_SCAN_INTERVAL = "scan-interval"; ! /** plugin configuration key defining the ip range */ ! protected static final String KEY_IP_RANGE = "ip-range"; ! /** plugin configuration key defining the tcp timeout */ ! protected static final String KEY_TCP_TO = "tcp-timeout"; ! /** plugin configuration key defining the save map path */ ! protected static final String KEY_SAVE_MAP = "map-save-file"; ! /** log writer */ private Log log = LogFactory.getLog(ScannerPlugin.class); ! /** the time the scannerthread sleeps */ private long sleep = 10000; ! /** the scanning interval */ private long interval = 300000; ! /** the tcp timeout */ private int tcpTimeout = 100; ! /** the path to load and save the hostmap to */ private String savemappath = "data/hostmap"; ! /** the ip subnets to scan over */ private ArrayList ipSubnets = null; ! /** initial ipsubnetsString */ private String ipSubnetsString = null; ! /** Creates a new instance of ScannerConfig. * protected standard constructor to prevent instantiation outside *************** *** 87,91 **** protected ScannerConfig() { } ! /** Creates a new instance of ScannerConfig. * @param m ModuleConfig --- 87,91 ---- protected ScannerConfig() { } ! /** Creates a new instance of ScannerConfig. * @param m ModuleConfig *************** *** 95,121 **** */ protected ScannerConfig(ActionServlet a, ModuleConfig m) ! throws IllegalArgumentException { HashMap conf = null; PlugInConfig[] pluginConfigs = m.findPlugInConfigs(); ! //get the config... there has to be another way to get it for (int x = 0; x < pluginConfigs.length; x++) { if (pluginConfigs[x].getClassName() ! .equals(ScannerPlugin.class.getName())) { conf = (HashMap) pluginConfigs[x].getProperties(); ! break; //leave loop if config found } } ! if (conf == null) { throw new IllegalArgumentException("plugin config not found"); } ! String path = a.getServletContext().getRealPath("/WEB-INF"); ! this.applyConfig(conf, path); } ! /** To provide a StandAlone config * @param h the standalone config --- 95,121 ---- */ protected ScannerConfig(ActionServlet a, ModuleConfig m) ! throws IllegalArgumentException { HashMap conf = null; PlugInConfig[] pluginConfigs = m.findPlugInConfigs(); ! //get the config... there has to be another way to get it for (int x = 0; x < pluginConfigs.length; x++) { if (pluginConfigs[x].getClassName() ! .equals(ScannerPlugin.class.getName())) { conf = (HashMap) pluginConfigs[x].getProperties(); ! break; //leave loop if config found } } ! if (conf == null) { throw new IllegalArgumentException("plugin config not found"); } ! String path = a.getServletContext().getRealPath("/WEB-INF"); ! this.applyConfig(conf, path); } ! /** To provide a StandAlone config * @param h the standalone config *************** *** 124,128 **** this.applyConfig(h, null); } ! /** Apply the config values. * @param conf configuration values --- 124,128 ---- this.applyConfig(h, null); } ! /** Apply the config values. * @param conf configuration values *************** *** 132,161 **** */ private void applyConfig(HashMap conf, String basepath) ! throws IllegalArgumentException { try { this.sleep = Long.parseLong( ! (String) conf.get( ! ScannerConfig.THREAD_SLEEP_KEY)); } catch (Exception e) { ! log.warn("Loading parameter " + ScannerConfig.THREAD_SLEEP_KEY ! + " FAILED, defaulting to " + this.sleep, e); } ! try { this.interval = Long.parseLong( ! (String) conf.get( ! ScannerConfig.SCAN_INTERVAL_KEY)); } catch (Exception e) { ! log.warn("Loading parameter " + ScannerConfig.SCAN_INTERVAL_KEY ! + "FAILED, defaulting to " + this.interval, e); } ! try { ! String subnetConfigs = (String) conf.get(ScannerConfig.IP_RANGE_KEY); this.ipSubnetsString = subnetConfigs; ! String[] scArray = subnetConfigs.split(","); this.ipSubnets = new ArrayList(scArray.length); ! for (int x = 0; x < scArray.length; x++) { this.ipSubnets.add(x, new IpSubnet(scArray[x])); --- 132,161 ---- */ private void applyConfig(HashMap conf, String basepath) ! throws IllegalArgumentException { try { this.sleep = Long.parseLong( ! (String) conf.get( ! ScannerConfig.KEY_THREAD_SLEEP)); } catch (Exception e) { ! log.warn("Loading parameter " + ScannerConfig.KEY_THREAD_SLEEP ! + " FAILED, defaulting to " + this.sleep, e); } ! try { this.interval = Long.parseLong( ! (String) conf.get( ! ScannerConfig.KEY_SCAN_INTERVAL)); } catch (Exception e) { ! log.warn("Loading parameter " + ScannerConfig.KEY_SCAN_INTERVAL ! + "FAILED, defaulting to " + this.interval, e); } ! try { ! String subnetConfigs = (String) conf.get(ScannerConfig.KEY_IP_RANGE); this.ipSubnetsString = subnetConfigs; ! String[] scArray = subnetConfigs.split(","); this.ipSubnets = new ArrayList(scArray.length); ! for (int x = 0; x < scArray.length; x++) { this.ipSubnets.add(x, new IpSubnet(scArray[x])); *************** *** 164,191 **** //this value cannot be defaulted, so failing ist fatal. throw new IllegalArgumentException("Loading parameter " ! + ScannerConfig.IP_RANGE_KEY ! + " FAILED. (" + e.getMessage() ! + ")"); } ! try { this.tcpTimeout = Integer.parseInt( ! (String) conf.get( ! ScannerConfig.TCP_TO_KEY)); } catch (Exception e) { ! log.warn("Loading parameter " + ScannerConfig.TCP_TO_KEY ! + " FAILED, defaulting to " + this.tcpTimeout, e); } ! try { ! String filename = (String) conf.get(ScannerConfig.SAVE_MAP_KEY); this.savemappath = basepath + File.separatorChar + ".." ! + File.separatorChar + filename; } catch (Exception e) { ! log.warn("Loading parameter " + ScannerConfig.SAVE_MAP_KEY ! + " FAILED, defaulting to " + this.savemappath, e); } } ! /** Returns the sleep value. * @return returns the sleep value --- 164,191 ---- //this value cannot be defaulted, so failing ist fatal. throw new IllegalArgumentException("Loading parameter " ! + ScannerConfig.KEY_IP_RANGE ! + " FAILED. (" + e.getMessage() ! + ")"); } ! try { this.tcpTimeout = Integer.parseInt( ! (String) conf.get( ! ScannerConfig.KEY_TCP_TO)); } catch (Exception e) { ! log.warn("Loading parameter " + ScannerConfig.KEY_TCP_TO ! + " FAILED, defaulting to " + this.tcpTimeout, e); } ! try { ! String filename = (String) conf.get(ScannerConfig.KEY_SAVE_MAP); this.savemappath = basepath + File.separatorChar + ".." ! + File.separatorChar + filename; } catch (Exception e) { ! log.warn("Loading parameter " + ScannerConfig.KEY_SAVE_MAP ! + " FAILED, defaulting to " + this.savemappath, e); } } ! /** Returns the sleep value. * @return returns the sleep value *************** *** 194,198 **** return this.sleep; } ! /** Returns the interval value. * @return returns the interval value --- 194,198 ---- return this.sleep; } ! /** Returns the interval value. * @return returns the interval value *************** *** 201,205 **** return this.interval; } ! /** Returns the tcp timeout value. * @return tcp timeout --- 201,205 ---- return this.interval; } ! /** Returns the tcp timeout value. * @return tcp timeout *************** *** 208,212 **** return this.tcpTimeout; } ! /** Returns an iterator over the configured ip subnets. * @return an iterator over the configured ip subnets --- 208,212 ---- return this.tcpTimeout; } ! /** Returns an iterator over the configured ip subnets. * @return an iterator over the configured ip subnets *************** *** 215,219 **** return this.ipSubnets.iterator(); } ! /** Returns the path to the saved hostmap. * @return the path to the saved hostmap --- 215,219 ---- return this.ipSubnets.iterator(); } ! /** Returns the path to the saved hostmap. * @return the path to the saved hostmap *************** *** 222,226 **** return this.savemappath; } ! /** return the initial ipSubnets String * @return initial ipsubnets String --- 222,226 ---- return this.savemappath; } ! /** return the initial ipSubnets String * @return initial ipsubnets String |