protected async override Task <string> OnSaveSecretAsync(Secret secret, CancellationToken token) { Contracts.Secret ss = new Contracts.Secret() { Name = secret.Name, Description = secret.Description, CurrentKeyName = secret.CurrentKeyName, ObjectName = secret.ObjectName, ObjectType = secret.ObjectType, VaultName = secret.VaultName, Version = secret.Version, SubscriptionId = secret.SubscriptionId, FormatExpression = secret.FormatExpression, SecretType = secret.SecretType, LastRotatedOn = secret.LastRotatedOn }; if (secret.Configuration != null) { ss.ConfigurationId = secret.Configuration.ConfigurationId; } await SaveObjectAsync(_rootContainer, FormatFileName(StorageFolders.Secret, ss.Key), GetObjectJson <Contracts.Secret>(ss), token); return(ss.ConfigurationId.ToString()); }
protected async override Task <Secret> OnGetConfiguredSecretAsync(string key, CancellationToken token) { SecretBase sb = await GetSecretAsync(key, token); if (null == sb) { return(null); //couldn't find base config, nothing to do here.. } if (null != token && token.IsCancellationRequested) { return(null); //cancel } Secret s = sb as Secret; //should never really happen give the code flow... if (null == s) { s = sb.ToConfiguredSecret(); } if (null == s.Configuration) { Contracts.Secret cs = sb as Contracts.Secret; if (null != cs) { s.Configuration = await GetSecretConfigurationAsync(cs.ConfigurationId.ToString(), token); } } else if (Guid.Empty != s.Configuration.ConfigurationId && (string.IsNullOrWhiteSpace(s.Name) || (s.SecretType == SecretType.Attached && null == s.Configuration.Policy))) { s.Configuration = await GetSecretConfigurationAsync(s.Configuration.ConfigurationId.ToString(), token); } //Contracts.Secret cs = sb as Contracts.Secret; //if (null != cs) //{ // s.Configuration = await GetSecretConfigurationAsync(cs.ConfigurationId.ToString(), token); //} return(s); }