Codota Logo
StorageCredentialsAccountAndKey
Code IndexAdd Codota to your IDE (free)

How to use
StorageCredentialsAccountAndKey
in
com.microsoft.azure.storage

Best Java code snippets using com.microsoft.azure.storage.StorageCredentialsAccountAndKey (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
LocalDateTime l =
  • Codota Iconnew LocalDateTime()
  • Codota IconLocalDateTime.now()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseLocalDateTime(text)
  • Smart code suggestions by Codota
}
origin: yammer/breakerbox

@JsonCreator
public AzureTableConfiguration(@JsonProperty("accountName") String accountName,
                @JsonProperty("accountKey") String accountKey,
                @JsonProperty("timeout")Duration timeout,
                @JsonProperty("retryInterval") Duration retryInterval,
                @JsonProperty("retryAttempts") int retryAttempts) {
  this.retryInterval = checkNotNull(retryInterval, "retryInterval cannot be null");
  this.retryAttempts = retryAttempts;
  this.timeout = checkNotNull(timeout, "timeout cannot be null");
  this.storageCredentialsAccountAndKey =
      new StorageCredentialsAccountAndKey(
          checkNotNull(accountName, "accountName cannot be null"),
          checkNotNull(accountKey, "accountKey cannot be null"));
}
origin: Azure/azure-storage-android

/**
 * Sets the name of the access key to be used when signing the request.
 * 
 * @param key
 *        A <code>String</code> that represents the name of the access key to be used when signing the request.
 */
public synchronized void updateKey(final String key) {
  this.updateKey(Base64.decode(key));
}

origin: com.microsoft.azure/azure-storage

/**
 * Returns a <code>String</code> that represents this instance, optionally including sensitive data.
 * 
 * @param exportSecrets
 *            <code>true</code> to include sensitive data in the return string; otherwise, <code>false</code>.
 * 
 * @return A <code>String</code> that represents this object, optionally including sensitive data.
 */
@Override
public String toString(final boolean exportSecrets) {
  return String.format("%s=%s;%s=%s", CloudStorageAccount.ACCOUNT_NAME_NAME, this.getAccountName(),
      CloudStorageAccount.ACCOUNT_KEY_NAME, exportSecrets ? this.exportBase64EncodedKey()
          : "[key hidden]");
}
origin: Azure/azure-storage-android

@Test
public void testStorageCredentialsSharedKeyUpdateKey() throws URISyntaxException, StorageException {
  StorageCredentialsAccountAndKey cred = new StorageCredentialsAccountAndKey(ACCOUNT_NAME, ACCOUNT_KEY);
  assertEquals(ACCOUNT_KEY, cred.exportBase64EncodedKey());
  // Validate update with byte array
  byte[] dummyKey = { 0, 1, 2 };
  cred.updateKey(dummyKey);
  String base64EncodedDummyKey = Base64.encode(dummyKey);
  assertEquals(base64EncodedDummyKey, cred.exportBase64EncodedKey());
  // Validate update with string
  dummyKey[0] = 3;
  base64EncodedDummyKey = Base64.encode(dummyKey);
  cred.updateKey(base64EncodedDummyKey);
  assertEquals(base64EncodedDummyKey, cred.exportBase64EncodedKey());
}
origin: Azure/azure-storage-android

@Test
public void testStorageCredentialsSharedKey() throws URISyntaxException, StorageException {
  StorageCredentialsAccountAndKey cred = new StorageCredentialsAccountAndKey(ACCOUNT_NAME, ACCOUNT_KEY);
  assertEquals(ACCOUNT_NAME, cred.getAccountName());
  URI testUri = new URI("http://test/abc?querya=1");
  assertEquals(testUri, cred.transformUri(testUri));
  assertEquals(ACCOUNT_KEY, cred.exportBase64EncodedKey());
  byte[] dummyKey = { 0, 1, 2 };
  String base64EncodedDummyKey = Base64.encode(dummyKey);
  cred = new StorageCredentialsAccountAndKey(ACCOUNT_NAME, base64EncodedDummyKey);
  assertEquals(base64EncodedDummyKey, cred.exportBase64EncodedKey());
  dummyKey[0] = 3;
  base64EncodedDummyKey = Base64.encode(dummyKey);
  cred = new StorageCredentialsAccountAndKey(ACCOUNT_NAME, base64EncodedDummyKey);
  assertEquals(base64EncodedDummyKey, cred.exportBase64EncodedKey());
}
origin: Azure/azure-storage-android

