use of com.microsoft.azure.sdk.iot.deps.serializer.X509ThumbprintParser in project azure-iot-sdk-java by Azure.
the class X509ThumbprintParserTest method testGettersAndSetters.
// Tests_SRS_X509ThumbprintParser_34_001: [This method shall return the value of primaryThumbprint]
// Tests_SRS_X509ThumbprintParser_34_003: [This method shall set the value of primaryThumbprint to the provided value.]
// Tests_SRS_X509ThumbprintParser_34_004: [This method shall return the value of secondaryThumbprint]
// Tests_SRS_X509ThumbprintParser_34_006: [This method shall set the value of secondaryThumbprint to the provided value.]
@Test
public void testGettersAndSetters() {
// arrange
X509ThumbprintParser parser = new X509ThumbprintParser();
// act
parser.setPrimaryThumbprint(SAMPLE_THUMBPRINT1);
parser.setSecondaryThumbprint(SAMPLE_THUMBPRINT2);
// assert
assertEquals(SAMPLE_THUMBPRINT1, parser.getPrimaryThumbprintFinal());
assertEquals(SAMPLE_THUMBPRINT2, parser.getSecondaryThumbprintFinal());
}
use of com.microsoft.azure.sdk.iot.deps.serializer.X509ThumbprintParser in project azure-iot-sdk-java by Azure.
the class X509ThumbprintParserTest method testFromThumbprints.
// Tests_SRS_X509ThumbprintParser_34_008: [The parser shall create and return an instance of a X509ThumbprintParser object that holds the provided primary and secondary thumbprints.]
@Test
public void testFromThumbprints() {
// act
X509ThumbprintParser parser = new X509ThumbprintParser(SAMPLE_THUMBPRINT1, SAMPLE_THUMBPRINT2);
// assert
String actualPrimaryThumbprint = Deencapsulation.getField(parser, "primaryThumbprint");
String actualSecondaryThumbprint = Deencapsulation.getField(parser, "secondaryThumbprint");
assertEquals(SAMPLE_THUMBPRINT1, actualPrimaryThumbprint);
assertEquals(SAMPLE_THUMBPRINT2, actualSecondaryThumbprint);
}
use of com.microsoft.azure.sdk.iot.deps.serializer.X509ThumbprintParser 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.X509ThumbprintParser 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.X509ThumbprintParser 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);
}
Aggregations