Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 3
0
 internal CertificateDatastoreCredentials(CredentialsType credentialsType, Uri authorityUri, Guid clientId, Uri resourceUri, CertificateDatastoreSecrets secrets, Guid tenantId, string thumbprint) : base(credentialsType)
 {
     AuthorityUri    = authorityUri;
     ClientId        = clientId;
     ResourceUri     = resourceUri;
     Secrets         = secrets;
     TenantId        = tenantId;
     Thumbprint      = thumbprint;
     CredentialsType = credentialsType;
 }
Exemplo n.º 4
0
        public CertificateDatastoreCredentials(Guid clientId, CertificateDatastoreSecrets secrets, Guid tenantId, string thumbprint)
        {
            if (secrets == null)
            {
                throw new ArgumentNullException(nameof(secrets));
            }
            if (thumbprint == null)
            {
                throw new ArgumentNullException(nameof(thumbprint));
            }

            ClientId        = clientId;
            Secrets         = secrets;
            TenantId        = tenantId;
            Thumbprint      = thumbprint;
            CredentialsType = CredentialsType.Certificate;
        }