@Test
public void testStorageCredentialsNullKeyValue() {
  String nullKeyValueAsString = null;
  try {
    new StorageCredentialsAccountAndKey(ACCOUNT_NAME, nullKeyValueAsString);
    fail("Did not hit expected exception");
  }
  catch (IllegalArgumentException ex) {
    assertEquals(SR.STRING_NOT_VALID, ex.getMessage());
  }
  StorageCredentialsAccountAndKey credentials2 = new StorageCredentialsAccountAndKey(ACCOUNT_NAME, ACCOUNT_KEY);
  assertEquals(ACCOUNT_NAME, credentials2.getAccountName());
  assertEquals(ACCOUNT_KEY, Base64.encode(credentials2.exportKey()));
  byte[] nullKeyValueAsByteArray = null;
  try {
    new StorageCredentialsAccountAndKey(ACCOUNT_NAME, nullKeyValueAsByteArray);
    fail("Did not hit expected exception");
  }
  catch (IllegalArgumentException ex) {
    assertEquals(SR.INVALID_KEY, ex.getMessage());
  }
}
origin: Azure/azure-storage-android

  @Test
  public void testCloudStorageAccountExportKey() throws InvalidKeyException, URISyntaxException {
    String accountKeyString = "abc2564=";
    String accountString = "BlobEndpoint=http://blobs/;AccountName=test;AccountKey=" + accountKeyString;
    CloudStorageAccount account = CloudStorageAccount.parse(accountString);
    StorageCredentialsAccountAndKey accountAndKey = (StorageCredentialsAccountAndKey) account.getCredentials();
    String key = accountAndKey.exportBase64EncodedKey();
    assertEquals(accountKeyString, key);

    byte[] keyBytes = accountAndKey.exportKey();
    byte[] expectedKeyBytes = Base64.decode(accountKeyString);
    TestHelper.assertByteArrayEquals(expectedKeyBytes, keyBytes);
  }
}
origin: com.microsoft.azure/azure-storage

/**
 * Computes a signature for the specified string using the HMAC-SHA256 algorithm.
 * 
 * @param value
 *            The UTF-8-encoded string to sign.
 * 
 * @return A <code>String</code> that contains the HMAC-SHA256-encoded signature.
 * 
 * @throws InvalidKeyException
 *             If the key is not a valid Base64-encoded string.
 */
public static synchronized String computeHmac256(final StorageCredentials creds, final String value) throws InvalidKeyException {
  if (creds.getClass().equals(StorageCredentialsAccountAndKey.class)) {
    byte[] utf8Bytes = null;
    try {
      utf8Bytes = value.getBytes(Constants.UTF8_CHARSET);
    }
    catch (final UnsupportedEncodingException e) {
      throw new IllegalArgumentException(e);
    }
    return Base64.encode(((StorageCredentialsAccountAndKey) creds).getHmac256().doFinal(utf8Bytes));
  }
  else {
    return null;
  }
}
origin: Azure/azure-storage-android

/**
 * Computes a signature for the specified string using the HMAC-SHA256 algorithm.
 * 
 * @param value
 *            The UTF-8-encoded string to sign.
 * 
 * @return A <code>String</code> that contains the HMAC-SHA256-encoded signature.
 * 
 * @throws InvalidKeyException
 *             If the key is not a valid Base64-encoded string.
 */
public static synchronized String computeHmac256(final StorageCredentials creds, final String value) throws InvalidKeyException {
  if (creds.getClass().equals(StorageCredentialsAccountAndKey.class)) {
    byte[] utf8Bytes = null;
    try {
      utf8Bytes = value.getBytes(Constants.UTF8_CHARSET);
    }
    catch (final UnsupportedEncodingException e) {
      throw new IllegalArgumentException(e);
    }
    return Base64.encode(((StorageCredentialsAccountAndKey) creds).getHmac256().doFinal(utf8Bytes));
  }
  else {
    return null;
  }
}
origin: org.apache.hadoop/hadoop-azure

/**
 * Connect to Azure storage using account key credentials.
 */
