@Test public final void testReadArguments2() { System.setProperty(AbstractReader.STUN_FIRST_IP, "wrong"); SystemPropertyReader sysPropReader = new SystemPropertyReader(); try { sysPropReader.readArguments(stunArgs, relayArgs, mediatorArgs); } catch(IllegalArgumentException e) { fail("Should not be here!"); } System.clearProperty(AbstractReader.STUN_FIRST_IP); }
@Override public void readArguments(List<String> stunArgs, List<String> relayArgs, List<String> mediatorArgs) throws IllegalArgumentException { SecurityManager securityManager = System.getSecurityManager(); if (securityManager != null) { try { securityManager.checkPropertiesAccess(); } catch (SecurityException e) { logError("Security manager prohibits access to system properties!"); logError(e.getMessage()); return; } } Properties props = System.getProperties(); Enumeration<?> propEnumeration = props.propertyNames(); while (propEnumeration.hasMoreElements()) { try { String key = propEnumeration.nextElement().toString(); if (key.equals(STUN_FIRST_IP)) { String value = props.getProperty(key); processStunFirstIP(stunArgs, value); } else if (key.equals(STUN_SECOND_IP)) { String value = props.getProperty(key); processStunSecondIP(stunArgs, value); } else if (key.equals(RELAY_PORT)) { String value = props.getProperty(key); processRelayPort(relayArgs, value); } else if (key.equals(MEDIATOR_PORT)) { String value = props.getProperty(key); processMediatorPort(mediatorArgs, value); } else if (key.equals(MEDIATOR_ITERATION)) { String value = props.getProperty(key); processMediatorIteration(mediatorArgs, value); } else if (key.equals(MEDIATOR_LIFETIME)) { String value = props.getProperty(key); processMediatorLifeTime(mediatorArgs, value); } } catch (IllegalArgumentException e) { logError("Argument \"" + e.getMessage() + "\" is empty or invalid"); continue; } } }
SystemPropertyReader extends AbstractReader { @Override public void readArguments(List<String> stunArgs, List<String> relayArgs, List<String> mediatorArgs) throws IllegalArgumentException { SecurityManager securityManager = System.getSecurityManager(); if (securityManager != null) { try { securityManager.checkPropertiesAccess(); } catch (SecurityException e) { logError("Security manager prohibits access to system properties!"); logError(e.getMessage()); return; } } Properties props = System.getProperties(); Enumeration<?> propEnumeration = props.propertyNames(); while (propEnumeration.hasMoreElements()) { try { String key = propEnumeration.nextElement().toString(); if (key.equals(STUN_FIRST_IP)) { String value = props.getProperty(key); processStunFirstIP(stunArgs, value); } else if (key.equals(STUN_SECOND_IP)) { String value = props.getProperty(key); processStunSecondIP(stunArgs, value); } else if (key.equals(RELAY_PORT)) { String value = props.getProperty(key); processRelayPort(relayArgs, value); } else if (key.equals(MEDIATOR_PORT)) { String value = props.getProperty(key); processMediatorPort(mediatorArgs, value); } else if (key.equals(MEDIATOR_ITERATION)) { String value = props.getProperty(key); processMediatorIteration(mediatorArgs, value); } else if (key.equals(MEDIATOR_LIFETIME)) { String value = props.getProperty(key); processMediatorLifeTime(mediatorArgs, value); } } catch (IllegalArgumentException e) { logError("Argument \"" + e.getMessage() + "\" is empty or invalid"); continue; } } } }
SystemPropertyReader extends AbstractReader { @Override public void readArguments(List<String> stunArgs, List<String> relayArgs, List<String> mediatorArgs) throws IllegalArgumentException { SecurityManager securityManager = System.getSecurityManager(); if (securityManager != null) { try { securityManager.checkPropertiesAccess(); } catch (SecurityException e) { logError("Security manager prohibits access to system properties!"); logError(e.getMessage()); return; } } Properties props = System.getProperties(); Enumeration<?> propEnumeration = props.propertyNames(); while (propEnumeration.hasMoreElements()) { try { String key = propEnumeration.nextElement().toString(); if (key.equals(STUN_FIRST_IP)) { String value = props.getProperty(key); processStunFirstIP(stunArgs, value); } else if (key.equals(STUN_SECOND_IP)) { String value = props.getProperty(key); processStunSecondIP(stunArgs, value); } else if (key.equals(RELAY_PORT)) { String value = props.getProperty(key); processRelayPort(relayArgs, value); } else if (key.equals(MEDIATOR_PORT)) { String value = props.getProperty(key); processMediatorPort(mediatorArgs, value); } else if (key.equals(MEDIATOR_ITERATION)) { String value = props.getProperty(key); processMediatorIteration(mediatorArgs, value); } else if (key.equals(MEDIATOR_LIFETIME)) { String value = props.getProperty(key); processMediatorLifeTime(mediatorArgs, value); } } catch (IllegalArgumentException e) { logError("Argument \"" + e.getMessage() + "\" is empty or invalid"); continue; } } } SystemPropertyReader(); }
SystemPropertyReader extends AbstractReader { @Override public void readArguments(List<String> stunArgs, List<String> relayArgs, List<String> mediatorArgs) throws IllegalArgumentException { SecurityManager securityManager = System.getSecurityManager(); if (securityManager != null) { try { securityManager.checkPropertiesAccess(); } catch (SecurityException e) { logError("Security manager prohibits access to system properties!"); logError(e.getMessage()); return; } } Properties props = System.getProperties(); Enumeration<?> propEnumeration = props.propertyNames(); while (propEnumeration.hasMoreElements()) { try { String key = propEnumeration.nextElement().toString(); if (key.equals(STUN_FIRST_IP)) { String value = props.getProperty(key); processStunFirstIP(stunArgs, value); } else if (key.equals(STUN_SECOND_IP)) { String value = props.getProperty(key); processStunSecondIP(stunArgs, value); } else if (key.equals(RELAY_PORT)) { String value = props.getProperty(key); processRelayPort(relayArgs, value); } else if (key.equals(MEDIATOR_PORT)) { String value = props.getProperty(key); processMediatorPort(mediatorArgs, value); } else if (key.equals(MEDIATOR_ITERATION)) { String value = props.getProperty(key); processMediatorIteration(mediatorArgs, value); } else if (key.equals(MEDIATOR_LIFETIME)) { String value = props.getProperty(key); processMediatorLifeTime(mediatorArgs, value); } } catch (IllegalArgumentException e) { logError("Argument \"" + e.getMessage() + "\" is empty or invalid"); continue; } } } SystemPropertyReader(); @Override void readArguments(List<String> stunArgs, List<String> relayArgs, List<String> mediatorArgs); }
SystemPropertyReader extends AbstractReader { @Override public void readArguments(List<String> stunArgs, List<String> relayArgs, List<String> mediatorArgs) throws IllegalArgumentException { SecurityManager securityManager = System.getSecurityManager(); if (securityManager != null) { try { securityManager.checkPropertiesAccess(); } catch (SecurityException e) { logError("Security manager prohibits access to system properties!"); logError(e.getMessage()); return; } } Properties props = System.getProperties(); Enumeration<?> propEnumeration = props.propertyNames(); while (propEnumeration.hasMoreElements()) { try { String key = propEnumeration.nextElement().toString(); if (key.equals(STUN_FIRST_IP)) { String value = props.getProperty(key); processStunFirstIP(stunArgs, value); } else if (key.equals(STUN_SECOND_IP)) { String value = props.getProperty(key); processStunSecondIP(stunArgs, value); } else if (key.equals(RELAY_PORT)) { String value = props.getProperty(key); processRelayPort(relayArgs, value); } else if (key.equals(MEDIATOR_PORT)) { String value = props.getProperty(key); processMediatorPort(mediatorArgs, value); } else if (key.equals(MEDIATOR_ITERATION)) { String value = props.getProperty(key); processMediatorIteration(mediatorArgs, value); } else if (key.equals(MEDIATOR_LIFETIME)) { String value = props.getProperty(key); processMediatorLifeTime(mediatorArgs, value); } } catch (IllegalArgumentException e) { logError("Argument \"" + e.getMessage() + "\" is empty or invalid"); continue; } } } SystemPropertyReader(); @Override void readArguments(List<String> stunArgs, List<String> relayArgs, List<String> mediatorArgs);  }