microsoft-azure-storage/src/com/microsoft/azure/storage/CloudStorageAccount.java
public String generateSharedAccessSignature(SharedAccessAccountPolicy policy)
            throws InvalidKeyException, StorageException {
        if (!StorageCredentialsHelper.canCredentialsSignRequest(this.getCredentials())) {
            throw new IllegalArgumentException(SR.CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY);
        }
        
        final String sig = SharedAccessSignatureHelper.generateSharedAccessSignatureHashForAccount(
                this.credentials.getAccountName(), policy, this.getCredentials());
        final UriQueryBuilder sasBuilder =
                SharedAccessSignatureHelper.generateSharedAccessSignatureForAccount(policy, sig);
        return sasBuilder.toString();
    }
public String generateSharedAccessSignature(SharedAccessAccountPolicy policy)
            throws InvalidKeyException, StorageException {
        if (!StorageCredentialsHelper.canCredentialsSignRequest(this.getCredentials())) {
            throw new IllegalArgumentException(SR.CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY);
        }
        
        final String sig = SharedAccessSignatureHelper.generateSharedAccessSignatureHashForAccount(
                this.credentials.getAccountName(), policy, this.getCredentials());
        final UriQueryBuilder sasBuilder =
                SharedAccessSignatureHelper.generateSharedAccessSignatureForAccount(policy, sig);
        return sasBuilder.toString();
    }
public String generateSharedAccessSignature ( SharedAccessAccountPolicy policy ) throws InvalidKeyException , StorageException { if ( ! StorageCredentialsHelper . canCredentialsSignRequest ( this . getCredentials ( ) ) ) { throw new IllegalArgumentException ( SR . CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY ) ; } final String sig = SharedAccessSignatureHelper . generateSharedAccessSignatureHashForAccount ( this . credentials . getAccountName ( ) , policy , this . getCredentials ( ) ) ; final UriQueryBuilder sasBuilder = SharedAccessSignatureHelper . generateSharedAccessSignatureForAccount ( policy , sig ) ; return sasBuilder . toString ( ) ; }
Returns a shared access signature for the account.

@param policy
A {@link SharedAccessAccountPolicy} specifying the access policy for the shared access signature.

@return The query string returned includes the leading question mark.
@throws StorageException
If a storage service error occurred.
@throws InvalidKeyException
If the key is invalid.
Returns a shared access signature for the account .