public static void setAZTracker(URL tracker_url, boolean az_tracker) { String key = tracker_url.getHost() + ":" + tracker_url.getPort(); synchronized (az_trackers) { boolean changed = false; if (az_trackers.get(key) == null) { if (az_tracker) { az_trackers.put(key, new Long(SystemTime.getCurrentTime())); changed = true; } } else { if (!az_tracker) { if (az_trackers.remove(key) != null) { changed = true; } } } if (changed) { COConfigurationManager.setParameter("Tracker Client AZ Instances", az_trackers); } } }
public AuthenticatorWindow() { SESecurityManager.addPasswordListener(this); // System.out.println( "AuthenticatorWindow"); Map cache = COConfigurationManager.getMapParameter(CONFIG_PARAM, new HashMap()); try { Iterator it = cache.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String key = (String) entry.getKey(); Map value = (Map) entry.getValue(); String user = new String((byte[]) value.get("user"), "UTF-8"); char[] pw = new String((byte[]) value.get("pw"), "UTF-8").toCharArray(); auth_cache.put(key, new authCache(key, new PasswordAuthentication(user, pw), true)); } } catch (Throwable e) { COConfigurationManager.setParameter(CONFIG_PARAM, new HashMap()); Debug.printStackTrace(e); } }
public static void setUDPProbeResult(URL tracker_url, boolean probe_ok) { String key = tracker_url.getHost(); synchronized (udp_probe_results) { boolean changed = false; if (udp_probe_results.get(key) == null) { if (probe_ok) { // arbitrary max size here just in case something weird happens if (udp_probe_results.size() > 512) { udp_probe_results.clear(); } udp_probe_results.put(key, new Long(SystemTime.getCurrentTime())); changed = true; } } else { if (!probe_ok) { if (udp_probe_results.remove(key) != null) { changed = true; } } } if (changed) { COConfigurationManager.setParameter("Tracker Client UDP Probe Results", udp_probe_results); } } }
protected void saveAuthCache() { try { this_mon.enter(); HashMap map = new HashMap(); Iterator it = auth_cache.values().iterator(); while (it.hasNext()) { authCache value = (authCache) it.next(); if (value.isPersistent()) { try { HashMap entry_map = new HashMap(); entry_map.put("user", value.getAuth().getUserName().getBytes("UTF-8")); entry_map.put("pw", new String(value.getAuth().getPassword()).getBytes("UTF-8")); map.put(value.getKey(), entry_map); } catch (Throwable e) { Debug.printStackTrace(e); } } } COConfigurationManager.setParameter(CONFIG_PARAM, map); } finally { this_mon.exit(); } }