示例#1
0
        public ServicePrincipalCredential(string dataSourceCredentialName, ServicePrincipalParam parameters) : base(dataSourceCredentialName)
        {
            if (dataSourceCredentialName == null)
            {
                throw new ArgumentNullException(nameof(dataSourceCredentialName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            Parameters = parameters;
            DataSourceCredentialType = DataSourceCredentialType.ServicePrincipal;
        }
示例#2
0
        internal static ServicePrincipalCredential DeserializeServicePrincipalCredential(JsonElement element)
        {
            ServicePrincipalParam    parameters = default;
            DataSourceCredentialType dataSourceCredentialType = default;
            Optional <Guid>          dataSourceCredentialId   = default;
            string            dataSourceCredentialName        = default;
            Optional <string> dataSourceCredentialDescription = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("parameters"))
                {
                    parameters = ServicePrincipalParam.DeserializeServicePrincipalParam(property.Value);
                    continue;
                }
                if (property.NameEquals("dataSourceCredentialType"))
                {
                    dataSourceCredentialType = new DataSourceCredentialType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("dataSourceCredentialId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    dataSourceCredentialId = property.Value.GetGuid();
                    continue;
                }
                if (property.NameEquals("dataSourceCredentialName"))
                {
                    dataSourceCredentialName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dataSourceCredentialDescription"))
                {
                    dataSourceCredentialDescription = property.Value.GetString();
                    continue;
                }
            }
            return(new ServicePrincipalCredential(dataSourceCredentialType, Optional.ToNullable(dataSourceCredentialId), dataSourceCredentialName, dataSourceCredentialDescription.Value, parameters));
        }
示例#3
0
        internal static ServicePrincipalDatasourceCredential DeserializeServicePrincipalDatasourceCredential(JsonElement element)
        {
            ServicePrincipalParam    parameters = default;
            DataSourceCredentialType dataSourceCredentialType = default;
            Optional <string>        dataSourceCredentialId   = default;
            string            dataSourceCredentialName        = default;
            Optional <string> dataSourceCredentialDescription = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("parameters"))
                {
                    parameters = ServicePrincipalParam.DeserializeServicePrincipalParam(property.Value);
                    continue;
                }
                if (property.NameEquals("dataSourceCredentialType"))
                {
                    dataSourceCredentialType = new DataSourceCredentialType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("dataSourceCredentialId"))
                {
                    dataSourceCredentialId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dataSourceCredentialName"))
                {
                    dataSourceCredentialName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dataSourceCredentialDescription"))
                {
                    dataSourceCredentialDescription = property.Value.GetString();
                    continue;
                }
            }
            return(new ServicePrincipalDatasourceCredential(dataSourceCredentialType, dataSourceCredentialId.Value, dataSourceCredentialName, dataSourceCredentialDescription.Value, parameters));
        }
        /// <summary>
        /// Initializes a new instance of <see cref="Administration.ServicePrincipalCredentialEntity"/> for mocking purposes.
        /// </summary>
        /// <param name="id">Sets the <see cref="DataSourceCredentialEntity.Id"/> property.</param>
        /// <param name="name">Sets the <see cref="DataSourceCredentialEntity.Name"/> property.</param>
        /// <param name="description">Sets the <see cref="DataSourceCredentialEntity.Description"/> property.</param>
        /// <param name="clientId">Sets the <see cref="ServicePrincipalCredentialEntity.ClientId"/> property.</param>
        /// <param name="clientSecret">Sets the client secret. This secret is not exposed in a property.</param>
        /// <param name="tenantId">Sets the <see cref="ServicePrincipalCredentialEntity.TenantId"/> property.</param>
        /// <returns>A new instance of <see cref="Administration.ServicePrincipalCredentialEntity"/> for mocking purposes.</returns>
        public static ServicePrincipalCredentialEntity ServicePrincipalCredentialEntity(string id = null, string name = null, string description = null, string clientId = null, string clientSecret = null, string tenantId = null)
        {
            ServicePrincipalParam parameters = new ServicePrincipalParam(clientId, clientSecret, tenantId);

            return(new ServicePrincipalCredentialEntity(DataSourceCredentialKind.ServicePrincipal, id, name, description, parameters));
        }
 internal ServicePrincipalDatasourceCredential(DataSourceCredentialType dataSourceCredentialType, string id, string name, string description, ServicePrincipalParam parameters)
     : base(dataSourceCredentialType, id, name, description)
 {
     DataSourceCredentialType = dataSourceCredentialType;
     ClientId     = parameters.ClientId;
     ClientSecret = parameters.ClientSecret;
     TenantId     = parameters.TenantId;
 }
示例#6
0
 internal ServicePrincipalCredential(DataSourceCredentialType dataSourceCredentialType, Guid?dataSourceCredentialId, string dataSourceCredentialName, string dataSourceCredentialDescription, ServicePrincipalParam parameters) : base(dataSourceCredentialType, dataSourceCredentialId, dataSourceCredentialName, dataSourceCredentialDescription)
 {
     Parameters = parameters;
     DataSourceCredentialType = dataSourceCredentialType;
 }