in iothub/device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device/IotHubConnectionString.java [241:277]
private static void validateTerms(String hostName, String deviceId,
String sharedAccessKey, String sharedAccessToken, boolean usingX509)
throws IllegalArgumentException
{
if ((hostName == null) || hostName.isEmpty())
{
throw new IllegalArgumentException("IoT Hub hostName cannot be null.");
}
try
{
new URI(hostName);
}
catch (URISyntaxException e)
{
throw new IllegalArgumentException("Host name did not contain a valid URI", e);
}
parseHubName(hostName);
if ((deviceId == null) || deviceId.isEmpty())
{
throw new IllegalArgumentException("Device ID cannot be null.");
}
if ((sharedAccessKey != null) && (sharedAccessToken != null))
{
throw new IllegalArgumentException("Either of device key or Shared Access Signature should be provided, but not both.");
}
if (!usingX509
&& ((sharedAccessKey == null) || sharedAccessKey.isEmpty())
&& ((sharedAccessToken == null) || sharedAccessToken.isEmpty()))
{
throw new IllegalArgumentException("Device key and Shared Access Signature both cannot be null unless using x509 authentication.");
}
}