/* * (non-Javadoc) * * @see com.adito.vpn.util.ApplicationLauncher#processLauncherElement(com.adito.vpn.util.XMLElement) */ protected boolean processLauncherElement(XMLElement element) { if (element.getName().equalsIgnoreCase("registry")) { Enumeration e = element.enumerateChildren(); while (e.hasMoreElements()) { XMLElement el = (XMLElement) e.nextElement(); processRegistryElements(el); } return true; } else return false; }
protected void createTunnel(XMLElement e) throws IOException { String hostname = (String) e.getAttribute("hostname"); // $NON-NLS-1$ String name = (String) e.getAttribute("name"); // $NON-NLS-1$ int port = Integer.parseInt((String) e.getAttribute("port")); // $NON-NLS-1$ boolean usePreferredPort = ("true".equals(e.getAttribute("usePreferredPort"))); // $NON-NLS-1$ //$NON-NLS-2$ boolean singleConnection = !("false".equals(e.getAttribute("singleConnection"))); // $NON-NLS-1$ //$NON-NLS-2$ boolean localhostWorkaround = "true".equals(e.getAttribute("localhostWorkaround")); // $NON-NLS-1$ //$NON-NLS-2$ if (events != null) { TunnelConfiguration listeningSocketConfiguration = events.createTunnel( name, hostname, port, usePreferredPort, singleConnection, localhostWorkaround ? "127.0.0.2" : agent.getConfiguration().getLocalhostAddress()); tunnels.addElement(listeningSocketConfiguration); } else throw new IOException( Messages.getString("ApplicationLauncher.tunnelRequiredButNoEventHandler")); // $NON-NLS-1$ }
private void processRegistryElements(XMLElement el) { if (el.getName().equalsIgnoreCase("get")) { String scope = el.getStringAttribute("scope"); String key = replaceTokens(el.getStringAttribute("key")); String value = replaceTokens(el.getStringAttribute("value")); String param = replaceTokens(el.getStringAttribute("parameter")); String defaultValue = replaceTokens(el.getStringAttribute("default")); addParameter( param, WinRegistry.getRegistryValue( scope, key, value, defaultValue == null ? "" : defaultValue)); } else if (el.getName().equalsIgnoreCase("set")) { String scope = el.getStringAttribute("scope"); String key = replaceTokens(el.getStringAttribute("key")); String value = replaceTokens(el.getStringAttribute("value")); String arg = replaceTokens(el.getStringAttribute("arg")); WinRegistry.setRegistryValue(scope, key, value, arg); } else if (el.getName().equalsIgnoreCase("if")) { String scope = el.getStringAttribute("scope"); String key = replaceTokens(el.getStringAttribute("key")); String value = replaceTokens(el.getStringAttribute("value")); String notAttr = el.getStringAttribute("not"); String existsAttr = el.getStringAttribute("exists"); String equalsAttr = el.getStringAttribute("equals"); if (existsAttr != null) { boolean exists = Boolean.getBoolean(existsAttr); String v = WinRegistry.getRegistryValue(scope, key, value, "DEFAULT_VALUE"); if (v.equals("DEFAULT_VALUE") && !exists) { processRegistryElements(el); } else if (!v.equals("DEFAULT_VALUE") && exists) { processRegistryElements(el); } } else if (notAttr != null) { boolean not = Boolean.getBoolean(notAttr == null ? "false" : notAttr); String v = WinRegistry.getRegistryValue(scope, key, value, ""); if (equalsAttr.equals(v) && !not) { processRegistryElements(el); } else if (!equalsAttr.equals(v) && not) { processRegistryElements(el); } } } }