當前位置: 首頁>>代碼示例>>Java>>正文


Java ServiceClient類代碼示例

本文整理匯總了Java中com.microsoft.azure.storage.ServiceClient的典型用法代碼示例。如果您正苦於以下問題:Java ServiceClient類的具體用法?Java ServiceClient怎麽用?Java ServiceClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ServiceClient類屬於com.microsoft.azure.storage包,在下文中一共展示了ServiceClient類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: signBlobQueueAndFileRequest

import com.microsoft.azure.storage.ServiceClient; //導入依賴的package包/類
public static final void signBlobQueueAndFileRequest(HttpURLConnection request, ServiceClient client,
        long contentLength, OperationContext context) throws InvalidKeyException, StorageException {
    if (client.getAuthenticationScheme() == AuthenticationScheme.SHAREDKEYFULL) {
        StorageCredentialsHelper.signBlobAndQueueRequest(client.getCredentials(), request, contentLength, context);
    }
    else {
        StorageCredentialsHelper.signBlobAndQueueRequestLite(client.getCredentials(), request, contentLength,
                context);
    }
}
 
開發者ID:horizon-institute,項目名稱:runspotrun-android-client,代碼行數:11,代碼來源:StorageRequest.java

示例2: signTableRequest

import com.microsoft.azure.storage.ServiceClient; //導入依賴的package包/類
public static final void signTableRequest(HttpURLConnection request, ServiceClient client, long contentLength,
        OperationContext context) throws InvalidKeyException, StorageException {
    if (client.getAuthenticationScheme() == AuthenticationScheme.SHAREDKEYFULL) {
        StorageCredentialsHelper.signTableRequest(client.getCredentials(), request, contentLength, context);
    }
    else {
        StorageCredentialsHelper.signTableRequestLite(client.getCredentials(), request, contentLength, context);
    }
}
 
開發者ID:horizon-institute,項目名稱:runspotrun-android-client,代碼行數:10,代碼來源:StorageRequest.java

示例3: generateSharedAccessSignatureHashForQueueAndTable

import com.microsoft.azure.storage.ServiceClient; //導入依賴的package包/類
/**
 * Get the signature hash embedded inside the Shared Access Signature for queue and table service.
 * 
 * @param permissions
 *            The permissions for a shared access signature.
 * @param startTime
 *            The start time for a shared access signature.
 * @param expiryTime
 *            The expiry time for a shared access signature.
 * @param resourceName
 *            The canonical resource string, unescaped.
 * @param accessPolicyIdentifier
 *            An optional identifier for the policy.
 * @param client
 *            Reference to the ServiceClient.
 * @param opContext
 *            An object used to track the execution of the operation.
 * @return
 *         the signature hash embedded inside the Shared Access Signature.
 * @throws InvalidKeyException
 * @throws StorageException
 */
private static String generateSharedAccessSignatureHashForQueueAndTable(final SharedAccessPolicy policy,
        final String resourceName, final String accessPolicyIdentifier, final boolean useTableSas,
        final String startPartitionKey, final String startRowKey, final String endPartitionKey,
        final String endRowKey, final ServiceClient client, final OperationContext opContext)
        throws InvalidKeyException, StorageException {
    Utility.assertNotNullOrEmpty("resourceName", resourceName);
    Utility.assertNotNull("client", client);

    String permissions = null;
    Date startTime = null;
    Date expiryTime = null;

    if (policy != null) {
        permissions = policy.permissionsToString();
        startTime = policy.getSharedAccessStartTime();
        expiryTime = policy.getSharedAccessExpiryTime();
    }

    String stringToSign = String.format("%s\n%s\n%s\n%s\n%s\n%s", permissions == null ? Constants.EMPTY_STRING
            : permissions, Utility.getUTCTimeOrEmpty(startTime), Utility.getUTCTimeOrEmpty(expiryTime),
            resourceName, accessPolicyIdentifier == null ? Constants.EMPTY_STRING : accessPolicyIdentifier,
            Constants.HeaderConstants.TARGET_STORAGE_VERSION);

    if (useTableSas) {
        stringToSign = String.format("%s\n%s\n%s\n%s\n%s", stringToSign,
                startPartitionKey == null ? Constants.EMPTY_STRING : startPartitionKey,
                startRowKey == null ? Constants.EMPTY_STRING : startRowKey,
                endPartitionKey == null ? Constants.EMPTY_STRING : endPartitionKey,
                endRowKey == null ? Constants.EMPTY_STRING : endRowKey);
    }

    stringToSign = Utility.safeDecode(stringToSign);
    final String signature = StorageCredentialsHelper.computeHmac256(client.getCredentials(), stringToSign,
            opContext);

    // add logging
    return signature;
}
 
