你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
IotHubSasTokenAuthenticationProvider Class
- java.
lang. Object - com.
microsoft. azure. sdk. iot. device. auth. IotHubAuthenticationProvider - com.
microsoft. azure. sdk. iot. device. auth. IotHubSasTokenAuthenticationProvider
- com.
- com.
public abstract class IotHubSasTokenAuthenticationProvider
extends IotHubAuthenticationProvider
Field Summary
Modifier and Type | Field and Description |
---|---|
protected static final java.lang.String | ENCODING_FORMAT_NAME |
protected static final long | MILLISECONDS_PER_SECOND |
protected static final long | MINIMUM_EXPIRATION_TIME_OFFSET |
protected
Iot |
sasToken |
protected int |
timeBufferPercentage
The percentage of a sas token's life that will happen before it should be renewed. |
protected long |
tokenValidSecs
The number of seconds after which the generated SAS token for a message will become invalid. |
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. |
void | setTokenValidSecs(long tokenValidSecs) |
boolean |
shouldRefreshToken(boolean proactivelyRenew)
Returns true if the saved token should be refreshed |
Methods inherited from IotHubAuthenticationProvider
Methods inherited from java.lang.Object
Field Details
ENCODING_FORMAT_NAME
protected static final String ENCODING_FORMAT_NAME
MILLISECONDS_PER_SECOND
protected static final long MILLISECONDS_PER_SECOND
MINIMUM_EXPIRATION_TIME_OFFSET
protected static final long MINIMUM_EXPIRATION_TIME_OFFSET
sasToken
protected IotHubSasToken sasToken
timeBufferPercentage
protected int timeBufferPercentage
The percentage of a sas token's life that will happen before it should be renewed. Between 1 and 100
tokenValidSecs
protected 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 currentTime() + DEVICE_KEY_VALID_LENGTH
, as a salt when generating our SAS token.
Constructor Details
IotHubSasTokenAuthenticationProvider
public IotHubSasTokenAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId)
Parameters:
IotHubSasTokenAuthenticationProvider
public IotHubSasTokenAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId, SSLContext sslContext)
Parameters:
IotHubSasTokenAuthenticationProvider
public IotHubSasTokenAuthenticationProvider(String hostname, String gatewayHostname, String deviceId, String moduleId, long tokenValidSecs, int timeBufferPercentage)
Parameters:
Method Details
canRefreshToken
public abstract boolean canRefreshToken()
getMillisecondsBeforeProactiveRenewal
public int getMillisecondsBeforeProactiveRenewal()
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:
setTokenValidSecs
public void setTokenValidSecs(long tokenValidSecs)
Parameters:
shouldRefreshToken
public boolean shouldRefreshToken(boolean proactivelyRenew)
Returns true if the saved token should be refreshed
Parameters:
Returns: