/** * Tries to determine the storage credentials from a connection string. * <p> * The format for the connection string is in the pattern "<i>keyname=value</i>". Multiple key/value pairs can be * separated by a semi-colon, for example, "<i>keyname1=value1;keyname2=value2</i>". Either include an account name * with an account key or a shared access signature. If you use an account name and account key, do not include a * shared access signature, and vice versa. * <p> * The same connection string can be used as for {@link CloudStorageAccount#parse(String)} but here only the account * name, account key, and sas key/value pairs will be examined. * * @param connectionString * A <code>String</code> that contains the key/value pairs that represent the storage credentials. * * @return A {@link StorageCredentials} object representing the storage credentials determined from the connection * string. * * @throws InvalidKeyException * If the account key specified in <code>connectionString</code> is not valid. * @throws StorageException */ public static StorageCredentials tryParseCredentials(final String connectionString) throws InvalidKeyException, StorageException { return tryParseCredentials(Utility.parseAccountString(connectionString)); }
/** * Tries to determine the storage credentials from a connection string. * <p> * The format for the connection string is in the pattern "<i>keyname=value</i>". Multiple key/value pairs can be * separated by a semi-colon, for example, "<i>keyname1=value1;keyname2=value2</i>". Either include an account name * with an account key or a shared access signature. If you use an account name and account key, do not include a * shared access signature, and vice versa. * <p> * The same connection string can be used as for {@link CloudStorageAccount#parse(String)} but here only the account * name, account key, and sas key/value pairs will be examined. * * @param connectionString * A <code>String</code> that contains the key/value pairs that represent the storage credentials. * * @return A {@link StorageCredentials} object representing the storage credentials determined from the connection * string. * * @throws InvalidKeyException * If the account key specified in <code>connectionString</code> is not valid. * @throws StorageException */ public static StorageCredentials tryParseCredentials(final String connectionString) throws InvalidKeyException, StorageException { return tryParseCredentials(Utility.parseAccountString(connectionString)); }
final Map<String, String> settings = Utility.parseAccountString(connectionString);
final Map<String, String> settings = Utility.parseAccountString(connectionString);
@NotNull public ClientStorageAccount getStorageAccount(@NotNull String connectionString) { HashMap<String, String> settings = Utility.parseAccountString(connectionString); String name = settings.containsKey(ClientStorageAccount.ACCOUNT_NAME_KEY) ? settings.get(ClientStorageAccount.ACCOUNT_NAME_KEY) : ""; ClientStorageAccount storageAccount = new ClientStorageAccount(name); if (settings.containsKey(ClientStorageAccount.ACCOUNT_KEY_KEY)) { storageAccount.setPrimaryKey(settings.get(ClientStorageAccount.ACCOUNT_KEY_KEY)); } if (settings.containsKey(ClientStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_KEY)) { storageAccount.setUseCustomEndpoints(false); storageAccount.setProtocol(settings.get(ClientStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_KEY)); } else { storageAccount.setUseCustomEndpoints(true); if (settings.containsKey(ClientStorageAccount.BLOB_ENDPOINT_KEY)) { storageAccount.setBlobsUri(settings.get(ClientStorageAccount.BLOB_ENDPOINT_KEY)); } if (settings.containsKey(ClientStorageAccount.QUEUE_ENDPOINT_KEY)) { storageAccount.setQueuesUri(settings.get(ClientStorageAccount.QUEUE_ENDPOINT_KEY)); } if (settings.containsKey(ClientStorageAccount.TABLE_ENDPOINT_KEY)) { storageAccount.setTablesUri(settings.get(ClientStorageAccount.TABLE_ENDPOINT_KEY)); } } return storageAccount; }