private void connectUsingConnectionStringCredentials(
  final String accountName, final String containerName,
  final String accountKey) throws InvalidKeyException, StorageException,
  IOException, URISyntaxException {
 // If the account name is "acc.blob.core.windows.net", then the
 // rawAccountName is just "acc"
 String rawAccountName = accountName.split("\\.")[0];
 StorageCredentials credentials = new StorageCredentialsAccountAndKey(
   rawAccountName, accountKey);
 connectUsingCredentials(accountName, credentials, containerName);
}
origin: Azure/azure-storage-android

/**
 * Returns a <code>String</code> that represents this instance, optionally including sensitive data.
 * 
 * @param exportSecrets
 *            <code>true</code> to include sensitive data in the return string; otherwise, <code>false</code>.
 * 
 * @return A <code>String</code> that represents this object, optionally including sensitive data.
 */
@Override
public String toString(final boolean exportSecrets) {
  return String.format("%s=%s;%s=%s", CloudStorageAccount.ACCOUNT_NAME_NAME, this.getAccountName(),
      CloudStorageAccount.ACCOUNT_KEY_NAME, exportSecrets ? this.exportBase64EncodedKey()
          : "[key hidden]");
}
origin: com.microsoft.azure/azure-storage

/**
 * Sets the name of the access key to be used when signing the request.
 * 
 * @param key
 *        A <code>String</code> that represents the name of the access key to be used when signing the request.
 */
public synchronized void updateKey(final String key) {
  this.updateKey(Base64.decode(key));
}
 
origin: org.apache.hadoop/hadoop-azure

/**
 * Helper method that creates CloudStorageAccount Instance using the
 * storage account key.
 * @param accountName Name of the storage account
 * @param accountKey Storage Account key
 * @return CloudStorageAccount instance for the storage account.
 * @throws SASKeyGenerationException
 */
private CloudStorageAccount getStorageAccountInstance(String accountName,
  String accountKey) throws SASKeyGenerationException {
 if (!storageAccountMap.containsKey(accountName)) {
  CloudStorageAccount account = null;
  try {
   account =
     new CloudStorageAccount(new StorageCredentialsAccountAndKey(
       accountName, accountKey));
  } catch (URISyntaxException uriSyntaxEx) {
   throw new SASKeyGenerationException("Encountered URISyntaxException "
     + "for account " + accountName, uriSyntaxEx);
  }
  storageAccountMap.put(accountName, account);
 }
 return storageAccountMap.get(accountName);
}
origin: iterate-ch/cyberduck

@Override
public void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException {
  final StorageCredentials credentials = client.getCredentials();
  if(host.getCredentials().isPasswordAuthentication()) {
    // Update credentials
    ((StorageCredentialsAccountAndKey) credentials).updateKey(host.getCredentials().getPassword());
  }
  else if(host.getCredentials().isTokenAuthentication()) {
    if(!StringUtils.equals(host.getCredentials().getToken(), ((StorageCredentialsSharedAccessSignature) credentials).getToken())) {
      this.interrupt();
      this.open(proxy, new DisabledHostKeyCallback(), prompt);
    }
  }
  // Fetch reference for directory to check login credentials
  try {
    this.getFeature(ListService.class).list(new AzureHomeFinderService(this).find(), new DisabledListProgressListener() {
      @Override
      public void chunk(final Path parent, final AttributedList<Path> list) throws ListCanceledException {
        throw new ListCanceledException(list);
      }
    });
  }
  catch(ListCanceledException e) {
    // Success
  }
}
origin: apache/jackrabbit-oak

public static CloudBlobDirectory createCloudBlobDirectory(String path) {
  Map<String, String> config = parseAzureConfigurationFromUri(path);
  String accountName = config.get(KEY_ACCOUNT_NAME);
  String key = System.getenv("AZURE_SECRET_KEY");
  StorageCredentials credentials = null;
  try {
    credentials = new StorageCredentialsAccountAndKey(accountName, key);
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException(
        "Could not connect to the Azure Storage. Please verify if AZURE_SECRET_KEY environment variable "
            + "is correctly set!");
  }
  String uri = config.get(KEY_STORAGE_URI);
  String dir = config.get(KEY_DIR);
  try {
    return AzureUtilities.cloudBlobDirectoryFrom(credentials, uri, dir);
  } catch (URISyntaxException | StorageException e) {
    throw new IllegalArgumentException(
        "Could not connect to the Azure Storage. Please verify the path provided!");
  }
}
origin: org.apache.jackrabbit/oak-segment-azure

