Search in sources :

Example 1 with SecurityProviderDiceEmulator

use of com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderDiceEmulator in project azure-iot-sdk-java by Azure.

the class SecurityProviderDiceEmulatorTest method getterForRootCertPemSucceeds.

// SRS_SecurityClientDiceEmulator_25_011: [ This method shall return Root certificate generated by DICE as PEM string ]
@Test
public void getterForRootCertPemSucceeds() throws Exception {
    // arrange
    SecurityProviderDiceEmulator testSecurityClientDiceEmulator = new SecurityProviderDiceEmulator(TEST_ALIAS, TEST_SIGNER, TEST_ROOT);
    // act
    String cert = testSecurityClientDiceEmulator.getRootCertPem();
    // assert
    assertNotNull(cert);
}
Also used : SecurityProviderDiceEmulator(com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderDiceEmulator) Test(org.junit.Test)

Example 2 with SecurityProviderDiceEmulator

use of com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderDiceEmulator in project azure-iot-sdk-java by Azure.

the class SecurityProviderDiceEmulatorTest method constructorSucceeds.

// SRS_SecurityClientDiceEmulator_25_001: [ Constructor shall create a default unique names for Alias Certificate, Signer Certificate and Root certificate ]
// SRS_SecurityClientDiceEmulator_25_002: [ Constructor shall create a diceBundle by calling CreateDeviceAuthBundle ]
@Test
public void constructorSucceeds() throws Exception {
    // act
    SecurityProviderDiceEmulator testSecurityClientDiceEmulator = new SecurityProviderDiceEmulator();
    // assert
    assertNotNull(Deencapsulation.getField(testSecurityClientDiceEmulator, "commonNameAlias"));
    assertNotNull(Deencapsulation.getField(testSecurityClientDiceEmulator, "commonNameSigner"));
    assertNotNull(Deencapsulation.getField(testSecurityClientDiceEmulator, "commonNameRoot"));
}
Also used : SecurityProviderDiceEmulator(com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderDiceEmulator) Test(org.junit.Test)

Example 3 with SecurityProviderDiceEmulator

use of com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderDiceEmulator in project azure-iot-sdk-java by Azure.

the class SecurityProviderDiceEmulatorTest method getterForSignerCertPemSucceeds.

// SRS_SecurityClientDiceEmulator_25_010: [ This method shall return Signer certificate generated by DICE as PEM string ]
@Test
public void getterForSignerCertPemSucceeds() throws Exception {
    // arrange
    SecurityProviderDiceEmulator testSecurityClientDiceEmulator = new SecurityProviderDiceEmulator(TEST_ALIAS, TEST_SIGNER, TEST_ROOT);
    // act
    String cert = testSecurityClientDiceEmulator.getSignerCertPem();
    // assert
    assertNotNull(cert);
}
Also used : SecurityProviderDiceEmulator(com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderDiceEmulator) Test(org.junit.Test)

Example 4 with SecurityProviderDiceEmulator

use of com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderDiceEmulator in project azure-iot-sdk-java by Azure.

the class SecurityProviderDiceEmulatorTest method generateLeafCertThrowsOnNullID.

// SRS_SecurityClientDiceEmulator_25_012: [ This method shall return Leaf certificate generated by DICE with unique ID as common Name in PEM Format ]
@Test(expected = SecurityProviderException.class)
public void generateLeafCertThrowsOnNullID() throws Exception {
    // arrange
    SecurityProviderDiceEmulator testSecurityClientDiceEmulator = new SecurityProviderDiceEmulator(TEST_ALIAS, TEST_SIGNER, TEST_ROOT);
    // act
    testSecurityClientDiceEmulator.generateLeafCert(null);
}
Also used : SecurityProviderDiceEmulator(com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderDiceEmulator) Test(org.junit.Test)

Example 5 with SecurityProviderDiceEmulator

use of com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderDiceEmulator in project azure-iot-sdk-java by Azure.

the class SecurityProviderDiceEmulatorTest method getterForCommonNameSucceeds.

// SRS_SecurityClientDiceEmulator_25_005: [ This method shall return Root certificate name as common name ]
@Test
public void getterForCommonNameSucceeds() throws Exception {
    // arrange
    SecurityProviderDiceEmulator testSecurityClientDiceEmulator = new SecurityProviderDiceEmulator(TEST_ALIAS, TEST_SIGNER, TEST_ROOT);
    // act
    String cName = testSecurityClientDiceEmulator.getClientCertificateCommonName();
    // assert
    assertEquals(cName, TEST_ALIAS);
}
Also used : SecurityProviderDiceEmulator(com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderDiceEmulator) Test(org.junit.Test)

Aggregations

SecurityProviderDiceEmulator (com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderDiceEmulator)12 Test (org.junit.Test)11 X509Certificate (java.security.cert.X509Certificate)2 SecurityProviderException (com.microsoft.azure.sdk.iot.provisioning.security.exceptions.SecurityProviderException)1 Key (java.security.Key)1 Scanner (java.util.Scanner)1