Package com.azure.core.credential
Class AzureNamedKeyCredential
- java.lang.Object
-
- com.azure.core.credential.AzureNamedKeyCredential
-
public final class AzureNamedKeyCredential extends Object
Represents a credential with a key name and the key and uses the key to authenticate to an Azure Service.The named credential can be created for keys which have a name identifier associated with them.
Code Samples
Create a named credential for a service specific sas key.
AzureNamedKeyCredential azureNamedKeyCredential = new AzureNamedKeyCredential("AZURE-SERVICE-SAS-KEY-NAME", "AZURE-SERVICE-SAS-KEY");
-
-
Constructor Summary
Constructors Constructor Description AzureNamedKeyCredential(String name, String key)
Creates a credential with specifiedname
that authorizes request with the givenkey
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AzureNamedKey
getAzureNamedKey()
Retrieves theAzureNamedKey
containing the name and key associated with this credential.AzureNamedKeyCredential
update(String name, String key)
Rotates thename
andkey
associated to this credential.
-
-
-
Constructor Detail
-
AzureNamedKeyCredential
public AzureNamedKeyCredential(String name, String key)
Creates a credential with specifiedname
that authorizes request with the givenkey
.- Parameters:
name
- The name of the key credential.key
- The key used to authorize requests.- Throws:
NullPointerException
- Ifkey
orname
isnull
.IllegalArgumentException
- Ifkey
orname
is an empty string.
-
-
Method Detail
-
getAzureNamedKey
public AzureNamedKey getAzureNamedKey()
Retrieves theAzureNamedKey
containing the name and key associated with this credential.- Returns:
- The
AzureNamedKey
containing the name and key .
-
update
public AzureNamedKeyCredential update(String name, String key)
Rotates thename
andkey
associated to this credential.- Parameters:
name
- The new name of the key credential.key
- The new key to be associated with this credential.- Returns:
- The updated
AzureNamedKeyCredential
object. - Throws:
NullPointerException
- Ifkey
orname
isnull
.IllegalArgumentException
- Ifkey
orname
is an empty string.
-
-