microsoft-azure-storage/src/com/microsoft/azure/storage/StorageCredentials.java
protected static StorageCredentials tryParseCredentials(final Map<String, String> settings)
            throws InvalidKeyException {
        final String accountName = settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ?
                settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null;

        final String accountKey = settings.get(CloudStorageAccount.ACCOUNT_KEY_NAME) != null ?
                settings.get(CloudStorageAccount.ACCOUNT_KEY_NAME) : null;

        final String sasSignature = settings.get(CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME) != null ?
                settings.get(CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME) : null;

        if (accountName != null && accountKey != null && sasSignature == null) {
            if (Base64.validateIsBase64String(accountKey)) {
                return new StorageCredentialsAccountAndKey(accountName, accountKey);
            }
            else {
                throw new InvalidKeyException(SR.INVALID_KEY);
            }
        }
        if (accountKey == null && sasSignature != null) {
            return new StorageCredentialsSharedAccessSignature(sasSignature);
        }

        return null;
    }
protected static StorageCredentials tryParseCredentials(final Map<String, String> settings)
            throws InvalidKeyException {
        final String accountName = settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ?
                settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null;

        final String accountKey = settings.get(CloudStorageAccount.ACCOUNT_KEY_NAME) != null ?
                settings.get(CloudStorageAccount.ACCOUNT_KEY_NAME) : null;

        final String sasSignature = settings.get(CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME) != null ?
                settings.get(CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME) : null;

        if (accountName != null && accountKey != null && sasSignature == null) {
            if (Base64.validateIsBase64String(accountKey)) {
                return new StorageCredentialsAccountAndKey(accountName, accountKey);
            }
            else {
                throw new InvalidKeyException(SR.INVALID_KEY);
            }
        }
        if (accountKey == null && sasSignature != null) {
            return new StorageCredentialsSharedAccessSignature(sasSignature);
        }

        return null;
    }
protected static StorageCredentials tryParseCredentials ( final Map < String , String > settings ) throws InvalidKeyException { final String accountName = settings . get ( CloudStorageAccount . ACCOUNT_NAME_NAME ) != null ? settings . get ( CloudStorageAccount . ACCOUNT_NAME_NAME ) : null ; final String accountKey = settings . get ( CloudStorageAccount . ACCOUNT_KEY_NAME ) != null ? settings . get ( CloudStorageAccount . ACCOUNT_KEY_NAME ) : null ; final String sasSignature = settings . get ( CloudStorageAccount . SHARED_ACCESS_SIGNATURE_NAME ) != null ? settings . get ( CloudStorageAccount . SHARED_ACCESS_SIGNATURE_NAME ) : null ; if ( accountName != null && accountKey != null && sasSignature == null ) { if ( Base64 . validateIsBase64String ( accountKey ) ) { return new StorageCredentialsAccountAndKey ( accountName , accountKey ) ; } else { throw new InvalidKeyException ( SR . INVALID_KEY ) ; } } if ( accountKey == null && sasSignature != null ) { return new StorageCredentialsSharedAccessSignature ( sasSignature ) ; } return null ; }
Tries to determine the storage credentials from a collection of name/value pairs.

@param settings
A <code>Map</code> object of the name/value pairs that represent the settings to use to configure
the credentials.
<p>
Either include an account name with an account key (specifying values for
{@link CloudStorageAccount#ACCOUNT_NAME_NAME} and {@link CloudStorageAccount#ACCOUNT_KEY_NAME} ), or a
shared access signature (specifying a value for
{@link CloudStorageAccount#SHARED_ACCESS_SIGNATURE_NAME} ). If you use an account name and account
key, do not include a shared access signature, and vice versa.

@return A {@link StorageCredentials} object representing the storage credentials determined from the name/value
pairs.

@throws InvalidKeyException
If the key value specified for {@link CloudStorageAccount#ACCOUNT_KEY_NAME} is not a valid
Base64-encoded string.
Tries to determine the storage credentials from a collection of name / value pairs .