Package com.azure.core.credential
Class AzureSasCredential
- java.lang.Object
-
- com.azure.core.credential.AzureSasCredential
-
public final class AzureSasCredential extends Object
Represents a credential that uses a shared access signature to authenticate to an Azure Service.
-
-
Constructor Summary
Constructors Constructor Description AzureSasCredential(String signature)
Creates a credential that authorizes request with the given shared access signature.AzureSasCredential(String signature, Function<String,String> signatureEncoder)
Creates a credential that authorizes request within the given shared access signature.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getSignature()
Retrieves the shared access signature associated to this credential.AzureSasCredential
update(String signature)
Rotates the shared access signature associated to this credential.
-
-
-
Constructor Detail
-
AzureSasCredential
public AzureSasCredential(String signature)
Creates a credential that authorizes request with the given shared access signature.The
signature
passed is assumed to be encoded. This constructor is effectively the same as callingnew AzureSasCredential(signature, null))
.- Parameters:
signature
- The shared access signature used to authorize requests.- Throws:
NullPointerException
- Ifsignature
isnull
.IllegalArgumentException
- Ifsignature
is an empty string.
-
AzureSasCredential
public AzureSasCredential(String signature, Function<String,String> signatureEncoder)
Creates a credential that authorizes request within the given shared access signature.If
signatureEncoder
is non-null thesignature
, and allupdated signatures
, will be encoded using the function.signatureEncoder
should be as idempotent as possible to reduce the chance of double encoding errors.- Parameters:
signature
- The shared access signature used to authorize requests.signatureEncoder
- An optional function which encodes thesignature
.- Throws:
NullPointerException
- Ifsignature
isnull
.IllegalArgumentException
- Ifsignature
is an empty string.
-
-
Method Detail
-
getSignature
public String getSignature()
Retrieves the shared access signature associated to this credential.- Returns:
- The shared access signature being used to authorize requests.
-
update
public AzureSasCredential update(String signature)
Rotates the shared access signature associated to this credential.- Parameters:
signature
- The new shared access signature to be associated with this credential.- Returns:
- The updated
AzureSasCredential
object. - Throws:
NullPointerException
- Ifsignature
isnull
.IllegalArgumentException
- Ifsignature
is an empty string.
-
-