/// <summary> /// Download the secrets from a path (following the '.../v1/secret/') /// </summary> /// <param name="path">The path.</param> /// <returns>The secret tree structure.</returns> public async Task <SecretFolder> GetSecrets(string path) { var folder = new SecretFolder(this.GetLastFolder(path)); // Gets the list of secrets for this path IEnumerable <string> keyList = new List <string>();; try { keyList = await this.GetSecretList(path); } catch (VaultRequestException ex) { // May be connection issue, or forbidden. We just continue. } foreach (var key in keyList) { if (SecretFolder.IsFolder(key)) { // Resursive call folder.AddFolder(await this.GetSecrets(path + "/" + key)); } else { // Adds secret folder.AddSecret(this.GetSecret(path + "/" + key)); } } return(folder); }
/// <summary> /// Download the secrets from a path (following the '.../v1/secret/') /// </summary> /// <param name="path">The path.</param> /// <returns>The secret tree structure.</returns> public async Task <SecretFolder> GetSecrets(string path) { var folder = new SecretFolder(this.GetLastFolder(path)); // Gets the list of secrets for this path IEnumerable <string> keyList = new List <string>();; try { keyList = await this.GetSecretList(path); } catch (VaultRequestException ex) { // May be connection issue, or forbidden. We just continue. } if (keyList.Count() < 1) { KeePassLib.Utility.MessageService.ShowWarning("No Secrets could be retrieved for: " + path); return(null); } foreach (var key in keyList) { try { if (SecretFolder.IsFolder(key)) { // Resursive call folder.AddFolder(await this.GetSecrets(path + "/" + key)); } else { folder.AddSecret(this.GetSecret(path + "/" + key)); } } catch (Exception ex) { // we are unable to retrieve the secret. // cause could be ACL prohibiting READ access to secret } } return(folder); }
/// <summary> /// Download the secrets from a path (following the '.../v1/secret/') /// </summary> /// <param name="path">The path.</param> /// <returns>The secret tree structure.</returns> public async Task <SecretFolder> GetSecrets(string path) { var folder = new SecretFolder(this.GetLastFolder(path)); // Gets the list of secrets for this path SecretKeys keyList; try { keyList = await this.GetSecretList(path); } catch (VaultRequestException ex) { // May be connection issue, or forbidden. We just continue, but we store the error for future display this.syncStatus.AddLog(string.Format("Exception for {0}: {1}{2}{3}", path, ex.Message, Environment.NewLine, ex.StackTrace)); return(folder); } if (keyList.Keys.Count() > 0) { this.syncStatus.AddLog(string.Format("{0} keys fetched in {1}", keyList.Keys.Count(), path)); } foreach (var key in keyList.Keys) { if (SecretFolder.IsFolder(key)) { // Resursive call folder.AddFolder(await this.GetSecrets(path + "/" + key)); } else { // Adds secret folder.AddSecret(this.GetSecret(path + "/" + key)); } } if (folder.Secrets.Count() > 0) { this.syncStatus.AddLog(string.Format("{0} secrets fetched in {1}", folder.Secrets.Count(), path)); } return(folder); }