Esempio n. 1
0
        public Task <Identity> GetCertAuditor(string ClusterNode, IdentityFilter filter)
        {
            var builder = new HttpRequest.Builder().BaseURL(_url)
                          .Uri("/api/identity/CertAuditor")
                          .AddParam("ClusterNode", ClusterNode)
                          .AddInterceptor(new JsonDeserializerInterceptor());

            if (!string.IsNullOrEmpty(filter.Name))
            {
                builder.AddParam("name", filter.Name.Trim());
            }

            if (!string.IsNullOrEmpty(filter.Email))
            {
                builder.AddParam("email", filter.Email.Trim());
            }

            if ((filter.RequestTypes?.Length ?? 0) > 0)
            {
                for (int i = 0; i < filter.RequestTypes.Length; i++)
                {
                    builder.AddParam($"requestTypes[{i}]", $"{(int)filter.RequestTypes[i]}");
                }
            }

            if ((filter.Permissions?.Length ?? 0) > 0)
            {
                for (int i = 0; i < filter.Permissions.Length; i++)
                {
                    builder.AddParam($"permissions[{i}]", $"{(int)filter.Permissions[i]}");
                }
            }

            if ((filter.Clusters?.Length ?? 0) > 0)
            {
                for (int i = 0; i < filter.Clusters.Length; i++)
                {
                    builder.AddParam($"clusters[{i}]", $"{filter.Clusters[i]}");
                }
            }

            return(builder.Execute <Identity>());
        }
Esempio n. 2
0
        public HttpRequest.Builder BuildUpon(string baseUrl)
        {
            var builder = new HttpRequest.Builder().BaseURL(baseUrl)
                          .AddInterceptor(new HttpExceptionInterceptor());

            var identity = _contextAccessor.HttpContext.User;

            if (identity != null)
            {
                var token = identity.FindFirst("Token")?.Value;
                if (!string.IsNullOrEmpty(token))
                {
                    builder.AddProperty("Authorization", $"Bearer {token}");
                }

                var user = identity.ToOfficer();
                builder.AddParam("userID", user?.ID.ToString());
                builder.AddParam("userName", user?.Name);
                builder.AddParam("userEmail", user?.Email);
            }

            return(builder);
        }