use of com.microsoft.azure.sdk.iot.device.hsm.parser.TrustBundleResponse in project azure-iot-sdk-java by Azure.
the class HttpsHsmTrustBundleProvider method getTrustBundleCerts.
/**
* Retrieve the list of certificates to be trusted as dictated by the HSM
* @param providerUri the provider uri of the HSM to communicate with
* @param apiVersion the api version to use
* @return the raw string containing all of the certificates to be trusted. May be one certificate or many certificates
* @throws URISyntaxException if the providerUri cannot be parsed as a uri
* @throws TransportException if the hsm cannot be reacheed
* @throws IOException if the hsm cannot be reached
* @throws HsmException if the hsm cannot give the trust bundle
*/
public String getTrustBundleCerts(String providerUri, String apiVersion) throws URISyntaxException, TransportException, IOException, HsmException {
// Codes_SRS_TRUSTBUNDLEPROVIDER_34_001: [This function shall create an HttpsHsmClient using the provided provider uri.]
HttpsHsmClient httpsHsmClient = new HttpsHsmClient(providerUri);
// Codes_SRS_TRUSTBUNDLEPROVIDER_34_002: [This function shall invoke getTrustBundle on the HttpsHsmClient and return the resulting certificates.]
TrustBundleResponse response = httpsHsmClient.getTrustBundle(apiVersion);
return response.getCertificates();
}
use of com.microsoft.azure.sdk.iot.device.hsm.parser.TrustBundleResponse in project azure-iot-sdk-java by Azure.
the class TrustBundleResponseTest method getCertificatesReturnsCertificates.
// Tests_SRS_TRUSTBUNDLERESPONSE_34_003: [This constructor shall create a new TrustBundleResponse from json.]
@Test
public void getCertificatesReturnsCertificates() {
// arrange
TrustBundleResponse response = TrustBundleResponse.fromJson(jsonWithTrustedCertificates);
// act
String certificates = response.getCertificates();
// assert
assertEquals(testCertificates, certificates);
}
use of com.microsoft.azure.sdk.iot.device.hsm.parser.TrustBundleResponse in project azure-iot-sdk-java by Azure.
the class TrustBundleResponseTest method constructorSavesCertificates.
// Tests_SRS_TRUSTBUNDLERESPONSE_34_001: [This function shall return the saved certificates string.]
@Test
public void constructorSavesCertificates() {
// act
TrustBundleResponse response = TrustBundleResponse.fromJson(jsonWithTrustedCertificates);
String certificates = Deencapsulation.getField(response, "certificates");
// assert
assertEquals(testCertificates, certificates);
}
Aggregations