public static CloudBlobDirectory createCloudBlobDirectory(String path) {
  Map<String, String> config = parseAzureConfigurationFromUri(path);
  String accountName = config.get(KEY_ACCOUNT_NAME);
  String key = System.getenv("AZURE_SECRET_KEY");
  StorageCredentials credentials = null;
  try {
    credentials = new StorageCredentialsAccountAndKey(accountName, key);
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException(
        "Could not connect to the Azure Storage. Please verify if AZURE_SECRET_KEY environment variable "
            + "is correctly set!");
  }
  String uri = config.get(KEY_STORAGE_URI);
  String dir = config.get(KEY_DIR);
  try {
    return AzureUtilities.cloudBlobDirectoryFrom(credentials, uri, dir);
  } catch (URISyntaxException | StorageException e) {
    throw new IllegalArgumentException(
        "Could not connect to the Azure Storage. Please verify the path provided!");
  }
}
origin: org.apache.jackrabbit/oak-upgrade

private AzurePersistence createAzurePersistence() throws StorageException, URISyntaxException, InvalidKeyException {
  CloudBlobDirectory cloudBlobDirectory = null;
  if (accountName != null && uri != null) {
    String key = System.getenv("AZURE_SECRET_KEY");
    StorageCredentials credentials = new StorageCredentialsAccountAndKey(accountName, key);
    cloudBlobDirectory = AzureUtilities.cloudBlobDirectoryFrom(credentials, uri, dir);
  } else if (connectionString != null && containerName != null) {
    cloudBlobDirectory = AzureUtilities.cloudBlobDirectoryFrom(connectionString, containerName, dir);
  }
  if (cloudBlobDirectory == null) {
    throw new IllegalArgumentException("Could not connect to Azure storage. Too few connection parameters specified!");
  }
  return new AzurePersistence(cloudBlobDirectory);
}
origin: apache/jackrabbit-oak

private AzurePersistence createAzurePersistence() throws StorageException, URISyntaxException, InvalidKeyException {
  CloudBlobDirectory cloudBlobDirectory = null;
  if (accountName != null && uri != null) {
    String key = System.getenv("AZURE_SECRET_KEY");
    StorageCredentials credentials = new StorageCredentialsAccountAndKey(accountName, key);
    cloudBlobDirectory = AzureUtilities.cloudBlobDirectoryFrom(credentials, uri, dir);
  } else if (connectionString != null && containerName != null) {
    cloudBlobDirectory = AzureUtilities.cloudBlobDirectoryFrom(connectionString, containerName, dir);
  }
  if (cloudBlobDirectory == null) {
    throw new IllegalArgumentException("Could not connect to Azure storage. Too few connection parameters specified!");
  }
  return new AzurePersistence(cloudBlobDirectory);
}
origin: com.microsoft.azure/azure-storage

return new StorageCredentialsAccountAndKey(accountName, accountKey);
origin: stackoverflow.com

  String accountKey = Utils.returnInputkey(inputCreds, accountName);
  System.out.println(“This mapper is assigned the following     account:”+accountName);
StorageCredentials creds = new        StorageCredentialsAccountAndKey(accountName,accountKey);
CloudStorageAccount account = new CloudStorageAccount(creds);
  CloudBlobClient client = account.createCloudBlobClient();
com.microsoft.azure.storageStorageCredentialsAccountAndKey

Javadoc

Represents storage account credentials, based on storage account and access key, for accessing the Microsoft Azure storage services.

Most used methods

  • <init>
    Creates an instance of the StorageCredentialsAccountAndKey class, using the specified storage accoun
  • updateKey
    Sets the name of the access key to be used when signing the request.
  • exportBase64EncodedKey
    Exports the value of the access key to a Base64-encoded string.
  • getAccountName
    Gets the account name.
  • getHmac256
    Gets the HmacSha256 associated with the account key.
  • exportKey
    Exports the value of the access key to an array of bytes.
  • transformUri

Popular in Java

  • Updating database using SQL prepared statement
  • onCreateOptionsMenu (Activity)
  • getSystemService (Context)
  • getExternalFilesDir (Context)
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Notification (javax.management)
  • JFileChooser (javax.swing)
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now