com.microsoft.azure.storage.StorageCredentialsToken Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-storage Show documentation
Show all versions of azure-storage Show documentation
SDK for Microsoft Azure Storage Clients
package com.microsoft.azure.storage;
import java.net.URI;
/**
* Represents storage account credentials, based on an authentication token, for accessing the Microsoft Azure
* storage services.
*/
public final class StorageCredentialsToken extends StorageCredentials{
/**
* Stores the token for the credentials.
*/
private volatile String token;
/**
* Stores the account name.
*/
private volatile String accountName;
/**
* Creates an instance of the StorageCredentialsToken
class, using the specified token.
* Token credentials must only be used with HTTPS requests on the blob and queue services.
* The specified token is stored as a String
.
*
* @param token
* A String
that represents the token.
*/
public StorageCredentialsToken(String accountName, String token) {
this.accountName = accountName;
this.token = token;
}
/**
* Gets whether this StorageCredentials
object only allows access via HTTPS.
*
* @return A boolean
representing whether this StorageCredentials
* object only allows access via HTTPS.
*/
@Override
public boolean isHttpsOnly() {
return true;
}
/**
* Gets the token.
*
* @return A String
that contains the token.
*/
public String getToken() {
return this.token;
}
/**
* Sets the token to be used when authenticating HTTPS requests.
*
* @param token
* A String
that represents the access token to be used when authenticating HTTPS requests.
*/
public synchronized void updateToken(final String token) {
this.token = token;
}
/**
* Gets the account name.
*
* @return A String
that contains the account name.
*/
@Override
public String getAccountName() {
return this.accountName;
}
/**
* Returns a String
that represents this instance, optionally including sensitive data.
*
* @param exportSecrets
* true
to include sensitive data in the return string; otherwise, false
.
*
* @return A String
that represents this object, optionally including sensitive data.
*/
@Override
public String toString(final boolean exportSecrets) {
return String.format("%s=%s", CloudStorageAccount.ACCOUNT_TOKEN_NAME, exportSecrets ? this.token
: "[token hidden]");
}
@Override
public URI transformUri(URI resourceUri, OperationContext opContext) {
return resourceUri;
}
@Override
public StorageUri transformUri(StorageUri resourceUri, OperationContext opContext) {
return resourceUri;
}
}