IotHubSasTokenHardwareAuthenticationProvider Class

public class IotHubSasTokenHardwareAuthenticationProvider
extends IotHubSasTokenAuthenticationProvider

Field Summary

Modifier and Type Field and Description
protected SecurityProviderTpm securityProvider

Constructor Summary

Constructor Description
IotHubSasTokenHardwareAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId, SecurityProvider securityProvider)

Creates a Sas Token based authentication object that uses the provided security provider to produce sas tokens.

Method Summary

Modifier and Type Method and Description
boolean canRefreshToken()
javax.net.ssl.SSLContext getSSLContext()

Getter for SSLContext

char[] getSasToken()

Getter for SasToken.

boolean isAuthenticationProviderRenewalNecessary()

Returns true if the this authentication provider is no longer valid.

void setIotHubTrustedCert(String certificate)

Setter for the user trusted certificate

void setPathToIotHubTrustedCert(String pathToCertificate)

Setter for the providing trusted certificate.

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

securityProvider

protected SecurityProviderTpm securityProvider

Constructor Details

IotHubSasTokenHardwareAuthenticationProvider

public IotHubSasTokenHardwareAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId, SecurityProvider securityProvider)

Creates a Sas Token based authentication object that uses the provided security provider to produce sas tokens.

Parameters:

hostname - The host name of the hub to authenticate against
gatewayHostname - The gateway hostname to use, or null if connecting to an IotHub
deviceId - The unique id of the device to authenticate
moduleId - the module id. May be null if not using a module
securityProvider - the security provider to use for authentication

Throws:

java.io.IOException - if the provided securityProvider throws while retrieving a sas token or ssl context instance

Method Details

canRefreshToken

public boolean canRefreshToken()

Overrides:

IotHubSasTokenHardwareAuthenticationProvider.canRefreshToken()

getSSLContext

public SSLContext getSSLContext()

Getter for SSLContext

Overrides:

IotHubSasTokenHardwareAuthenticationProvider.getSSLContext()

Returns:

The value of SSLContext

Throws:

java.io.IOException - if an error occurs when generating the SSLContext

getSasToken

public char[] getSasToken()

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

Overrides:

IotHubSasTokenHardwareAuthenticationProvider.getSasToken()

Returns:

The value of SasToken

Throws:

java.io.IOException - if generating the sas token from the TPM fails

isAuthenticationProviderRenewalNecessary

public boolean isAuthenticationProviderRenewalNecessary()

Returns true if the this authentication provider is no longer valid. If true, users will need to create a new DeviceClient instance to get a new authentication provider. The most common case for this is if the user provides a SAS token, but no symmetric key, and that SAS token has expired. At that point, the user's client won't be able to authenticate anymore.

Overrides:

IotHubSasTokenHardwareAuthenticationProvider.isAuthenticationProviderRenewalNecessary()

Returns:

always returns false as the hardware authentication mechanism will never need to be updated with a new key or token

setIotHubTrustedCert

public void setIotHubTrustedCert(String certificate)

Setter for the user trusted certificate

Overrides:

IotHubSasTokenHardwareAuthenticationProvider.setIotHubTrustedCert(String certificate)

Parameters:

certificate - valid user trusted certificate string

setPathToIotHubTrustedCert

public void setPathToIotHubTrustedCert(String pathToCertificate)

Setter for the providing trusted certificate.

Overrides:

IotHubSasTokenHardwareAuthenticationProvider.setPathToIotHubTrustedCert(String pathToCertificate)

Parameters:

pathToCertificate - path to the certificate for one way authentication.

Applies to