예제 #1
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));
        }
예제 #2
0
        public KerberosKeytabCredentials(KerberosKeytabSecrets secrets, string kerberosKdcAddress, string kerberosPrincipal, string kerberosRealm)
        {
            if (secrets == null)
            {
                throw new ArgumentNullException(nameof(secrets));
            }
            if (kerberosKdcAddress == null)
            {
                throw new ArgumentNullException(nameof(kerberosKdcAddress));
            }
            if (kerberosPrincipal == null)
            {
                throw new ArgumentNullException(nameof(kerberosPrincipal));
            }
            if (kerberosRealm == null)
            {
                throw new ArgumentNullException(nameof(kerberosRealm));
            }

            Secrets            = secrets;
            KerberosKdcAddress = kerberosKdcAddress;
            KerberosPrincipal  = kerberosPrincipal;
            KerberosRealm      = kerberosRealm;
            CredentialsType    = CredentialsType.KerberosKeytab;
        }
예제 #3
0
 internal KerberosKeytabCredentials(CredentialsType credentialsType, KerberosKeytabSecrets secrets, string kerberosKdcAddress, string kerberosPrincipal, string kerberosRealm) : base(credentialsType)
 {
     Secrets            = secrets;
     KerberosKdcAddress = kerberosKdcAddress;
     KerberosPrincipal  = kerberosPrincipal;
     KerberosRealm      = kerberosRealm;
     CredentialsType    = credentialsType;
 }
예제 #4
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));
        }