IndividualEnrollment Class
- java.
lang. Object - java.
io. Serializable - Serializable
- com.
microsoft. azure. sdk. iot. provisioning. service. configs. IndividualEnrollment
- com.
- java.
public class IndividualEnrollment extends Serializable
Representation of a single Device Provisioning Service enrollment with a JSON serializer and deserializer.
This object is used to send IndividualEnrollment information to the provisioning service, or receive IndividualEnrollment information from the provisioning service.
To create or update an IndividualEnrollment on the provisioning service you should fill this object and call the public API createOrUpdateIndividualEnrollment(IndividualEnrollment individualEnrollment). The minimum information required by the provisioning service is theregistrationId
</code> and the <code>attestation
</code> .</p>
A new device can be provisioned by three attestation mechanisms, Trust Platform Module (see TpmAttestation), X509 (see X509Attestation) or SymmetricKeyAttestation mechanism. The definition of each one you should use depending on the physical authentication hardware that the device contains.
The content of this class will be serialized in a JSON format and sent as a body of the rest API to the provisioning service.
When serialized, an IndividualEnrollment will look like the following example:
{
"registrationId":"validRegistrationId",
"deviceId":"ContosoDevice-123",
"attestation":{
"type":"tpm",
"tpm":{
"endorsementKey":"validEndorsementKey"
}
},
"iotHubHostName":"ContosoIoTHub.azure-devices.net",
"provisioningStatus":"enabled"
}
The content of this class can be filled by a JSON, received from the provisioning service, as result of a IndividualEnrollment operation like create, update, or query enrollment.
The following JSON is a sample or the IndividualEnrollment response, received from the provisioning service.
{
"registrationId":"validRegistrationId",
"deviceId":"ContosoDevice-123",
"attestation":{
"type":"tpm",
"tpm":{
"endorsementKey":"validEndorsementKey"
}
},
"iotHubHostName":"ContosoIoTHub.azure-devices.net",
"provisioningStatus":"enabled"
"createdDateTimeUtc": "2017-09-28T16:29:42.3447817Z",
"lastUpdatedDateTimeUtc": "2017-09-28T16:29:42.3447817Z",
"etag": "\"00000000-0000-0000-0000-00000000000\""
}
Constructor Summary
Constructor
Description
IndividualEnrollment(String json)
CONSTRUCTOR
This constructor creates an instance of the enrollment filling the class with the information provided in the JSON. It is used by the SDK to parse enrollment responses from the provisioning service.
The following JSON is a sample of the IndividualEnrollment response, received from the provisioning service.
{
"registrationId":"validRegistrationId",
"deviceId":"ContosoDevice-123",
"attestation":{
"type":"tpm",
"tpm":{
"endorsementKey":"validEndorsementKey"
}
},
"iotHubHostName":"ContosoIoTHub.azure-devices.net",
"provisioningStatus":"enabled"
"createdDateTimeUtc": "2017-09-28T16:29:42.3447817Z",
"lastUpdatedDateTimeUtc": "2017-09-28T16:29:42.3447817Z",
"etag": "\"00000000-0000-0000-0000-00000000000\""
}
IndividualEnrollment(String registrationId, Attestation attestation)
CONSTRUCTOR
This constructor creates an instance of the enrollment with the minimum set of information required by the provisioning service. A valid enrollment must contain the registrationId, which uniquely identify this enrollment, and the attestation mechanism, which can be TPM, X509 or SymmetricKey.
Other parameters can be added by calling the setters on this class.
When serialized, an IndividualEnrollment will look like the following example:
{
"registrationId":"validRegistrationId",
"attestation":{
"type":"tpm",
"tpm":{
"endorsementKey":"validEndorsementKey"
}
}
}
Method Summary
Modifier and Type
Method and Description
Attestation
getAttestation()
Getter for the attestation mechanism.
void
setAttestation(Attestation attestation)
Setter for the attestation.
Attestation mechanism is a mandatory parameter that provides the mechanism type and the necessary keys/certificates
final void
setAttestation(AttestationMechanism attestationMechanism)
Setter for the attestation.
Attestation mechanism is a mandatory parameter that provides the mechanism type and the necessary keys/certificates
JsonElement
toJsonElement()
Serializer
Creates aJsonElement
</code> , which the content represents the information in this class and its subclasses in a JSON format.</p>
This is useful if the caller will integrate this JSON with JSON from other classes to generate a consolidated JSON.
Inherited Members
Constructor Details
IndividualEnrollment
public IndividualEnrollment(String json)
CONSTRUCTOR
This constructor creates an instance of the enrollment filling the class with the information provided in the JSON. It is used by the SDK to parse enrollment responses from the provisioning service.
The following JSON is a sample of the IndividualEnrollment response, received from the provisioning service.
{
"registrationId":"validRegistrationId",
"deviceId":"ContosoDevice-123",
"attestation":{
"type":"tpm",
"tpm":{
"endorsementKey":"validEndorsementKey"
}
},
"iotHubHostName":"ContosoIoTHub.azure-devices.net",
"provisioningStatus":"enabled"
"createdDateTimeUtc": "2017-09-28T16:29:42.3447817Z",
"lastUpdatedDateTimeUtc": "2017-09-28T16:29:42.3447817Z",
"etag": "\"00000000-0000-0000-0000-00000000000\""
}
Parameters:
json
- theString
</code> with the JSON received from the provisioning service. </p>
Throws:
IllegalArgumentException
- If the provided JSON is null, empty, or invalid.
IndividualEnrollment
public IndividualEnrollment(String registrationId, Attestation attestation)
CONSTRUCTOR
This constructor creates an instance of the enrollment with the minimum set of information required by the provisioning service. A valid enrollment must contain the registrationId, which uniquely identify this enrollment, and the attestation mechanism, which can be TPM, X509 or SymmetricKey.
Other parameters can be added by calling the setters on this class.
When serialized, an IndividualEnrollment will look like the following example:
{
"registrationId":"validRegistrationId",
"attestation":{
"type":"tpm",
"tpm":{
"endorsementKey":"validEndorsementKey"
}
}
}
Parameters:
registrationId
- theString
</code> with an unique id for this enrollment. </p>
attestation
- the Attestation mechanism that can be TpmAttestation, X509Attestation or SymmetricKeyAttestation.
Throws:
IllegalArgumentException
- If one of the provided parameters is not correct.
Method Details
getAttestation
public Attestation getAttestation()
Getter for the attestation mechanism.
Returns:
TheAttestation
</code> with the attestation content. It cannot be<code>null
</code> . </p>
Throws:
ProvisioningServiceClientException
- If the type of the attestation mechanism is unknown.
setAttestation
public void setAttestation(Attestation attestation)
Setter for the attestation.
Attestation mechanism is a mandatory parameter that provides the mechanism type and the necessary keys/certificates
Parameters:
attestation
- the Attestation with the new attestation mechanism. It can be TpmAttestation, X509Attestation or SymmetricKeyAttestation.
Throws:
IllegalArgumentException
- If the provided attestation mechanism isnull
</code> . </p>
setAttestation
protected final void setAttestation(AttestationMechanism attestationMechanism)
Setter for the attestation.
Attestation mechanism is a mandatory parameter that provides the mechanism type and the necessary keys/certificates
Parameters:
attestationMechanism
- theAttestationMechanism
</code> with the new attestation mechanism. It can be `tpm`, `x509` or `SymmetricKey`. </p>
Throws:
IllegalArgumentException
- If the provided attestation mechanism isnull
</code> or invalid. </p>
toJsonElement
public JsonElement toJsonElement()
Serializer
Creates aJsonElement
</code> , which the content represents the information in this class and its subclasses in a JSON format.</p>
This is useful if the caller will integrate this JSON with JSON from other classes to generate a consolidated JSON.
Returns:
TheJsonElement
</code> with the content of this class. </p>
Applies to
Azure SDK for Java