/** * Creates an instance of the <code>StorageCredentialsAccountAndKey</code> class, using the specified storage * account name and access key; the specified access key is stored as a <code>String</code>. * * @param accountName * A <code>String</code> that represents the name of the storage account. * @param key * A <code>String</code> that represents the Base-64-encoded account access key. */ public StorageCredentialsAccountAndKey(final String accountName, final String key) { this(accountName, Base64.decode(key)); }
/** * Creates an instance of the <code>StorageCredentialsAccountAndKey</code> class, using the specified storage * account name and access key; the specified access key is stored as a <code>String</code>. * * @param accountName * A <code>String</code> that represents the name of the storage account. * @param key * A <code>String</code> that represents the Base-64-encoded account access key. */ public StorageCredentialsAccountAndKey(final String accountName, final String key) { this(accountName, Base64.decode(key)); }
/** * 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)); }
/** * Gets the value of this {@link EntityProperty} as a <code>byte</code> array. * * @return * A <code>byte[]</code> representation of the {@link EntityProperty} value, or <code>null</code>. */ public byte[] getValueAsByteArray() { return this.getIsNull() ? null : Base64.decode(this.value); }
/** * Gets the value of this {@link EntityProperty} as a <code>byte</code> array. * * @return * A <code>byte[]</code> representation of the {@link EntityProperty} value, or <code>null</code>. */ public byte[] getValueAsByteArray() { return this.getIsNull() ? null : Base64.decode(this.value); }
/** * 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)); }
/** * Gets the content of the message as a string. * * @return A <code>String</code> which contains the content of the message. * * @throws StorageException * If a storage service error occurred. */ public final String getMessageContentAsString() throws StorageException { if (this.messageType == QueueMessageType.RAW_STRING) { return this.messageContent; } else { if (Utility.isNullOrEmpty(this.messageContent)) { return null; } try { return new String(Base64.decode(this.messageContent), Constants.UTF8_CHARSET); } catch (final UnsupportedEncodingException e) { throw Utility.generateNewUnexpectedStorageException(e); } } }
/** * Gets the content of the message as a byte array. * * @return A <code>byte</code> array which contains the content of the message. * * @throws StorageException * If a storage service error occurred. */ public final byte[] getMessageContentAsByte() throws StorageException { if (Utility.isNullOrEmpty(this.messageContent)) { return new byte[0]; } if (this.messageType == QueueMessageType.RAW_STRING) { try { return this.messageContent.getBytes(Constants.UTF8_CHARSET); } catch (final UnsupportedEncodingException e) { throw Utility.generateNewUnexpectedStorageException(e); } } else { return Base64.decode(this.messageContent); } }
/** * Gets the content of the message as a byte array. * * @return A <code>byte</code> array which contains the content of the message. * * @throws StorageException * If a storage service error occurred. */ public final byte[] getMessageContentAsByte() throws StorageException { if (Utility.isNullOrEmpty(this.messageContent)) { return new byte[0]; } if (this.messageType == QueueMessageType.RAW_STRING) { try { return this.messageContent.getBytes(Constants.UTF8_CHARSET); } catch (final UnsupportedEncodingException e) { throw Utility.generateNewUnexpectedStorageException(e); } } else { return Base64.decode(this.messageContent); } }
/** * Gets the content of the message as a string. * * @return A <code>String</code> which contains the content of the message. * * @throws StorageException * If a storage service error occurred. */ public final String getMessageContentAsString() throws StorageException { if (this.messageType == QueueMessageType.RAW_STRING) { return this.messageContent; } else { if (Utility.isNullOrEmpty(this.messageContent)) { return null; } try { return new String(Base64.decode(this.messageContent), Constants.UTF8_CHARSET); } catch (final UnsupportedEncodingException e) { throw Utility.generateNewUnexpectedStorageException(e); } } }
CloudBlockBlob blob = container.getBlockBlobReference(fn); blob.downloadToFile(p.getPath(), null, null, opContext); byte[] md5 = Base64.decode(blob.getProperties().getContentMD5()); if (!FileUtils.fileValid(p, md5)) throw new IOException("file " + p.getPath() + " is corrupt");
@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); } }