Search in sources :

Example 1 with AttestationMechanism

use of com.microsoft.azure.sdk.iot.provisioning.service.configs.AttestationMechanism in project azure-iot-sdk-java by Azure.

the class EnrollmentGroupManager method getAttestationMechanism.

AttestationMechanism getAttestationMechanism(String enrollmentGroupId) throws ProvisioningServiceClientException {
    if (Tools.isNullOrEmpty(enrollmentGroupId)) {
        throw new IllegalArgumentException("enrollmentGroupId cannot be null or empty.");
    }
    String enrollmentAttestationMechanismPath = getEnrollmentGroupAttestationMechanismPath(enrollmentGroupId);
    String payload = "{}";
    HttpResponse httpResponse = contractApiHttp.request(HttpMethod.POST, enrollmentAttestationMechanismPath, null, payload);
    byte[] body = httpResponse.getBody();
    if (body == null) {
        throw new ProvisioningServiceClientServiceException("Unexpected empty body received from service");
    }
    return new AttestationMechanism(new String(body, StandardCharsets.UTF_8));
}
Also used : ProvisioningServiceClientServiceException(com.microsoft.azure.sdk.iot.provisioning.service.exceptions.ProvisioningServiceClientServiceException) HttpResponse(com.microsoft.azure.sdk.iot.deps.transport.http.HttpResponse) AttestationMechanism(com.microsoft.azure.sdk.iot.provisioning.service.configs.AttestationMechanism)

Aggregations

HttpResponse (com.microsoft.azure.sdk.iot.deps.transport.http.HttpResponse)1 AttestationMechanism (com.microsoft.azure.sdk.iot.provisioning.service.configs.AttestationMechanism)1 ProvisioningServiceClientServiceException (com.microsoft.azure.sdk.iot.provisioning.service.exceptions.ProvisioningServiceClientServiceException)1