Dela via


IotHubServiceSasToken Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.service.auth.IotHubServiceSasToken

public final class IotHubServiceSasToken

Grants device access to an IoT Hub for the specified amount of time.

Field Summary

Modifier and Type Field and Description
static final java.lang.String TOKEN_FORMAT

The SAS token format.

protected final long expiryTimeSeconds
protected final java.lang.String keyName
protected final java.lang.String keyValue
protected final java.lang.String resourceUri
protected final java.lang.String token
protected final long tokenLifespanSeconds

Constructor Summary

Constructor Description
IotHubServiceSasToken(IotHubConnectionString iotHubConnectionString)

Constructor.

IotHubServiceSasToken(IotHubConnectionString iotHubConnectionString, long tokenLifespanSeconds)

Constructor.

Method Summary

Modifier and Type Method and Description
final long getExpiryTimeMillis()
long getTokenLifespanSeconds()
java.lang.String toString()

Returns the string representation of the SAS token.

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

TOKEN_FORMAT

public static final String TOKEN_FORMAT

The SAS token format. The parameters to be interpolated are, in order: the signature the resource URI the expiry time the key name Example: SharedAccessSignature sr=IOTHUBURI&sig=SIGNATURE&se=EXPIRY&skn=SHAREDACCESSKEYNAME

expiryTimeSeconds

protected final long expiryTimeSeconds

keyName

protected final String keyName

keyValue

protected final String keyValue

resourceUri

protected final String resourceUri

token

protected final String token

tokenLifespanSeconds

protected final long tokenLifespanSeconds

Constructor Details

IotHubServiceSasToken

public IotHubServiceSasToken(IotHubConnectionString iotHubConnectionString)

Constructor. Generates a SAS token that grants access to an IoT Hub for the default amount of time of 1 hour.

Parameters:

iotHubConnectionString - Connection string object containing the connection parameters

IotHubServiceSasToken

public IotHubServiceSasToken(IotHubConnectionString iotHubConnectionString, long tokenLifespanSeconds)

Constructor. Generates a SAS token that grants access to an IoT Hub for the specified amount of time.

Parameters:

iotHubConnectionString - Connection string object containing the connection parameters.
tokenLifespanSeconds - The number of seconds that the created SAS token will be valid for.

Method Details

getExpiryTimeMillis

public final long getExpiryTimeMillis()

Returns:

the number of milliseconds since the UNIX Epoch when this token will expire

getTokenLifespanSeconds

public long getTokenLifespanSeconds()

Returns:

The number of seconds that this token is valid for. Not to be confused with how many seconds the SAS token is still valid for at the time of calling this method.

toString

public String toString()

Returns the string representation of the SAS token.

Overrides:

IotHubServiceSasToken.toString()

Returns:

The string representation of the SAS token.

Applies to