Search in sources :

Example 6 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 getterForAliasCertPemSucceeds.

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

Example 7 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 getterForDeviceSignerCertificatesSucceeds.

// SRS_SecurityClientDiceEmulator_25_008: [ This method shall return Signer certificates generated by DICE ]
@Test
public void getterForDeviceSignerCertificatesSucceeds() throws Exception {
    // arrange
    SecurityProviderDiceEmulator testSecurityClientDiceEmulator = new SecurityProviderDiceEmulator(TEST_ALIAS, TEST_SIGNER, TEST_ROOT);
    // act
    Collection<X509Certificate> cert = testSecurityClientDiceEmulator.getIntermediateCertificatesChain();
    // assert
    assertNotNull(cert);
    assertFalse(cert.isEmpty());
}
Also used : SecurityProviderDiceEmulator(com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderDiceEmulator) X509Certificate(java.security.cert.X509Certificate) Test(org.junit.Test)

Example 8 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 generateLeafCertThrowsOnEmptyID.

@Test(expected = SecurityProviderException.class)
public void generateLeafCertThrowsOnEmptyID() throws Exception {
    // arrange
    SecurityProviderDiceEmulator testSecurityClientDiceEmulator = new SecurityProviderDiceEmulator(TEST_ALIAS, TEST_SIGNER, TEST_ROOT);
    // act
    testSecurityClientDiceEmulator.generateLeafCert("");
}
Also used : SecurityProviderDiceEmulator(com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderDiceEmulator) Test(org.junit.Test)

Example 9 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 getterForAliasKeySucceeds.

// SRS_SecurityClientDiceEmulator_25_007: [ This method shall return Alias private key generated by DICE ]
@Test
public void getterForAliasKeySucceeds() throws Exception {
    // arrange
    SecurityProviderDiceEmulator testSecurityClientDiceEmulator = new SecurityProviderDiceEmulator(TEST_ALIAS, TEST_SIGNER, TEST_ROOT);
    // act
    Key aliasKey = testSecurityClientDiceEmulator.getClientPrivateKey();
    // assert
    assertNotNull(aliasKey);
}
Also used : SecurityProviderDiceEmulator(com.microsoft.azure.sdk.iot.provisioning.security.hsm.SecurityProviderDiceEmulator) Key(java.security.Key) Test(org.junit.Test)

Example 10 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 constructorWithNamesSucceeds.

@Test
public void constructorWithNamesSucceeds() throws Exception {
    // act
    SecurityProviderDiceEmulator testSecurityClientDiceEmulator = new SecurityProviderDiceEmulator(TEST_ALIAS, TEST_SIGNER, TEST_ROOT);
    // assert
    assertEquals(TEST_ALIAS, Deencapsulation.getField(testSecurityClientDiceEmulator, "commonNameAlias"));
    assertEquals(TEST_SIGNER, Deencapsulation.getField(testSecurityClientDiceEmulator, "commonNameSigner"));
    assertEquals(TEST_ROOT, Deencapsulation.getField(testSecurityClientDiceEmulator, "commonNameRoot"));
}
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