コード例 #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));
        }
コード例 #2
0
        internal static DatastoreCredentials DeserializeDatastoreCredentials(JsonElement element)
        {
            if (element.TryGetProperty("credentialsType", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "AccountKey": return(AccountKeyDatastoreCredentials.DeserializeAccountKeyDatastoreCredentials(element));

                case "Certificate": return(CertificateDatastoreCredentials.DeserializeCertificateDatastoreCredentials(element));

                case "KerberosKeytab": return(KerberosKeytabCredentials.DeserializeKerberosKeytabCredentials(element));

                case "KerberosPassword": return(KerberosPasswordCredentials.DeserializeKerberosPasswordCredentials(element));

                case "None": return(NoneDatastoreCredentials.DeserializeNoneDatastoreCredentials(element));

                case "Sas": return(SasDatastoreCredentials.DeserializeSasDatastoreCredentials(element));

                case "ServicePrincipal": return(ServicePrincipalDatastoreCredentials.DeserializeServicePrincipalDatastoreCredentials(element));
                }
            }
            CredentialsType credentialsType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("credentialsType"))
                {
                    credentialsType = new CredentialsType(property.Value.GetString());
                    continue;
                }
            }
            return(new DatastoreCredentials(credentialsType));
        }
コード例 #3
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("credentialsType");
     writer.WriteStringValue(CredentialsType.ToString());
     writer.WriteEndObject();
 }
コード例 #4
0
 internal KerberosPasswordCredentials(CredentialsType credentialsType, KerberosPasswordSecrets secrets, string kerberosKdcAddress, string kerberosPrincipal, string kerberosRealm) : base(credentialsType)
 {
     Secrets            = secrets;
     KerberosKdcAddress = kerberosKdcAddress;
     KerberosPrincipal  = kerberosPrincipal;
     KerberosRealm      = kerberosRealm;
     CredentialsType    = credentialsType;
 }
コード例 #5
0
 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;
 }
コード例 #6
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;
 }
コード例 #7
0
        internal static NoneDatastoreCredentials DeserializeNoneDatastoreCredentials(JsonElement element)
        {
            CredentialsType credentialsType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("credentialsType"))
                {
                    credentialsType = new CredentialsType(property.Value.GetString());
                    continue;
                }
            }
            return(new NoneDatastoreCredentials(credentialsType));
        }
コード例 #8
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("secrets");
     writer.WriteObjectValue(Secrets);
     writer.WritePropertyName("kerberosKdcAddress");
     writer.WriteStringValue(KerberosKdcAddress);
     writer.WritePropertyName("kerberosPrincipal");
     writer.WriteStringValue(KerberosPrincipal);
     writer.WritePropertyName("kerberosRealm");
     writer.WriteStringValue(KerberosRealm);
     writer.WritePropertyName("credentialsType");
     writer.WriteStringValue(CredentialsType.ToString());
     writer.WriteEndObject();
 }
コード例 #9
0
        internal static AccountKeyDatastoreCredentials DeserializeAccountKeyDatastoreCredentials(JsonElement element)
        {
            AccountKeyDatastoreSecrets secrets         = default;
            CredentialsType            credentialsType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("secrets"))
                {
                    secrets = AccountKeyDatastoreSecrets.DeserializeAccountKeyDatastoreSecrets(property.Value);
                    continue;
                }
                if (property.NameEquals("credentialsType"))
                {
                    credentialsType = new CredentialsType(property.Value.GetString());
                    continue;
                }
            }
            return(new AccountKeyDatastoreCredentials(credentialsType, secrets));
        }
コード例 #10
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     if (Optional.IsDefined(AuthorityUri))
     {
         if (AuthorityUri != null)
         {
             writer.WritePropertyName("authorityUrl");
             writer.WriteStringValue(AuthorityUri.AbsoluteUri);
         }
         else
         {
             writer.WriteNull("authorityUrl");
         }
     }
     writer.WritePropertyName("clientId");
     writer.WriteStringValue(ClientId);
     if (Optional.IsDefined(ResourceUri))
     {
         if (ResourceUri != null)
         {
             writer.WritePropertyName("resourceUrl");
             writer.WriteStringValue(ResourceUri.AbsoluteUri);
         }
         else
         {
             writer.WriteNull("resourceUrl");
         }
     }
     writer.WritePropertyName("secrets");
     writer.WriteObjectValue(Secrets);
     writer.WritePropertyName("tenantId");
     writer.WriteStringValue(TenantId);
     writer.WritePropertyName("thumbprint");
     writer.WriteStringValue(Thumbprint);
     writer.WritePropertyName("credentialsType");
     writer.WriteStringValue(CredentialsType.ToString());
     writer.WriteEndObject();
 }
コード例 #11
0
        internal static KerberosKeytabCredentials DeserializeKerberosKeytabCredentials(JsonElement element)
        {
            KerberosKeytabSecrets secrets      = default;
            string          kerberosKdcAddress = default;
            string          kerberosPrincipal  = default;
            string          kerberosRealm      = default;
            CredentialsType credentialsType    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("secrets"))
                {
                    secrets = KerberosKeytabSecrets.DeserializeKerberosKeytabSecrets(property.Value);
                    continue;
                }
                if (property.NameEquals("kerberosKdcAddress"))
                {
                    kerberosKdcAddress = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("kerberosPrincipal"))
                {
                    kerberosPrincipal = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("kerberosRealm"))
                {
                    kerberosRealm = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("credentialsType"))
                {
                    credentialsType = new CredentialsType(property.Value.GetString());
                    continue;
                }
            }
            return(new KerberosKeytabCredentials(credentialsType, secrets, kerberosKdcAddress, kerberosPrincipal, kerberosRealm));
        }
コード例 #12
0
 internal AccountKeyDatastoreCredentials(CredentialsType credentialsType, AccountKeyDatastoreSecrets secrets) : base(credentialsType)
 {
     Secrets         = secrets;
     CredentialsType = credentialsType;
 }
コード例 #13
0
 internal SasDatastoreCredentials(CredentialsType credentialsType, SasDatastoreSecrets secrets) : base(credentialsType)
 {
     Secrets         = secrets;
     CredentialsType = credentialsType;
 }