internal static DatastoreSecrets DeserializeDatastoreSecrets(JsonElement element) { if (element.TryGetProperty("secretsType", out JsonElement discriminator)) { switch (discriminator.GetString()) { case "Certificate": return(CertificateDatastoreSecrets.DeserializeCertificateDatastoreSecrets(element)); case "KerberosKeytab": return(KerberosKeytabSecrets.DeserializeKerberosKeytabSecrets(element)); case "KerberosPassword": return(KerberosPasswordSecrets.DeserializeKerberosPasswordSecrets(element)); case "Sas": return(SasDatastoreSecrets.DeserializeSasDatastoreSecrets(element)); case "ServicePrincipal": return(ServicePrincipalDatastoreSecrets.DeserializeServicePrincipalDatastoreSecrets(element)); case "AccountKey": return(AccountKeyDatastoreSecrets.DeserializeAccountKeyDatastoreSecrets(element)); } } SecretsType secretsType = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("secretsType")) { secretsType = new SecretsType(property.Value.GetString()); continue; } } return(new DatastoreSecrets(secretsType)); }
internal ServicePrincipalDatastoreCredentials(CredentialsType credentialsType, Uri authorityUri, Guid clientId, Uri resourceUri, ServicePrincipalDatastoreSecrets secrets, Guid tenantId) : base(credentialsType) { AuthorityUri = authorityUri; ClientId = clientId; ResourceUri = resourceUri; Secrets = secrets; TenantId = tenantId; CredentialsType = credentialsType; }
internal static ServicePrincipalDatastoreCredentials DeserializeServicePrincipalDatastoreCredentials(JsonElement element) { Optional <Uri> authorityUrl = default; Guid clientId = default; Optional <Uri> resourceUrl = default; ServicePrincipalDatastoreSecrets secrets = default; Guid tenantId = default; CredentialsType credentialsType = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("authorityUrl")) { if (property.Value.ValueKind == JsonValueKind.Null) { authorityUrl = null; continue; } authorityUrl = new Uri(property.Value.GetString()); continue; } if (property.NameEquals("clientId")) { clientId = property.Value.GetGuid(); continue; } if (property.NameEquals("resourceUrl")) { if (property.Value.ValueKind == JsonValueKind.Null) { resourceUrl = null; continue; } resourceUrl = new Uri(property.Value.GetString()); continue; } if (property.NameEquals("secrets")) { secrets = ServicePrincipalDatastoreSecrets.DeserializeServicePrincipalDatastoreSecrets(property.Value); continue; } if (property.NameEquals("tenantId")) { tenantId = property.Value.GetGuid(); continue; } if (property.NameEquals("credentialsType")) { credentialsType = new CredentialsType(property.Value.GetString()); continue; } } return(new ServicePrincipalDatastoreCredentials(credentialsType, authorityUrl.Value, clientId, resourceUrl.Value, secrets, tenantId)); }
public ServicePrincipalDatastoreCredentials(Guid clientId, ServicePrincipalDatastoreSecrets secrets, Guid tenantId) { if (secrets == null) { throw new ArgumentNullException(nameof(secrets)); } ClientId = clientId; Secrets = secrets; TenantId = tenantId; CredentialsType = CredentialsType.ServicePrincipal; }