Device Class

public class Device
extends BaseDevice

The Device class extends the BaseDevice class implementing constructors and serialization functionality.

Field Summary

Modifier and Type Field and Description
protected DeviceCapabilities capabilities
protected DeviceStatus status

"Enabled", "Disabled".

protected java.lang.String statusReason

A 128 char long string storing the reason of suspension.

protected java.lang.String statusUpdatedTime

Datetime of last time the state was updated.

Constructor Summary

Modifier Constructor Description
protected Device(String deviceId, DeviceStatus status, SymmetricKey symmetricKey)

Create an Device instance using the given device name

Method Summary

Modifier and Type Method and Description
static Device createDevice(String deviceId, AuthenticationType authenticationType)

Static create function Creates device object using the given name that will use a Certificate Authority signed certificate for authentication.

static Device createFromId(String deviceId, DeviceStatus status, SymmetricKey symmetricKey)

Static create function Creates device object using the given name.

DeviceCapabilities getCapabilities()

Getter for capabilities

java.lang.String getScope()

Get the security scope for this device

DeviceStatus getStatus()

Getter for DeviceStatus object

java.lang.String getStatusReason()

Getter for status reason

java.lang.String getStatusUpdatedTime()

Getter for status updated time string

void setCapabilities(DeviceCapabilities capabilities)

Setter for DeviceCapabilities object

void setScope(String scope)

Set the security scope for this device

void setStatus(DeviceStatus status)

Setter for DeviceStatus object

Methods inherited from BaseDevice

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Field Details

capabilities

protected DeviceCapabilities capabilities

status

protected DeviceStatus status

"Enabled", "Disabled". If "Enabled", this device is authorized to connect. If "Disabled" this device cannot receive or send messages, and statusReason must be set.

statusReason

protected String statusReason

A 128 char long string storing the reason of suspension. (all UTF-8 chars allowed).

statusUpdatedTime

protected String statusUpdatedTime

Datetime of last time the state was updated.

Constructor Details

Device

protected Device(String deviceId, DeviceStatus status, SymmetricKey symmetricKey)

Create an Device instance using the given device name

Parameters:

deviceId - Name of the device (used as device id)
status -
  • Device status. If parameter is null, then the status will be set to Enabled.
symmetricKey -
  • Device key. If parameter is null, then the key will be auto generated.

Throws:

java.lang.IllegalArgumentException - This exception is thrown if the encryption method is not supported by the keyGenerator

Method Details

createDevice

public static Device createDevice(String deviceId, AuthenticationType authenticationType)

Static create function Creates device object using the given name that will use a Certificate Authority signed certificate for authentication. If input device status is null then it will be auto generated.

Parameters:

deviceId -
  • String containing the device name
authenticationType -
  • The type of authentication used by this device.

Returns:

Device object

createFromId

public static Device createFromId(String deviceId, DeviceStatus status, SymmetricKey symmetricKey)

Static create function Creates device object using the given name. If input device status and symmetric key are null then they will be auto generated.

Parameters:

deviceId -
  • String containing the device name
status -
  • Device status. If parameter is null, then the status will be set to Enabled.
symmetricKey -
  • Device key. If parameter is null, then the key will be auto generated.

Returns:

Device object

Throws:

java.lang.IllegalArgumentException - This exception is thrown if deviceId is null or empty.

getCapabilities

public DeviceCapabilities getCapabilities()

Getter for capabilities

Returns:

The DeviceCapabilities containing capabilites that are enabled on the device

getScope

public String getScope()

Get the security scope for this device

Returns:

the security scope for this device

getStatus

public DeviceStatus getStatus()

Getter for DeviceStatus object

Returns:

The deviceStatus object

getStatusReason

public String getStatusReason()

Getter for status reason

Returns:

The statusReason string

getStatusUpdatedTime

public String getStatusUpdatedTime()

Getter for status updated time string

Returns:

The string containing the time when the statusUpdated parameter was updated

setCapabilities

public void setCapabilities(DeviceCapabilities capabilities)

Setter for DeviceCapabilities object

Parameters:

capabilities - capabilities to be set

setScope

public void setScope(String scope)

Set the security scope for this device

Parameters:

scope - the security scope to set

setStatus

public void setStatus(DeviceStatus status)

Setter for DeviceStatus object

Parameters:

status - status to be set

Applies to

Azure SDK for Java

Preview