開發者ID:horizon-institute,項目名稱:runspotrun-android-client,代碼行數:61,代碼來源:SharedAccessSignatureHelper.java

示例4: generateSharedAccessSignatureHashForBlobAndFile

import com.microsoft.azure.storage.ServiceClient; //導入依賴的package包/類
/**
 * Get the signature hash embedded inside the Shared Access Signature for the blob or file service.
 * 
 * @param policy
 *            The shared access policy to hash.
 * @param headers
 *            The optional header values to set for a blob or file accessed with this shared access signature.
 * @param accessPolicyIdentifier
 *            An optional identifier for the policy.
 * @param resourceName
 *            The resource name.
 * @param ipRange
 *            The range of IP addresses to hash.
 * @param protocols
 *            The Internet protocols to hash.
 * @param client
 *            The ServiceClient associated with the object.
 *            
 * @return The signature hash embedded inside the Shared Access Signature.
 * @throws InvalidKeyException
 * @throws StorageException
 */
public static String generateSharedAccessSignatureHashForBlobAndFile(final SharedAccessPolicy policy,
        SharedAccessHeaders headers, final String accessPolicyIdentifier, final String resourceName,
        final IPRange ipRange, final SharedAccessProtocols protocols, final ServiceClient client)
        throws InvalidKeyException, StorageException {
    
    String stringToSign = generateSharedAccessSignatureStringToSign(
            policy, resourceName, ipRange, protocols, accessPolicyIdentifier);

    String cacheControl = null;
    String contentDisposition = null;
    String contentEncoding = null;
    String contentLanguage = null;
    String contentType = null;
    if (headers != null) {
        cacheControl = headers.getCacheControl();
        contentDisposition = headers.getContentDisposition();
        contentEncoding = headers.getContentEncoding();
        contentLanguage = headers.getContentLanguage();
        contentType = headers.getContentType();
    }
        
    stringToSign = String.format("%s\n%s\n%s\n%s\n%s\n%s", stringToSign,
            cacheControl == null ? Constants.EMPTY_STRING : cacheControl,
            contentDisposition == null ? Constants.EMPTY_STRING : contentDisposition,
            contentEncoding == null ? Constants.EMPTY_STRING : contentEncoding,
            contentLanguage == null ? Constants.EMPTY_STRING : contentLanguage,
            contentType == null ? Constants.EMPTY_STRING : contentType);
    
    return generateSharedAccessSignatureHashHelper(stringToSign, client.getCredentials());
}
 
開發者ID:Azure,項目名稱:azure-storage-android,代碼行數:53,代碼來源:SharedAccessSignatureHelper.java

示例5: generateSharedAccessSignatureHashForBlob

import com.microsoft.azure.storage.ServiceClient; //導入依賴的package包/類
/**
 * Get the signature hash embedded inside the Shared Access Signature for blob service.
 * 
 * @param permissions
 *            The permissions for a shared access signature.
 * @param startTime
 *            The start time for a shared access signature.
 * @param expiryTime
 *            The expiry time for a shared access signature.
 * @param resourceName
 *            The canonical resource string, unescaped.
 * @param accessPolicyIdentifier
 *            An optional identifier for the policy.
 * @param client
 *            Reference to the ServiceClient.
 * @param opContext
 *            An object used to track the execution of the operation.
 * @param headers
 *            The optional header values to set for a blob returned with this SAS.
 * @return
 *         The signature hash embedded inside the Shared Access Signature.
 * @throws InvalidKeyException
 * @throws StorageException
 */
