IotHubSasTokenHsmAuthenticationProvider Class

public class IotHubSasTokenHsmAuthenticationProvider extends IotHubSasTokenWithRefreshAuthenticationProvider

Authentication method that uses HSM to get a SAS token.

Method Summary

Modifier and Type Method and Description
boolean canRefreshToken()

Returns true as the Hsm can always refresh the token

IotHubSasTokenHsmAuthenticationProvider create(SignatureProvider signatureProvider, String deviceId, String moduleId, String hostname, String gatewayHostname, String generationId, int suggestedTimeToLiveSeconds, int timeBufferPercentage)

Constructor for a IotHubSasTokenHsmAuthenticationProvider instance

IotHubSasTokenHsmAuthenticationProvider create(SignatureProvider signatureProvider, String deviceId, String moduleId, String hostname, String gatewayHostname, String generationId, int suggestedTimeToLiveSeconds, int timeBufferPercentage, SSLContext sslContext)

Constructor for a IotHubSasTokenHsmAuthenticationProvider instance

void refreshSasToken()

Renew the saved sas token using the HSM unit

Inherited Members

IotHubSasTokenWithRefreshAuthenticationProvider.buildAudience(String hostname, String deviceId, String moduleId) IotHubAuthenticationProvider.deviceId IotHubAuthenticationProvider.gatewayHostname IotHubAuthenticationProvider.getDeviceId() IotHubAuthenticationProvider.getGatewayHostname() IotHubAuthenticationProvider.getHostname() IotHubSasTokenAuthenticationProvider.getMillisecondsBeforeProactiveRenewal() IotHubAuthenticationProvider.getModuleId() IotHubSasTokenWithRefreshAuthenticationProvider.getSasToken() 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) IotHubSasTokenWithRefreshAuthenticationProvider.IotHubSasTokenWithRefreshAuthenticationProvider(String hostname, String gatewayHostName, String deviceId, String moduleId, String sharedAccessToken, int suggestedTimeToLiveSeconds, int timeBufferPercentage) IotHubSasTokenWithRefreshAuthenticationProvider.IotHubSasTokenWithRefreshAuthenticationProvider(String hostname, String gatewayHostName, String deviceId, String moduleId, String sharedAccessToken, int suggestedTimeToLiveSeconds, int timeBufferPercentage, SSLContext sslContext) IotHubSasTokenWithRefreshAuthenticationProvider.isAuthenticationProviderRenewalNecessary() IotHubSasTokenAuthenticationProvider.isSasTokenExpired() IotHubAuthenticationProvider.moduleId IotHubSasTokenAuthenticationProvider.sasToken IotHubSasTokenAuthenticationProvider.setTokenValidSecs(long tokenValidSecs) IotHubSasTokenAuthenticationProvider.shouldRefreshToken(boolean proactivelyRenew) IotHubSasTokenAuthenticationProvider.tokenValidSecs

Method Details

canRefreshToken

public boolean canRefreshToken()

Returns true as the Hsm can always refresh the token

Returns:

true

create

public static IotHubSasTokenHsmAuthenticationProvider create(SignatureProvider signatureProvider, String deviceId, String moduleId, String hostname, String gatewayHostname, String generationId, int suggestedTimeToLiveSeconds, int timeBufferPercentage)

Constructor for a IotHubSasTokenHsmAuthenticationProvider instance

Parameters:

signatureProvider - the signature provider to be used when generating sas tokens
deviceId - the id of the device the module belongs to
moduleId - the id of the module to be authenticated for
hostname - the hostname of the iothub to be authenticated for. May be null if gatewayHostname is not
gatewayHostname - the gatewayHostname of the edge hub to be authenticated for. May be null if hostname is not
generationId - the generation id
suggestedTimeToLiveSeconds - the time for the generated sas tokens to live for
timeBufferPercentage - the percent of the life a sas token will live before attempting to be renewed. (100 means don't renew until end of life)

Returns:

the created IotHubSasTokenHsmAuthenticationProvider instance

Throws:

IOException - If the Hsm unit cannot be reached
TransportException - If the Hsm unit cannot be reached

create

public static IotHubSasTokenHsmAuthenticationProvider create(SignatureProvider signatureProvider, String deviceId, String moduleId, String hostname, String gatewayHostname, String generationId, int suggestedTimeToLiveSeconds, int timeBufferPercentage, SSLContext sslContext)

Constructor for a IotHubSasTokenHsmAuthenticationProvider instance

Parameters:

signatureProvider - the signature provider to be used when generating sas tokens
deviceId - the id of the device the module belongs to
moduleId - the id of the module to be authenticated for
hostname - the hostname of the iothub to be authenticated for. May be null if gatewayHostname is not
gatewayHostname - the gatewayHostname of the edge hub to be authenticated for. May be null if hostname is not
generationId - the generation id
suggestedTimeToLiveSeconds - the time for the generated sas tokens to live for
timeBufferPercentage - the percent of the life a sas token will live before attempting to be renewed. (100 means don't renew until end of life)
sslContext - the SSLContext to open connections with

Returns:

the created IotHubSasTokenHsmAuthenticationProvider instance

Throws:

IOException - If the Hsm unit cannot be reached
TransportException - If the Hsm unit cannot be reached

refreshSasToken

public void refreshSasToken()

Renew the saved sas token using the HSM unit

Throws:

IOException - If the Hsm unit cannot be reached
TransportException - If the Hsm unit cannot be reached

Applies to