Beispiel #1
0
        internal static CertificateDatastoreCredentials DeserializeCertificateDatastoreCredentials(JsonElement element)
        {
            Optional <Uri> authorityUrl         = default;
            Guid           clientId             = default;
            Optional <Uri> resourceUrl          = default;
            CertificateDatastoreSecrets secrets = default;
            Guid            tenantId            = default;
            string          thumbprint          = 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 = CertificateDatastoreSecrets.DeserializeCertificateDatastoreSecrets(property.Value);
                    continue;
                }
                if (property.NameEquals("tenantId"))
                {
                    tenantId = property.Value.GetGuid();
                    continue;
                }
                if (property.NameEquals("thumbprint"))
                {
                    thumbprint = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("credentialsType"))
                {
                    credentialsType = new CredentialsType(property.Value.GetString());
                    continue;
                }
            }
            return(new CertificateDatastoreCredentials(credentialsType, authorityUrl.Value, clientId, resourceUrl.Value, secrets, tenantId, thumbprint));
        }
Beispiel #2
0
        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));
        }