use of com.microsoft.azure.sdk.iot.deps.serializer.AuthenticationParser in project azure-iot-sdk-java by Azure.
the class AuthenticationParserTest method testConstructor.
// Tests_SRS_AUTHENTICATION_PARSER_34_001: [This Constructor shall create a new instance of an authenticationParser object and return it.]
@Test
public void testConstructor() {
// act
AuthenticationParser parser = new AuthenticationParser();
// assert
assertNotNull(parser);
}
use of com.microsoft.azure.sdk.iot.deps.serializer.AuthenticationParser in project azure-iot-sdk-java by Azure.
the class AuthenticationParserTest method testThumbprintParserProperty.
// Tests_SRS_AUTHENTICATION_PARSER_34_004: [This method shall return the value of this object's thumbprint.]
// Tests_SRS_AUTHENTICATION_PARSER_34_005: [This method shall set the value of this object's thumbprint equal to the provided value.]
@Test
public void testThumbprintParserProperty() {
// arrange
AuthenticationParser parser = new AuthenticationParser();
X509ThumbprintParser thumbprintParser = new X509ThumbprintParser();
thumbprintParser.setPrimaryThumbprint("1234");
thumbprintParser.setSecondaryThumbprint("5678");
// act
parser.setThumbprint(thumbprintParser);
// assert
assertEquals(thumbprintParser, parser.getThumbprint());
}
use of com.microsoft.azure.sdk.iot.deps.serializer.AuthenticationParser in project azure-iot-sdk-java by Azure.
the class Tools method addModules.
private static void addModules(Iterable<Module> modules, String connectionString) throws IOException, IotHubException {
if (modules == null) {
throw new IllegalArgumentException("modules cannot be null");
}
IotHubConnectionString iotHubConnectionString = IotHubConnectionString.createConnectionString(connectionString);
URL url = getBulkDeviceAddUrl(iotHubConnectionString);
List<ExportImportDeviceParser> parsers = new ArrayList<>();
for (Module module : modules) {
ExportImportDeviceParser exportImportDevice = new ExportImportDeviceParser();
exportImportDevice.setId(module.getDeviceId());
exportImportDevice.setModuleId(module.getId());
AuthenticationParser authenticationParser = new AuthenticationParser();
if (module.getAuthenticationType() == AuthenticationType.SAS) {
authenticationParser.setType(AuthenticationTypeParser.SAS);
authenticationParser.setSymmetricKey(new SymmetricKeyParser(module.getSymmetricKey().getPrimaryKey(), module.getSymmetricKey().getSecondaryKey()));
} else {
authenticationParser.setType(AuthenticationTypeParser.SELF_SIGNED);
authenticationParser.setThumbprint(new X509ThumbprintParser(module.getPrimaryThumbprint(), module.getSecondaryThumbprint()));
}
exportImportDevice.setAuthentication(authenticationParser);
exportImportDevice.setImportMode(IMPORT_MODE_CREATE);
parsers.add(exportImportDevice);
}
ExportImportDevicesParser body = new ExportImportDevicesParser();
body.setExportImportDevices(parsers);
bulkRegistryOperation(body.toJson(), url, connectionString);
}
use of com.microsoft.azure.sdk.iot.deps.serializer.AuthenticationParser in project azure-iot-sdk-java by Azure.
the class Tools method addDevices.
private static void addDevices(Iterable<Device> devices, String connectionString) throws IOException, IotHubException {
if (devices == null) {
throw new IllegalArgumentException("devices cannot be null");
}
IotHubConnectionString iotHubConnectionString = IotHubConnectionString.createConnectionString(connectionString);
URL url = getBulkDeviceAddUrl(iotHubConnectionString);
List<ExportImportDeviceParser> parsers = new ArrayList<>();
for (Device device : devices) {
ExportImportDeviceParser exportImportDevice = new ExportImportDeviceParser();
exportImportDevice.setId(device.getDeviceId());
AuthenticationParser authenticationParser = new AuthenticationParser();
if (device.getAuthenticationType() == AuthenticationType.SAS) {
authenticationParser.setType(AuthenticationTypeParser.SAS);
authenticationParser.setSymmetricKey(new SymmetricKeyParser(device.getSymmetricKey().getPrimaryKey(), device.getSymmetricKey().getSecondaryKey()));
} else {
authenticationParser.setType(AuthenticationTypeParser.SELF_SIGNED);
authenticationParser.setThumbprint(new X509ThumbprintParser(device.getPrimaryThumbprint(), device.getSecondaryThumbprint()));
}
exportImportDevice.setAuthentication(authenticationParser);
exportImportDevice.setImportMode(IMPORT_MODE_CREATE);
parsers.add(exportImportDevice);
}
ExportImportDevicesParser body = new ExportImportDevicesParser();
body.setExportImportDevices(parsers);
bulkRegistryOperation(body.toJson(), url, connectionString);
}
use of com.microsoft.azure.sdk.iot.deps.serializer.AuthenticationParser in project azure-iot-sdk-java by Azure.
the class AuthenticationParserTest method testSymmetricKeyParserProperty.
// Tests_SRS_AUTHENTICATION_PARSER_34_006: [This method shall return the value of this object's symmetricKey.]
// Tests_SRS_AUTHENTICATION_PARSER_34_007: [This method shall set the value of symmetricKey equal to the provided value.]
@Test
public void testSymmetricKeyParserProperty() {
// arrange
AuthenticationParser parser = new AuthenticationParser();
SymmetricKeyParser symmetricKeyParser = new SymmetricKeyParser();
symmetricKeyParser.setPrimaryKey("1234");
symmetricKeyParser.setPrimaryKey("5678");
// act
parser.setSymmetricKey(symmetricKeyParser);
// assert
assertEquals(symmetricKeyParser, parser.getSymmetricKey());
}
Aggregations