private static String generateSharedAccessSignatureHashForBlob(final SharedAccessPolicy policy,
        final String resourceName, final String accessPolicyIdentifier, final ServiceClient client,
        final OperationContext opContext, final SharedAccessBlobHeaders headers) throws InvalidKeyException,
        StorageException {
    Utility.assertNotNullOrEmpty("resourceName", resourceName);
    Utility.assertNotNull("client", client);

    String permissions = null;
    Date startTime = null;
    Date expiryTime = null;

    if (policy != null) {
        permissions = policy.permissionsToString();
        startTime = policy.getSharedAccessStartTime();
        expiryTime = policy.getSharedAccessExpiryTime();
    }

    String cacheControl = null;
    String contentDisposition = null;
    String contentEncoding = null;
    String contentLanguage = null;
    String contentType = null;

    if (headers != null) {
        cacheControl = headers.getCacheControl();
        contentDisposition = headers.getContentDisposition();
        contentEncoding = headers.getContentEncoding();
        contentLanguage = headers.getContentLanguage();
        contentType = headers.getContentType();
    }

    String stringToSign = String.format("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s",
            permissions == null ? Constants.EMPTY_STRING : permissions, Utility.getUTCTimeOrEmpty(startTime),
            Utility.getUTCTimeOrEmpty(expiryTime), resourceName,
            accessPolicyIdentifier == null ? Constants.EMPTY_STRING : accessPolicyIdentifier,
            Constants.HeaderConstants.TARGET_STORAGE_VERSION, cacheControl == null ? Constants.EMPTY_STRING
                    : cacheControl, contentDisposition == null ? Constants.EMPTY_STRING : contentDisposition,
            contentEncoding == null ? Constants.EMPTY_STRING : contentEncoding,
            contentLanguage == null ? Constants.EMPTY_STRING : contentLanguage,
            contentType == null ? Constants.EMPTY_STRING : contentType);

    stringToSign = Utility.safeDecode(stringToSign);
    final String signature = StorageCredentialsHelper.computeHmac256(client.getCredentials(), stringToSign,
            opContext);

    // add logging
    return signature;
}
 
開發者ID:horizon-institute,項目名稱:runspotrun-android-client,代碼行數:73,代碼來源:SharedAccessSignatureHelper.java

示例6: signBlobQueueAndFileRequest

import com.microsoft.azure.storage.ServiceClient; //導入依賴的package包/類
public static final void signBlobQueueAndFileRequest(HttpURLConnection request, ServiceClient client,
        long contentLength, OperationContext context) throws InvalidKeyException, StorageException {
    StorageCredentialsHelper.signBlobQueueAndFileRequest(client.getCredentials(), request, contentLength, context);
}
 
開發者ID:Azure,項目名稱:azure-storage-android,代碼行數:5,代碼來源:StorageRequest.java

示例7: signTableRequest

import com.microsoft.azure.storage.ServiceClient; //導入依賴的package包/類
public static final void signTableRequest(HttpURLConnection request, ServiceClient client, long contentLength,
        OperationContext context) throws InvalidKeyException, StorageException {
    StorageCredentialsHelper.signTableRequest(client.getCredentials(), request, contentLength, context);
}
 
開發者ID:Azure,項目名稱:azure-storage-android,代碼行數:5,代碼來源:StorageRequest.java

示例8: generateSharedAccessSignatureHashForTable

import com.microsoft.azure.storage.ServiceClient; //導入依賴的package包/類
/**
 * Get the signature hash embedded inside the Shared Access Signature for the table service.
 * 
 * @param policy
 *            The shared access policy to hash.
 * @param accessPolicyIdentifier
 *            An optional identifier for the policy.
 * @param resourceName
 *            The resource name.
 * @param ipRange
 *            The range of IP addresses to hash.
 * @param protocols
 *            The Internet protocols to hash.
 * @param startPartitionKey
 *            An optional restriction of the beginning of the range of partition keys to hash.
 * @param startRowKey
 *            An optional restriction of the beginning of the range of row keys to hash.
 * @param endPartitionKey
 *            An optional restriction of the end of the range of partition keys to hash.
 * @param endRowKey
 *            An optional restriction of the end of the range of row keys to hash.
 * @param client
 *            The ServiceClient associated with the object.
 *            
 * @return The signature hash embedded inside the Shared Access Signature.
 * @throws InvalidKeyException
 * @throws StorageException
 */
public static String generateSharedAccessSignatureHashForTable(
        final SharedAccessTablePolicy policy, final String accessPolicyIdentifier, final String resourceName,
        final IPRange ipRange, final SharedAccessProtocols protocols, final String startPartitionKey,
        final String startRowKey, final String endPartitionKey, final String endRowKey, final ServiceClient client)
        throws InvalidKeyException, StorageException {

    String stringToSign = generateSharedAccessSignatureStringToSign(
            policy, resourceName, ipRange, protocols, accessPolicyIdentifier);
    
    stringToSign = String.format("%s\n%s\n%s\n%s\n%s", stringToSign,
            startPartitionKey == null ? Constants.EMPTY_STRING : startPartitionKey,
            startRowKey == null ? Constants.EMPTY_STRING : startRowKey,
            endPartitionKey == null ? Constants.EMPTY_STRING : endPartitionKey,
            endRowKey == null ? Constants.EMPTY_STRING : endRowKey);
    
    return generateSharedAccessSignatureHashHelper(stringToSign, client.getCredentials());
}
 
