IotHubSasTokenAuthenticationProvider Class
- java.
lang. Object - IotHubAuthenticationProvider
- com.
microsoft. azure. sdk. iot. device. auth. IotHubSasTokenAuthenticationProvider
- com.
public class IotHubSasTokenAuthenticationProvider extends IotHubAuthenticationProvider
Field Summary
Modifier and Type | Field and Description |
---|---|
Iot |
sasToken |
long |
tokenValidSecs
The number of seconds after which the generated SAS token for a message will become invalid. We also use the expiry time, which is computed as
|
Constructor Summary
Method Summary
Modifier and Type | Method and Description |
---|---|
abstract boolean | canRefreshToken() |
int | getMillisecondsBeforeProactiveRenewal() |
abstract char [] | getSasToken() |
long | getTokenValidSecs() |
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. |
boolean | isSasTokenExpired() |
void | setTokenValidSecs(long tokenValidSecs) |
boolean |
shouldRefreshToken(boolean proactivelyRenew)
Returns true if the saved token should be refreshed |
Inherited Members
Field Details
sasToken
protected IotHubSasToken sasToken
tokenValidSecs
protected long tokenValidSecs= 3600
The number of seconds after which the generated SAS token for a message will become invalid. We also use the expiry time, which is computed as currentTime() + DEVICE_KEY_VALID_LENGTH
</code> , as a salt when generating our SAS token. </p>
Constructor Details
IotHubSasTokenAuthenticationProvider
public IotHubSasTokenAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId)
Parameters:
hostname
gatewayHostname
deviceId
moduleId
IotHubSasTokenAuthenticationProvider
public IotHubSasTokenAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId, long tokenValidSecs, int timeBufferPercentage)
Parameters:
hostname
gatewayHostname
deviceId
moduleId
tokenValidSecs
timeBufferPercentage
Method Details
canRefreshToken
public abstract boolean canRefreshToken()
getMillisecondsBeforeProactiveRenewal
public int getMillisecondsBeforeProactiveRenewal()
getSasToken
public abstract char [] getSasToken()
getTokenValidSecs
public long getTokenValidSecs()
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.
Returns:
true if the this authentication provider is no longer valid. False otherwise
isSasTokenExpired
public boolean isSasTokenExpired()
setTokenValidSecs
public void setTokenValidSecs(long tokenValidSecs)
Parameters:
tokenValidSecs
shouldRefreshToken
public boolean shouldRefreshToken(boolean proactivelyRenew)
Returns true if the saved token should be refreshed
Parameters:
proactivelyRenew
- if true, this function will return true even if the saved token has not expired, but only if the token has lived beyond its time buffer percentage
Returns:
true if the caller should refresh the saved sas token
Applies to
Azure SDK for Java