IotHubConnectionString Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.device.IotHubConnectionString

public class IotHubConnectionString

Parser for the Iothub connection string.

Constructor Summary

Constructor Description
IotHubConnectionString(String connectionString)

CONSTRUCTOR.

IotHubConnectionString(String hostName, String deviceId, String sharedAccessKey, String sharedAccessToken)

Constructor.

IotHubConnectionString(String hostName, String deviceId, String sharedAccessKey, String sharedAccessToken, String gatewayHostName)

Method Summary

Modifier and Type Method and Description
java.lang.String getDeviceId()

Getter for the deviceId.

java.lang.String getGatewayHostName()
java.lang.String getHostName()

Getter for the hostName.

java.lang.String getHubName()

Getter for the hubName.

java.lang.String getModuleId()
java.lang.String getSharedAccessKey()

Getter for the sharedAccessKey.

java.lang.String getSharedAccessToken()

Getter for the sharedAccessToken.

boolean isUsingX509()

Getter for UsingX509

void setSharedAccessToken(String sharedAccessToken)

Setter for the shared access token

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

Constructor Details

IotHubConnectionString

public IotHubConnectionString(String connectionString)

CONSTRUCTOR.

Parameters:

connectionString - is the iothub connection string to parse.

Throws:

java.lang.IllegalArgumentException - if the provided connectionString is null, empty, or not valid or if the hostName in the connection string is not a valid URI.
java.lang.SecurityException - if the provided connectionString is null, empty, or not valid or if the hostName in the connection string is not a valid URI.
java.net.URISyntaxException - if the provided connectionString is null, empty, or not valid or if the hostName in the connection string is not a valid URI.

IotHubConnectionString

public IotHubConnectionString(String hostName, String deviceId, String sharedAccessKey, String sharedAccessToken)

Constructor.

Parameters:

hostName - the IoT Hub hostname.
deviceId - the device ID.
sharedAccessKey - the device key.
sharedAccessToken - the shared access token.

Throws:

java.lang.IllegalArgumentException - if the IoT Hub hostname does not contain a valid IoT Hub name as its prefix or if the IoT Hub hostname does not conform to RFC 3986.
java.net.URISyntaxException - if the IoT Hub hostname does not contain a valid IoT Hub name as its prefix or if the IoT Hub hostname does not conform to RFC 3986.

IotHubConnectionString

public IotHubConnectionString(String hostName, String deviceId, String sharedAccessKey, String sharedAccessToken, String gatewayHostName)

Parameters:

hostName
deviceId
sharedAccessKey
sharedAccessToken
gatewayHostName

Throws:

java.lang.IllegalArgumentException
java.net.URISyntaxException

Method Details

getDeviceId

public String getDeviceId()

Getter for the deviceId.

Returns:

string with the deviceId in the connectionString

getGatewayHostName

public String getGatewayHostName()

getHostName

public String getHostName()

Getter for the hostName.

Returns:

string with the hostName in the connectionString

getHubName

public String getHubName()

Getter for the hubName.

Returns:

string with the hubName in the connectionString

getModuleId

public String getModuleId()

getSharedAccessKey

public String getSharedAccessKey()

Getter for the sharedAccessKey.

Returns:

string with the sharedAccessKey in the connectionString. It can be null.

getSharedAccessToken

public String getSharedAccessToken()

Getter for the sharedAccessToken.

Returns:

string with the sharedAccessToken in the connectionString. It can be null.

isUsingX509

public boolean isUsingX509()

Getter for UsingX509

Returns:

The value of UsingX509

setSharedAccessToken

public void setSharedAccessToken(String sharedAccessToken)

Setter for the shared access token

Parameters:

sharedAccessToken - the new token value to set

Throws:

java.lang.IllegalArgumentException - if the provided value is null or empty

Applies to