microsoft-azure-storage/src/com/microsoft/azure/storage/core/SharedAccessSignatureHelper.java
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());
    }
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());
    }
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