@Test public void validateSignalingParams_Invalid() { HashMap<String, Object> settingParams = new HashMap<String, Object>(); try { getFilledHashMapWithValidPush(settingParams); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_USERNAME); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, ""); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_USERNAME); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, 10); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_ICE_SERVER_DISCOVERY_TYPE); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CUSTOM); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY_NO_ICE_SERVERS); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CUSTOM); List<Map<String, String>> listMediaIceServers = new ArrayList<>(); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS, listMediaIceServers); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY_NO_ICE_SERVERS); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CUSTOM); List<Map<String, String>> listMediaIceServers = new ArrayList<>(); Map<String, String> value = new HashMap<>(); value.put("", ""); listMediaIceServers.add(value); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS, listMediaIceServers); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledWithMediaParams(settingParams); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_URL, "media_ice_url"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledWithMediaParams(settingParams); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME, "media_ice_username"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledWithMediaParams(settingParams); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD, "media_ice_password"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledWithMediaParams(settingParams); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN, "media_ice_domain"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } try { settingParams = new HashMap<String, Object>(); getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); List<Map<String, String>> listMediaIceServers = new ArrayList<>(); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS, listMediaIceServers); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V3); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_ICE_SERVERS_NOT_CUSTOM_DISCOVERY); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V3); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_URL); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V3); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_URL, "media_ice_url"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_USERNAME); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V3); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_URL, "media_ice_url"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME, "media_ice_username"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_PASSWORD); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V3); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_URL, "media_ice_url"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME, "media_ice_username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD, "media_ice_password"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_DOMAIN); } }
@SuppressWarnings("unchecked") public static void validateSettingsParms(HashMap<String, Object> parameters) throws RCException { validatePushSettings(parameters); if (!parameters.containsKey(RCDevice.ParameterKeys.SIGNALING_USERNAME) || parameters.get(RCDevice.ParameterKeys.SIGNALING_USERNAME).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_USERNAME); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE)) { parameters.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V2); } else { RCDevice.MediaIceServersDiscoveryType iceServersDiscoveryType; if (parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE) instanceof Enum){ iceServersDiscoveryType = (RCDevice.MediaIceServersDiscoveryType)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE); } else { int discoveryType = (int)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE); if (discoveryType >= RCDevice.MediaIceServersDiscoveryType.values().length || discoveryType < 0){ throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_ICE_SERVER_DISCOVERY_TYPE); }else { iceServersDiscoveryType = RCDevice.MediaIceServersDiscoveryType.values()[discoveryType]; } } if (iceServersDiscoveryType == RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CUSTOM) { if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS) == null || ((List<Map<String,String>>) parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS)).size() == 0) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY_NO_ICE_SERVERS); } List<Map<String, String>> iceServers = (List<Map<String, String>>)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS); for (Map<String, String> iceServer : iceServers) { if (!iceServer.containsKey(RCConnection.IceServersKeys.ICE_SERVER_URL) || iceServer.get(RCConnection.IceServersKeys.ICE_SERVER_URL).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } } if (parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_URL) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN)) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } } else { if (parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS)) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_ICE_SERVERS_NOT_CUSTOM_DISCOVERY); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_URL) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_URL).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_URL); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_USERNAME); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_PASSWORD); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_DOMAIN); } } } }
RCUtils { @SuppressWarnings("unchecked") public static void validateSettingsParms(HashMap<String, Object> parameters) throws RCException { validatePushSettings(parameters); if (!parameters.containsKey(RCDevice.ParameterKeys.SIGNALING_USERNAME) || parameters.get(RCDevice.ParameterKeys.SIGNALING_USERNAME).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_USERNAME); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE)) { parameters.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V2); } else { RCDevice.MediaIceServersDiscoveryType iceServersDiscoveryType; if (parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE) instanceof Enum){ iceServersDiscoveryType = (RCDevice.MediaIceServersDiscoveryType)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE); } else { int discoveryType = (int)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE); if (discoveryType >= RCDevice.MediaIceServersDiscoveryType.values().length || discoveryType < 0){ throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_ICE_SERVER_DISCOVERY_TYPE); }else { iceServersDiscoveryType = RCDevice.MediaIceServersDiscoveryType.values()[discoveryType]; } } if (iceServersDiscoveryType == RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CUSTOM) { if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS) == null || ((List<Map<String,String>>) parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS)).size() == 0) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY_NO_ICE_SERVERS); } List<Map<String, String>> iceServers = (List<Map<String, String>>)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS); for (Map<String, String> iceServer : iceServers) { if (!iceServer.containsKey(RCConnection.IceServersKeys.ICE_SERVER_URL) || iceServer.get(RCConnection.IceServersKeys.ICE_SERVER_URL).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } } if (parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_URL) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN)) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } } else { if (parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS)) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_ICE_SERVERS_NOT_CUSTOM_DISCOVERY); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_URL) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_URL).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_URL); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_USERNAME); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_PASSWORD); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_DOMAIN); } } } } }
RCUtils { @SuppressWarnings("unchecked") public static void validateSettingsParms(HashMap<String, Object> parameters) throws RCException { validatePushSettings(parameters); if (!parameters.containsKey(RCDevice.ParameterKeys.SIGNALING_USERNAME) || parameters.get(RCDevice.ParameterKeys.SIGNALING_USERNAME).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_USERNAME); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE)) { parameters.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V2); } else { RCDevice.MediaIceServersDiscoveryType iceServersDiscoveryType; if (parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE) instanceof Enum){ iceServersDiscoveryType = (RCDevice.MediaIceServersDiscoveryType)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE); } else { int discoveryType = (int)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE); if (discoveryType >= RCDevice.MediaIceServersDiscoveryType.values().length || discoveryType < 0){ throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_ICE_SERVER_DISCOVERY_TYPE); }else { iceServersDiscoveryType = RCDevice.MediaIceServersDiscoveryType.values()[discoveryType]; } } if (iceServersDiscoveryType == RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CUSTOM) { if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS) == null || ((List<Map<String,String>>) parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS)).size() == 0) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY_NO_ICE_SERVERS); } List<Map<String, String>> iceServers = (List<Map<String, String>>)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS); for (Map<String, String> iceServer : iceServers) { if (!iceServer.containsKey(RCConnection.IceServersKeys.ICE_SERVER_URL) || iceServer.get(RCConnection.IceServersKeys.ICE_SERVER_URL).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } } if (parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_URL) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN)) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } } else { if (parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS)) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_ICE_SERVERS_NOT_CUSTOM_DISCOVERY); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_URL) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_URL).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_URL); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_USERNAME); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_PASSWORD); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_DOMAIN); } } } }  }
RCUtils { @SuppressWarnings("unchecked") public static void validateSettingsParms(HashMap<String, Object> parameters) throws RCException { validatePushSettings(parameters); if (!parameters.containsKey(RCDevice.ParameterKeys.SIGNALING_USERNAME) || parameters.get(RCDevice.ParameterKeys.SIGNALING_USERNAME).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_USERNAME); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE)) { parameters.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V2); } else { RCDevice.MediaIceServersDiscoveryType iceServersDiscoveryType; if (parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE) instanceof Enum){ iceServersDiscoveryType = (RCDevice.MediaIceServersDiscoveryType)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE); } else { int discoveryType = (int)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE); if (discoveryType >= RCDevice.MediaIceServersDiscoveryType.values().length || discoveryType < 0){ throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_ICE_SERVER_DISCOVERY_TYPE); }else { iceServersDiscoveryType = RCDevice.MediaIceServersDiscoveryType.values()[discoveryType]; } } if (iceServersDiscoveryType == RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CUSTOM) { if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS) == null || ((List<Map<String,String>>) parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS)).size() == 0) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY_NO_ICE_SERVERS); } List<Map<String, String>> iceServers = (List<Map<String, String>>)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS); for (Map<String, String> iceServer : iceServers) { if (!iceServer.containsKey(RCConnection.IceServersKeys.ICE_SERVER_URL) || iceServer.get(RCConnection.IceServersKeys.ICE_SERVER_URL).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } } if (parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_URL) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN)) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } } else { if (parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS)) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_ICE_SERVERS_NOT_CUSTOM_DISCOVERY); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_URL) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_URL).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_URL); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_USERNAME); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_PASSWORD); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_DOMAIN); } } } }  static void validateDeviceParms(HashMap<String, Object> parameters); @SuppressWarnings("unchecked") static void validateSettingsParms(HashMap<String, Object> parameters); static void validateConnectionParms(HashMap<String, Object> parameters); static boolean shouldRegisterForPush(HashMap<String, Object> parameters, StorageManagerInterface storageManagerInterface); }
RCUtils { @SuppressWarnings("unchecked") public static void validateSettingsParms(HashMap<String, Object> parameters) throws RCException { validatePushSettings(parameters); if (!parameters.containsKey(RCDevice.ParameterKeys.SIGNALING_USERNAME) || parameters.get(RCDevice.ParameterKeys.SIGNALING_USERNAME).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_USERNAME); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE)) { parameters.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V2); } else { RCDevice.MediaIceServersDiscoveryType iceServersDiscoveryType; if (parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE) instanceof Enum){ iceServersDiscoveryType = (RCDevice.MediaIceServersDiscoveryType)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE); } else { int discoveryType = (int)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE); if (discoveryType >= RCDevice.MediaIceServersDiscoveryType.values().length || discoveryType < 0){ throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_ICE_SERVER_DISCOVERY_TYPE); }else { iceServersDiscoveryType = RCDevice.MediaIceServersDiscoveryType.values()[discoveryType]; } } if (iceServersDiscoveryType == RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CUSTOM) { if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS) == null || ((List<Map<String,String>>) parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS)).size() == 0) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY_NO_ICE_SERVERS); } List<Map<String, String>> iceServers = (List<Map<String, String>>)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS); for (Map<String, String> iceServer : iceServers) { if (!iceServer.containsKey(RCConnection.IceServersKeys.ICE_SERVER_URL) || iceServer.get(RCConnection.IceServersKeys.ICE_SERVER_URL).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } } if (parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_URL) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN)) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } } else { if (parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS)) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_ICE_SERVERS_NOT_CUSTOM_DISCOVERY); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_URL) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_URL).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_URL); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_USERNAME); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_PASSWORD); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_DOMAIN); } } } }  static void validateDeviceParms(HashMap<String, Object> parameters); @SuppressWarnings("unchecked") static void validateSettingsParms(HashMap<String, Object> parameters); static void validateConnectionParms(HashMap<String, Object> parameters); static boolean shouldRegisterForPush(HashMap<String, Object> parameters, StorageManagerInterface storageManagerInterface);  }