microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFile.java
public String generateSharedAccessSignature(
            final SharedAccessFilePolicy policy, final SharedAccessFileHeaders headers,
            final String groupPolicyIdentifier, final IPRange ipRange, final SharedAccessProtocols protocols)
            throws InvalidKeyException, StorageException {

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

        final String signature = SharedAccessSignatureHelper.generateSharedAccessSignatureHashForBlobAndFile(
                policy, headers, groupPolicyIdentifier, this.getCanonicalName(),
                ipRange, protocols, this.fileServiceClient);

        final UriQueryBuilder builder = SharedAccessSignatureHelper.generateSharedAccessSignatureForBlobAndFile(
                policy, headers, groupPolicyIdentifier, "f", ipRange, protocols, signature);

        return builder.toString();
    }
public String generateSharedAccessSignature(
            final SharedAccessFilePolicy policy, final SharedAccessFileHeaders headers,
            final String groupPolicyIdentifier, final IPRange ipRange, final SharedAccessProtocols protocols)
            throws InvalidKeyException, StorageException {

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

        final String signature = SharedAccessSignatureHelper.generateSharedAccessSignatureHashForBlobAndFile(
                policy, headers, groupPolicyIdentifier, this.getCanonicalName(),
                ipRange, protocols, this.fileServiceClient);

        final UriQueryBuilder builder = SharedAccessSignatureHelper.generateSharedAccessSignatureForBlobAndFile(
                policy, headers, groupPolicyIdentifier, "f", ipRange, protocols, signature);

        return builder.toString();
    }
Returns a shared access signature for the file using the specified group policy identifier and
shared access file headers. Note this does not contain the leading "?".

@param policy
A <code>{@link SharedAccessFilePolicy}</code> object that represents the access policy for the shared
access signature.
@param headers
A <code>{@link SharedAccessFileHeaders}</code> object that represents the optional header values to
set for a file accessed with this shared access signature.
@param groupPolicyIdentifier
A <code>String</code> that represents the share-level access policy.
@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> that represents the shared access signature.

@throws IllegalArgumentException
If the credentials are invalid.
@throws InvalidKeyException
If the credentials are invalid.
@throws StorageException
If a storage service error occurred.