当前位置: 首页>>代码示例>>Java>>正文


Java SharedAccessSignatureHelper.generateSharedAccessSignatureForTable方法代码示例

本文整理汇总了Java中com.microsoft.azure.storage.core.SharedAccessSignatureHelper.generateSharedAccessSignatureForTable方法的典型用法代码示例。如果您正苦于以下问题:Java SharedAccessSignatureHelper.generateSharedAccessSignatureForTable方法的具体用法?Java SharedAccessSignatureHelper.generateSharedAccessSignatureForTable怎么用?Java SharedAccessSignatureHelper.generateSharedAccessSignatureForTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.microsoft.azure.storage.core.SharedAccessSignatureHelper的用法示例。


在下文中一共展示了SharedAccessSignatureHelper.generateSharedAccessSignatureForTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateSharedAccessSignature

import com.microsoft.azure.storage.core.SharedAccessSignatureHelper; //导入方法依赖的package包/类
/**
 * Creates a shared access signature for the table.
 *
 * @param policy
 *            A {@link SharedAccessTablePolicy} object which represents the access policy for the shared access
 *            signature.
 * @param accessPolicyIdentifier
 *            A <code>String</code> which represents a table-level access policy.
 * @param startPartitionKey
 *            A <code>String</code> which represents the starting partition key.
 * @param startRowKey
 *            A <code>String</code> which represents the starting row key.
 * @param endPartitionKey
 *            A <code>String</code> which represents the ending partition key.
 * @param endRowKey
 *            A <code>String</code> which represents the ending end key.
 *
 * @return A <code>String</code> containing the shared access signature for the table.
 *
 * @throws InvalidKeyException
 *             If an invalid key was passed.
 * @throws StorageException
 *             If a storage service error occurred.
 * @throws IllegalArgumentException
 *             If an unexpected value is passed.
 */
public String generateSharedAccessSignature(final SharedAccessTablePolicy policy,
        final String accessPolicyIdentifier, final String startPartitionKey, final String startRowKey,
        final String endPartitionKey, final String endRowKey) throws InvalidKeyException, StorageException {

    if (!StorageCredentialsHelper.canCredentialsSignRequest(this.tableServiceClient.getCredentials())) {
        throw new IllegalArgumentException(SR.CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY);
    }

    final String resourceName = this.getSharedAccessCanonicalName();

    final String signature = SharedAccessSignatureHelper.generateSharedAccessSignatureHashForTable(policy,
            accessPolicyIdentifier, resourceName, startPartitionKey, startRowKey, endPartitionKey, endRowKey,
            this.tableServiceClient, null);

    String accountKeyName = null;
    StorageCredentials credentials = this.tableServiceClient.getCredentials();

    if (credentials instanceof StorageCredentialsAccountAndKey) {
        accountKeyName = ((StorageCredentialsAccountAndKey) credentials).getAccountKeyName();
    }

    final UriQueryBuilder builder = SharedAccessSignatureHelper.generateSharedAccessSignatureForTable(policy,
            startPartitionKey, startRowKey, endPartitionKey, endRowKey, accessPolicyIdentifier, this.name,
            signature, accountKeyName);

    return builder.toString();
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:54,代码来源:CloudTable.java

示例2: generateSharedAccessSignature

import com.microsoft.azure.storage.core.SharedAccessSignatureHelper; //导入方法依赖的package包/类
/**
 * Creates a shared access signature for the table.
 *
 * @param policy
 *            A {@link SharedAccessTablePolicy} object which represents the access policy for the shared access
 *            signature.
 * @param accessPolicyIdentifier
 *            A <code>String</code> which represents a table-level access policy.
 * @param startPartitionKey
 *            A <code>String</code> which represents the starting partition key.
 * @param startRowKey
 *            A <code>String</code> which represents the starting row key.
 * @param endPartitionKey
 *            A <code>String</code> which represents the ending partition key.
 * @param endRowKey
 *            A <code>String</code> which represents the ending end key.
 * @param ipRange
 *            A {@link IPRange} object containing the range of allowed IP addresses.
 * @param protocols
 *            A {@link SharedAccessProtocols} representing the allowed Internet protocols.
 *
 * @return A <code>String</code> containing the shared access signature for the table.
 *
 * @throws InvalidKeyException
 *             If an invalid key was passed.
 * @throws StorageException
 *             If a storage service error occurred.
 * @throws IllegalArgumentException
 *             If an unexpected value is passed.
 */
public String generateSharedAccessSignature(
        final SharedAccessTablePolicy policy, final String accessPolicyIdentifier, final String startPartitionKey,
        final String startRowKey, final String endPartitionKey, final String endRowKey, final IPRange ipRange,
        final SharedAccessProtocols protocols)
        throws InvalidKeyException, StorageException {

    if (!StorageCredentialsHelper.canCredentialsSignRequest(this.tableServiceClient.getCredentials())) {
        throw new IllegalArgumentException(SR.CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY);
    }

    final String resourceName = this.getSharedAccessCanonicalName();

    final String signature = SharedAccessSignatureHelper.generateSharedAccessSignatureHashForTable(
            policy, accessPolicyIdentifier, resourceName, ipRange, protocols,
            startPartitionKey, startRowKey, endPartitionKey, endRowKey, this.tableServiceClient);

    final UriQueryBuilder builder = SharedAccessSignatureHelper.generateSharedAccessSignatureForTable(
            policy, startPartitionKey, startRowKey, endPartitionKey, endRowKey, accessPolicyIdentifier,
            ipRange, protocols, this.name,  signature);

    return builder.toString();
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:53,代码来源:CloudTable.java


注:本文中的com.microsoft.azure.storage.core.SharedAccessSignatureHelper.generateSharedAccessSignatureForTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。