IotHubSasTokenWithRefreshAuthenticationProvider Class

public class IotHubSasTokenWithRefreshAuthenticationProvider extends IotHubSasTokenAuthenticationProvider

Authentication method that uses a shared access signature token and allows for token refresh.

Constructor Summary

Constructor Description
IotHubSasTokenWithRefreshAuthenticationProvider(String hostname, String gatewayHostName, String deviceId, String moduleId, String sharedAccessToken, int suggestedTimeToLiveSeconds, int timeBufferPercentage)

Constructor for IotHubSasTokenWithRefreshAuthenticationProvider

IotHubSasTokenWithRefreshAuthenticationProvider(String hostname, String gatewayHostName, String deviceId, String moduleId, String sharedAccessToken, int suggestedTimeToLiveSeconds, int timeBufferPercentage, SSLContext sslContext)

Constructor for IotHubSasTokenWithRefreshAuthenticationProvider

Method Summary

Modifier and Type Method and Description
String buildAudience(String hostname, String deviceId, String moduleId)

Constructs the audience string to be used in a sas token

char [] getSasToken()

Check if sas token should be renewed at all, and then renew it if necessary

boolean isAuthenticationProviderRenewalNecessary()

Returns false as instances of this class will always be able to renew their own sas token

abstract void refreshSasToken()

Renew the saved sas token

Inherited Members

IotHubSasTokenAuthenticationProvider.canRefreshToken() IotHubAuthenticationProvider.deviceId IotHubAuthenticationProvider.gatewayHostname IotHubAuthenticationProvider.getDeviceId() IotHubAuthenticationProvider.getGatewayHostname() IotHubAuthenticationProvider.getHostname() IotHubSasTokenAuthenticationProvider.getMillisecondsBeforeProactiveRenewal() IotHubAuthenticationProvider.getModuleId() IotHubAuthenticationProvider.getSSLContext() IotHubSasTokenAuthenticationProvider.getTokenValidSecs() IotHubAuthenticationProvider.hostname IotHubAuthenticationProvider.IotHubAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId) IotHubAuthenticationProvider.IotHubAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId, SSLContext sslContext) IotHubSasTokenAuthenticationProvider.IotHubSasTokenAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId) IotHubSasTokenAuthenticationProvider.IotHubSasTokenAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId, long tokenValidSecs, int timeBufferPercentage) IotHubSasTokenAuthenticationProvider.isSasTokenExpired() IotHubAuthenticationProvider.moduleId IotHubSasTokenAuthenticationProvider.sasToken IotHubSasTokenAuthenticationProvider.setTokenValidSecs(long tokenValidSecs) IotHubSasTokenAuthenticationProvider.shouldRefreshToken(boolean proactivelyRenew) IotHubSasTokenAuthenticationProvider.tokenValidSecs

Constructor Details

IotHubSasTokenWithRefreshAuthenticationProvider

protected IotHubSasTokenWithRefreshAuthenticationProvider(String hostname, String gatewayHostName, String deviceId, String moduleId, String sharedAccessToken, int suggestedTimeToLiveSeconds, int timeBufferPercentage)

Constructor for IotHubSasTokenWithRefreshAuthenticationProvider

Parameters:

hostname - the hostname
gatewayHostName - the gateway hostname
deviceId - the device id
moduleId - the module id
sharedAccessToken - the shared access token
suggestedTimeToLiveSeconds - the time to live for generated tokens
timeBufferPercentage - the percent of a sas token's life to live before renewing

IotHubSasTokenWithRefreshAuthenticationProvider

protected IotHubSasTokenWithRefreshAuthenticationProvider(String hostname, String gatewayHostName, String deviceId, String moduleId, String sharedAccessToken, int suggestedTimeToLiveSeconds, int timeBufferPercentage, SSLContext sslContext)

Constructor for IotHubSasTokenWithRefreshAuthenticationProvider

Parameters:

hostname - the hostname
gatewayHostName - the gateway hostname
deviceId - the device id
moduleId - the module id
sharedAccessToken - the shared access token
suggestedTimeToLiveSeconds - the time to live for generated tokens
timeBufferPercentage - the percent of a sas token's life to live before renewing
sslContext - the SSLContext the connection will use

Method Details

buildAudience

protected static String buildAudience(String hostname, String deviceId, String moduleId)

Constructs the audience string to be used in a sas token

Parameters:

hostname - the hostname
deviceId - the device id
moduleId - the module id

Returns:

the audience

Throws:

UnsupportedEncodingException - if UTF-8 encoding is not supported

getSasToken

public char [] getSasToken()

Check if sas token should be renewed at all, and then renew it if necessary

Returns:

the renewed token, or the old token if it did not need to be renewed

Throws:

IOException - If an IOException is encountered while refreshing the sas token
TransportException - If a TransportException is encountered while refreshing the sas token

isAuthenticationProviderRenewalNecessary

public boolean isAuthenticationProviderRenewalNecessary()

Returns false as instances of this class will always be able to renew their own sas token

Returns:

false

refreshSasToken

public abstract void refreshSasToken()

Renew the saved sas token

Throws:

IOException - If an IOException is encountered while refreshing the sas token
TransportException - If a TransportException is encountered while refreshing the sas token

Applies to