開發者ID:Azure,項目名稱:azure-storage-android,代碼行數:46,代碼來源:SharedAccessSignatureHelper.java

示例9: generateSharedAccessSignatureHashForQueue

import com.microsoft.azure.storage.ServiceClient; //導入依賴的package包/類
/**
 * Get the signature hash embedded inside the Shared Access Signature for queue service.
 * 
 * @param policy
 *            The shared access policy to hash.
 * @param accessPolicyIdentifier
 *            An optional identifier for the policy.
 * @param resourceName
 *            The resource name.
 * @param client
 *            The ServiceClient associated with the object.
 * @param opContext
 *            An object used to track the execution of the operation
 * @return The signature hash embedded inside the Shared Access Signature.
 * @throws InvalidKeyException
 * @throws StorageException
 */

public static String generateSharedAccessSignatureHashForQueue(final SharedAccessQueuePolicy policy,
        final String accessPolicyIdentifier, final String resourceName, final ServiceClient client,
        final OperationContext opContext) throws InvalidKeyException, StorageException {
    return generateSharedAccessSignatureHashForQueueAndTable(policy, resourceName, accessPolicyIdentifier, false,
            null, null, null, null, client, opContext);
}
 
開發者ID:horizon-institute,項目名稱:runspotrun-android-client,代碼行數:25,代碼來源:SharedAccessSignatureHelper.java

示例10: generateSharedAccessSignatureHashForTable

import com.microsoft.azure.storage.ServiceClient; //導入依賴的package包/類
/**
 * Get the signature hash embedded inside the Shared Access Signature for blob service.
 * 
 * @param policy
 *            The shared access policy to hash.
 * @param accessPolicyIdentifier
 *            An optional identifier for the policy.
 * @param resourceName
 *            The resource name.
 * @param client
 *            The ServiceClient associated with the object.
 * @param opContext
 *            An object used to track the execution of the operation
 * @return The signature hash embedded inside the Shared Access Signature.
 * @throws InvalidKeyException
 * @throws StorageException
 */
public static String generateSharedAccessSignatureHashForTable(final SharedAccessTablePolicy policy,
        final String accessPolicyIdentifier, final String resourceName, final String startPartitionKey,
        final String startRowKey, final String endPartitionKey, final String endRowKey, final ServiceClient client,
        final OperationContext opContext) throws InvalidKeyException, StorageException {
    return generateSharedAccessSignatureHashForQueueAndTable(policy, resourceName, accessPolicyIdentifier, true,
            startPartitionKey, startRowKey, endPartitionKey, endRowKey, client, opContext);

}
 
開發者ID:horizon-institute,項目名稱:runspotrun-android-client,代碼行數:26,代碼來源:SharedAccessSignatureHelper.java

示例11: generateSharedAccessSignatureHashForQueue

import com.microsoft.azure.storage.ServiceClient; //導入依賴的package包/類
/**
 * Get the signature hash embedded inside the Shared Access Signature for queue service.
 * 
 * @param policy
 *            The shared access policy to hash.
 * @param accessPolicyIdentifier
 *            An optional identifier for the policy.
 * @param resourceName
 *            The resource name.
 * @param ipRange
 *            The range of IP addresses to hash.
 * @param protocols
 *            The Internet protocols to hash.
 * @param client
 *            The ServiceClient associated with the object.
 *            
 * @return The signature hash embedded inside the Shared Access Signature.
 * @throws InvalidKeyException
 * @throws StorageException
 */

public static String generateSharedAccessSignatureHashForQueue(
        final SharedAccessQueuePolicy policy, final String accessPolicyIdentifier, final String resourceName,
        final IPRange ipRange, final SharedAccessProtocols protocols, final ServiceClient client)
        throws InvalidKeyException, StorageException {
    
    final String stringToSign = generateSharedAccessSignatureStringToSign(
            policy, resourceName, ipRange, protocols, accessPolicyIdentifier);
    
    return generateSharedAccessSignatureHashHelper(stringToSign, client.getCredentials());
}
 
開發者ID:Azure,項目名稱:azure-storage-android,代碼行數:32,代碼來源:SharedAccessSignatureHelper.java


注:本文中的com.microsoft.azure.storage.ServiceClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。