本文整理汇总了Java中com.microsoft.azure.storage.core.Base64.decode方法的典型用法代码示例。如果您正苦于以下问题:Java Base64.decode方法的具体用法?Java Base64.decode怎么用?Java Base64.decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.microsoft.azure.storage.core.Base64
的用法示例。
在下文中一共展示了Base64.decode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMessageContentAsByte
import com.microsoft.azure.storage.core.Base64; //导入方法依赖的package包/类
/**
* 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);
}
}
示例2: getMessageContentAsString
import com.microsoft.azure.storage.core.Base64; //导入方法依赖的package包/类
/**
* 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);
}
}
}
示例3: testCloudStorageAccountExportKey
import com.microsoft.azure.storage.core.Base64; //导入方法依赖的package包/类
@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);
}
示例4: testCloudStorageAccountExportKey
import com.microsoft.azure.storage.core.Base64; //导入方法依赖的package包/类
@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);
assertArrayEquals(expectedKeyBytes, keyBytes);
}
示例5: testQueueMessageValidateEncryption
import com.microsoft.azure.storage.core.Base64; //导入方法依赖的package包/类
@Test
public void testQueueMessageValidateEncryption() throws StorageException, JsonProcessingException, IOException,
InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException,
NoSuchAlgorithmException, NoSuchPaddingException, InterruptedException, ExecutionException {
// Create the Key to be used for wrapping.
SymmetricKey aesKey = TestHelper.getSymmetricKey();
byte[] messageBytes = new byte[100];
Random rand = new Random();
rand.nextBytes(messageBytes);
String inputMessage = Base64.encode(messageBytes);
CloudQueueMessage message = new CloudQueueMessage(inputMessage);
this.queue.setShouldEncodeMessage(false);
QueueRequestOptions options = new QueueRequestOptions();
options.setEncryptionPolicy(new QueueEncryptionPolicy(aesKey, null));
// add message
this.queue.addMessage(message, 0, 0, options, null);
// Retrieve message without decrypting
CloudQueueMessage retrMessage = this.queue.retrieveMessage();
// Decrypt locally
CloudQueueMessage decryptedMessage;
CloudQueueEncryptedMessage encryptedMessage = CloudQueueEncryptedMessage.deserialize(retrMessage
.getMessageContentAsString());
EncryptionData encryptionData = encryptedMessage.getEncryptionData();
byte[] contentEncryptionKey = aesKey.unwrapKeyAsync(encryptionData.getWrappedContentKey().getEncryptedKey(),
encryptionData.getWrappedContentKey().getAlgorithm()).get();
SecretKey keySpec = new SecretKeySpec(contentEncryptionKey, 0, contentEncryptionKey.length,
"AES");
Cipher myAes = Cipher.getInstance("AES/CBC/PKCS5Padding");
myAes.init(Cipher.DECRYPT_MODE, keySpec, new IvParameterSpec(encryptionData.getContentEncryptionIV()));
byte[] src = Base64.decode(encryptedMessage.getEncryptedMessageContents());
decryptedMessage = new CloudQueueMessage(myAes.doFinal(src, 0, src.length));
assertArrayEquals(message.getMessageContentAsByte(), decryptedMessage.getMessageContentAsByte());
}
示例6: setKey
import com.microsoft.azure.storage.core.Base64; //导入方法依赖的package包/类
/**
* Sets the key to be used, using the specified <code>String</code> as the key.
* <p/>
* This method is provided to support key rotation. This method is not thread-safe.
*
* @param key
* A <code>String</code> that represents the key being assigned.
*/
public void setKey(final String key) {
this.key = Base64.decode(key);
}
示例7: Credentials
import com.microsoft.azure.storage.core.Base64; //导入方法依赖的package包/类
/**
* Creates an instance of the <code>Credentials</code> class, using the specified storage account name and access
* key; the specified access key is stored as a Base64-encoded <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 Base64-encoded account access key.
*
*/
public Credentials(final String accountName, final String key) {
this(accountName, Base64.decode(key));
}
示例8: StorageCredentialsAccountAndKey
import com.microsoft.azure.storage.core.Base64; //导入方法依赖的package包/类
/**
* 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));
}
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:13,代码来源:StorageCredentialsAccountAndKey.java
示例9: getValueAsByteArray
import com.microsoft.azure.storage.core.Base64; //导入方法依赖的package包/类
/**
* 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.isNull ? null : Base64.decode(this.value);
}
示例10: getValueAsByteArray
import com.microsoft.azure.storage.core.Base64; //导入方法依赖的package包/类
/**
* 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);
}