IotHubSasTokenSoftwareAuthenticationProvider Class

public class IotHubSasTokenSoftwareAuthenticationProvider
extends IotHubSasTokenAuthenticationProvider

Field Summary

Modifier and Type Field and Description
protected java.lang.String deviceKey

Constructor Summary

Constructor Description
IotHubSasTokenSoftwareAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId, String deviceKey, String sharedAccessToken)

Constructor that takes a connection string containing a sas token or a device key and uses the default token valid seconds and timeBufferPercentage

IotHubSasTokenSoftwareAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId, String deviceKey, String sharedAccessToken, int tokenValidSecs, int timeBufferPercentage)

Constructor that takes a connection string containing a sas token or a device key

IotHubSasTokenSoftwareAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId, String deviceKey, String sharedAccessToken, SSLContext sslContext)

Constructor that takes a connection string containing a sas token or a device key and uses the default token valid seconds and timeBufferPercentage

Method Summary

Modifier and Type Method and Description
boolean canRefreshToken()
char[] getSasToken()

Getter for SasToken.

boolean isAuthenticationProviderRenewalNecessary()

Returns true if the saved sas token has expired and cannot be auto-renewed through the device key

void setTokenValidSecs(long tokenValidSecs)

Methods inherited from IotHubAuthenticationProvider

Methods inherited from IotHubSasTokenAuthenticationProvider

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

deviceKey

protected String deviceKey

Constructor Details

IotHubSasTokenSoftwareAuthenticationProvider

public IotHubSasTokenSoftwareAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId, String deviceKey, String sharedAccessToken)

Constructor that takes a connection string containing a sas token or a device key and uses the default token valid seconds and timeBufferPercentage

Parameters:

hostname - the IotHub host name
gatewayHostname - The gateway hostname to use, or null if connecting to an IotHub
deviceId - the IotHub device id
moduleId - the module id. May be null if not using a module
deviceKey - the device key for the device. Must be null if the provided sharedAccessToken is not
sharedAccessToken - the sas token string for accessing the device. Must be null if the provided deviceKey is not.

Throws:

java.lang.SecurityException - if the provided sas token has expired

IotHubSasTokenSoftwareAuthenticationProvider

public IotHubSasTokenSoftwareAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId, String deviceKey, String sharedAccessToken, int tokenValidSecs, int timeBufferPercentage)

Constructor that takes a connection string containing a sas token or a device key

Parameters:

hostname - the IotHub host name
gatewayHostname - The gateway hostname to use, or null if connecting to an IotHub
deviceId - the IotHub device id
moduleId - the module id. May be null if not using a module
deviceKey - the device key for the device. Must be null if the provided sharedAccessToken is not
sharedAccessToken - the sas token string for accessing the device. Must be null if the provided deviceKey is not.
tokenValidSecs - the number of seconds that the token will be valid for
timeBufferPercentage - the percent of the sas token's life that will be exhausted before renewal is attempted

Throws:

java.lang.SecurityException - if the provided sas token has expired

IotHubSasTokenSoftwareAuthenticationProvider

public IotHubSasTokenSoftwareAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId, String deviceKey, String sharedAccessToken, SSLContext sslContext)

Constructor that takes a connection string containing a sas token or a device key and uses the default token valid seconds and timeBufferPercentage

Parameters:

hostname - the IotHub host name
gatewayHostname - The gateway hostname to use, or null if connecting to an IotHub
deviceId - the IotHub device id
moduleId - the module id. May be null if not using a module
deviceKey - the device key for the device. Must be null if the provided sharedAccessToken is not
sharedAccessToken - the sas token string for accessing the device. Must be null if the provided deviceKey is not.
sslContext - the sslContext to use for SSL negotiation

Throws:

java.lang.SecurityException - if the provided sas token has expired

Method Details

canRefreshToken

public boolean canRefreshToken()

Overrides:

IotHubSasTokenSoftwareAuthenticationProvider.canRefreshToken()

getSasToken

public char[] getSasToken()

Getter for SasToken. If the saved token has expired, this method shall renew it if possible

Overrides:

IotHubSasTokenSoftwareAuthenticationProvider.getSasToken()

Returns:

The value of SasToken

Throws:

java.io.IOException

isAuthenticationProviderRenewalNecessary

public boolean isAuthenticationProviderRenewalNecessary()

Returns true if the saved sas token has expired and cannot be auto-renewed through the device key

Overrides:

IotHubSasTokenSoftwareAuthenticationProvider.isAuthenticationProviderRenewalNecessary()

Returns:

if the sas token needs manual renewal

setTokenValidSecs

public void setTokenValidSecs(long tokenValidSecs)

Overrides:

IotHubSasTokenSoftwareAuthenticationProvider.setTokenValidSecs(long tokenValidSecs)

Parameters:

tokenValidSecs

Applies to