本文整理汇总了Java中com.microsoft.azure.storage.core.Base64类的典型用法代码示例。如果您正苦于以下问题:Java Base64类的具体用法?Java Base64怎么用?Java Base64使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Base64类属于com.microsoft.azure.storage.core包,在下文中一共展示了Base64类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: computeMacSha256
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
/**
* Computes a signature for the specified string using the HMAC-SHA256 algorithm.
*
* @param storageKey
* A <code>StorageKey</code> object that represents the storage key to use.
* @param stringToSign
* The UTF-8-encoded string to sign.
*
* @return A <code>String</code> that contains the HMAC-SHA256-encoded signature.
*
* @throws IllegalArgumentException
* If the string to sign is not a valid Base64-encoded string.
* @throws InvalidKeyException
* If the key is not a valid storage key.
*/
public static synchronized String computeMacSha256(final StorageKey storageKey, final String stringToSign)
throws InvalidKeyException {
if (storageKey.hmacSha256 == null) {
storageKey.initHmacSha256();
}
byte[] utf8Bytes = null;
try {
utf8Bytes = stringToSign.getBytes(Constants.UTF8_CHARSET);
}
catch (final UnsupportedEncodingException e) {
throw new IllegalArgumentException(e);
}
return Base64.encode(storageKey.hmacSha256.doFinal(utf8Bytes));
}
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:32,代码来源:StorageKey.java
示例2: computeMacSha512
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
/**
* Computes a signature for the specified string using the HMAC-SHA512 algorithm.
*
* @param storageKey
* A <code>StorageKey</code> object that represents the storage key to use.
* @param stringToSign
* The UTF-8-encoded string to sign.
*
* @return A <code>String</code> that contains the HMAC-SHA512-encoded signature.
*
* @throws IllegalArgumentException
* If the string to sign is not a valid Base64-encoded string.
* @throws InvalidKeyException
* If the key is not a valid storage key.
*/
public static synchronized String computeMacSha512(final StorageKey storageKey, final String stringToSign)
throws InvalidKeyException {
if (storageKey.hmacSha512 == null) {
storageKey.initHmacSha512();
}
byte[] utf8Bytes = null;
try {
utf8Bytes = stringToSign.getBytes(Constants.UTF8_CHARSET);
}
catch (final UnsupportedEncodingException e) {
throw new IllegalArgumentException(e);
}
return Base64.encode(storageKey.hmacSha512.doFinal(utf8Bytes));
}
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:32,代码来源:StorageKey.java
示例3: tryParseCredentials
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
/**
* Tries to determine the storage credentials from a collection of name/value pairs.
*
* @param settings
* A <code>HashMap</code> object of the name/value pairs that represent the settings to use to configure
* the credentials.
* <p>
* Either include an account name with an account key (specifying values for
* {@link CloudStorageAccount#ACCOUNT_NAME_NAME} and {@link CloudStorageAccount#ACCOUNT_KEY_NAME} ), or a
* shared access signature (specifying a value for
* {@link CloudStorageAccount#SHARED_ACCESS_SIGNATURE_NAME} ). If you use an account name and account
* key, do not include a shared access signature, and vice versa.
*
* @return A {@link StorageCredentials} object representing the storage credentials determined from the name/value
* pairs.
*
* @throws InvalidKeyException
* If the key value specified for {@link CloudStorageAccount#ACCOUNT_KEY_NAME} is not a valid
* Base64-encoded string.
*/
protected static StorageCredentials tryParseCredentials(final HashMap<String, String> settings)
throws InvalidKeyException {
final String accountName = settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings
.get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null;
final String accountKey = settings.get(CloudStorageAccount.ACCOUNT_KEY_NAME) != null ? settings
.get(CloudStorageAccount.ACCOUNT_KEY_NAME) : null;
final String sasSignature = settings.get(CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME) != null ? settings
.get(CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME) : null;
if (accountName != null && accountKey != null && sasSignature == null) {
if (Base64.validateIsBase64String(accountKey)) {
return new StorageCredentialsAccountAndKey(accountName, accountKey);
}
else {
throw new InvalidKeyException(SR.INVALID_KEY);
}
}
if (accountName == null && accountKey == null && sasSignature != null) {
return new StorageCredentialsSharedAccessSignature(sasSignature);
}
return null;
}
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:46,代码来源:StorageCredentials.java
示例4: commit
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
/**
* Commits the blob, for block blob this uploads the block list.
*
* @throws StorageException
* An exception representing any error which occurred during the operation.
*/
@DoesServiceRequest
private void commit() throws StorageException {
if (this.options.getStoreBlobContentMD5()) {
this.parentBlobRef.getProperties().setContentMD5(Base64.encode(this.md5Digest.digest()));
}
if (this.streamType == BlobType.BLOCK_BLOB) {
// wait for all blocks to finish
final CloudBlockBlob blobRef = (CloudBlockBlob) this.parentBlobRef;
blobRef.commitBlockList(this.blockList, this.accessCondition, this.options, this.opContext);
}
else if (this.streamType == BlobType.PAGE_BLOB) {
this.parentBlobRef.uploadProperties(this.accessCondition, this.options, this.opContext);
}
}
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:22,代码来源:BlobOutputStream.java
示例5: 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);
}
}
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:26,代码来源:CloudQueueMessage.java
示例6: 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);
}
}
}
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:26,代码来源:CloudQueueMessage.java
示例7: getMessageContentForTransfer
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
/**
* Gets the content of the message for transfer (internal use only).
*
* @return A <code>String</code> which contains the content of the message.
*
* @throws StorageException
* If a storage service error occurred.
*/
protected final String getMessageContentForTransfer(final boolean shouldEncodeMessage) throws StorageException {
String result = null;
if (this.messageType == QueueMessageType.RAW_STRING && shouldEncodeMessage) {
result = Base64.encode(this.getMessageContentAsByte());
}
else {
result = this.messageContent;
}
if (result != null && result.length() > QueueConstants.MAX_MESSAGE_SIZE) {
throw new IllegalArgumentException(
String.format(SR.INVALID_MESSAGE_LENGTH, QueueConstants.MAX_MESSAGE_SIZE));
}
return result;
}
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:25,代码来源:CloudQueueMessage.java
示例8: testStorageCredentialsSharedKey
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
@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());
}
开发者ID:Azure,项目名称:azure-storage-android,代码行数:21,代码来源:StorageAccountTests.java
示例9: testStorageCredentialsSharedKeyUpdateKey
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
@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());
}
开发者ID:Azure,项目名称:azure-storage-android,代码行数:18,代码来源:StorageAccountTests.java
示例10: tryParseCredentials
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
/**
* Tries to determine the storage credentials from a collection of name/value pairs.
*
* @param settings
* A <code>Map</code> object of the name/value pairs that represent the settings to use to configure
* the credentials.
* <p>
* Either include an account name with an account key (specifying values for
* {@link CloudStorageAccount#ACCOUNT_NAME_NAME} and {@link CloudStorageAccount#ACCOUNT_KEY_NAME} ), or a
* shared access signature (specifying a value for
* {@link CloudStorageAccount#SHARED_ACCESS_SIGNATURE_NAME} ). If you use an account name and account
* key, do not include a shared access signature, and vice versa.
*
* @return A {@link StorageCredentials} object representing the storage credentials determined from the name/value
* pairs.
*
* @throws InvalidKeyException
* If the key value specified for {@link CloudStorageAccount#ACCOUNT_KEY_NAME} is not a valid
* Base64-encoded string.
*/
protected static StorageCredentials tryParseCredentials(final Map<String, String> settings)
throws InvalidKeyException {
final String accountName = settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ?
settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null;
final String accountKey = settings.get(CloudStorageAccount.ACCOUNT_KEY_NAME) != null ?
settings.get(CloudStorageAccount.ACCOUNT_KEY_NAME) : null;
final String sasSignature = settings.get(CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME) != null ?
settings.get(CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME) : null;
if (accountName != null && accountKey != null && sasSignature == null) {
if (Base64.validateIsBase64String(accountKey)) {
return new StorageCredentialsAccountAndKey(accountName, accountKey);
}
else {
throw new InvalidKeyException(SR.INVALID_KEY);
}
}
if (accountKey == null && sasSignature != null) {
return new StorageCredentialsSharedAccessSignature(sasSignature);
}
return null;
}
开发者ID:Azure,项目名称:azure-storage-android,代码行数:46,代码来源:StorageCredentials.java
示例11: commit
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
/**
* Commits the blob, for block blob this uploads the block list.
*
* @throws StorageException
* An exception representing any error which occurred during the operation.
*/
@DoesServiceRequest
private synchronized void commit() throws StorageException {
if (this.options.getStoreBlobContentMD5()) {
this.parentBlobRef.getProperties().setContentMD5(Base64.encode(this.md5Digest.digest()));
}
if (this.streamType == BlobType.BLOCK_BLOB) {
// wait for all blocks to finish
final CloudBlockBlob blobRef = (CloudBlockBlob) this.parentBlobRef;
blobRef.commitBlockList(this.blockList, this.accessCondition, this.options, this.opContext);
}
else if (this.options.getStoreBlobContentMD5()) {
this.parentBlobRef.uploadProperties(this.accessCondition, this.options, this.opContext);
}
}
开发者ID:Azure,项目名称:azure-storage-android,代码行数:22,代码来源:BlobOutputStream.java
示例12: testQueueAddUpdateEncryptedEncodedMessage
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
@Test
public void testQueueAddUpdateEncryptedEncodedMessage() throws StorageException, InvalidKeyException,
NoSuchAlgorithmException, NoSuchPaddingException {
// 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
CloudQueueMessage retrMessage = this.queue.retrieveMessage(30, options, null);
assertEquals(inputMessage, retrMessage.getMessageContentAsString());
}
开发者ID:Azure,项目名称:azure-storage-java,代码行数:25,代码来源:CloudQueueEncryptionTests.java
示例13: validate
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
@Override
public boolean validate(final Credentials credentials, final LoginOptions options) {
if(super.validate(credentials, options)) {
if(options.password) {
return Base64.validateIsBase64String(credentials.getPassword());
}
return true;
}
return false;
}
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:11,代码来源:AzureProtocol.java
示例14: commit
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
/**
* Commits the file.
*
* @throws StorageException
* An exception representing any error which occurred during the operation.
*/
@DoesServiceRequest
private void commit() throws StorageException {
if (this.options.getStoreFileContentMD5()) {
this.parentFileRef.getProperties().setContentMD5(Base64.encode(this.md5Digest.digest()));
}
this.parentFileRef.uploadProperties(this.accessCondition, this.options, this.opContext);
}
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:15,代码来源:FileOutputStream.java
示例15: uploadRange
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
/**
* Uploads a range to a file using the specified lease ID, request options, and operation context.
*
* @param sourceStream
* An {@link IntputStream} object which represents the input stream to write to the file.
* @param offset
* A <code>long</code> which represents the offset, in number of bytes, at which to begin writing the
* data.
* @param length
* A <code>long</code> which represents the length, in bytes, of the data to write.
* @param accessCondition
* An {@link AccessCondition} object which represents the access conditions for the file.
* @param options
* A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
* <code>null</code> will use the default request options from the associated service client (
* {@link CloudFileClient}).
* @param opContext
* An {@link OperationContext} object which represents the context for the current operation. This object
* is used to track requests to the storage service, and to provide additional runtime information about
* the operation.
*
* @throws IOException
* If an I/O exception occurred.
* @throws StorageException
* If a storage service error occurred.
*/
@DoesServiceRequest
public void uploadRange(final InputStream sourceStream, final long offset, final long length,
final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
throws StorageException, IOException {
if (opContext == null) {
opContext = new OperationContext();
}
options = FileRequestOptions.applyDefaults(options, this.fileServiceClient);
final FileRange range = new FileRange(offset, offset + length - 1);
final byte[] data = new byte[(int) length];
String md5 = null;
int count = 0;
int total = 0;
while (total < length) {
count = sourceStream.read(data, total, (int) Math.min(length - total, Integer.MAX_VALUE));
total += count;
}
if (options.getUseTransactionalContentMD5()) {
try {
final MessageDigest digest = MessageDigest.getInstance("MD5");
digest.update(data, 0, data.length);
md5 = Base64.encode(digest.digest());
}
catch (final NoSuchAlgorithmException e) {
// This wont happen, throw fatal.
throw Utility.generateNewUnexpectedStorageException(e);
}
}
this.putRangeInternal(range, FileRangeOperationType.UPDATE, data, length, md5, accessCondition, options,
opContext);
}
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:63,代码来源:CloudFile.java
示例16: setValue
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
/**
* Sets this {@link EntityProperty} using the serialized <code>byte[]</code> value.
*
* @param value
* The <code>byte[]</code> value to set as the {@link EntityProperty} value. This value may be
* <code>null</code>.
*/
public synchronized final void setValue(final byte[] value) {
this.edmType = EdmType.BINARY;
this.type = byte[].class;
if (value == null) {
this.value = null;
this.isNull = true;
return;
}
else {
this.isNull = false;
}
this.value = Base64.encode(value);
}
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:22,代码来源:EntityProperty.java
示例17: setMessageContent
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
/**
* Sets the content of the message as a <code>byte</code> array.
*
* @param content
* A <code>byte</code> array which contains the content of the message.
*/
public final void setMessageContent(final byte[] content) {
Utility.assertNotNull("content", content);
this.messageContent = Base64.encode(content);
this.messageType = QueueMessageType.BASE_64_ENCODED;
}
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:13,代码来源:CloudQueueMessage.java
示例18: 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);
}
开发者ID:Azure,项目名称:azure-storage-android,代码行数:14,代码来源:StorageAccountTests.java
示例19: getCurrentBlockId
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
/**
* Generates a new block ID to be used for PutBlock.
*
* @return Base64 encoded block ID
* @throws IOException
*/
private String getCurrentBlockId() throws IOException
{
String blockIdSuffix = String.format("%06d", this.blockList.size());
byte[] blockIdInBytes;
try {
blockIdInBytes = (this.blockIdPrefix + blockIdSuffix).getBytes(Constants.UTF8_CHARSET);
} catch (UnsupportedEncodingException e) {
// this should never happen, UTF8 is a default charset
throw new IOException(e);
}
return Base64.encode(blockIdInBytes);
}
开发者ID:Azure,项目名称:azure-storage-android,代码行数:21,代码来源:BlobOutputStream.java
示例20: commit
import com.microsoft.azure.storage.core.Base64; //导入依赖的package包/类
/**
* Commits the file.
*
* @throws StorageException
* An exception representing any error which occurred during the operation.
* @throws URISyntaxException
*/
@DoesServiceRequest
private void commit() throws StorageException, URISyntaxException {
if (this.options.getStoreFileContentMD5()) {
this.parentFileRef.getProperties().setContentMD5(Base64.encode(this.md5Digest.digest()));
}
this.parentFileRef.uploadProperties(this.accessCondition, this.options, this.opContext);
}
开发者ID:Azure,项目名称:azure-storage-android,代码行数:16,代码来源:FileOutputStream.java
注:本文中的com.microsoft.azure.storage.core.Base64类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论