public HostWithCredentials(CredentialDomain domain, int index) : base(domain.Hosts[index]) { Guid id = domain.Hosts[index].ID; domain.Normalize(); this.Credentials = domain.Credentials.Where(c => c.Hosts.Contains(id)).Select(a => new CredentialData(a)).ToArray(); }
public CredentialWithHosts(CredentialDomain domain, int index) : base(domain.Credentials[index]) { List <Guid> paths = domain.Credentials[index].Paths; domain.Normalize(); this.Hosts = domain.Credentials[index].Hosts.SelectMany(g => domain.Hosts.Where(h => h.ID.Equals(g))).Select(a => new ResourceAuthorityInfo(a, paths)).ToArray(); }
public CredentialDomainInfo(CredentialDomain source) { if (source == null) { return; } source.Normalize(); this.ID = source.__IDString; this.Active = source.Active; this.Order = source.Order; this.ResourceAuthority = source.Hosts.Select(h => new ResourceAuthorityInfo(h)).ToArray(); this.Credentials = source.Credentials.ToArray(); }
private static void HandleListApi(string path, HttpRequest request, HttpResponse response, IHostingEnvironment env) { if (path.StartsWith("/")) { path = (path.Length == 1) ? "" : path.Substring(1); } CredentialDataStore dataStore = CredentialDataStore.Load(env, "credentials.json"); Guid id; switch (path) { case "domain": HandleReturnResult <CredentialDomainInfo[]>(dataStore.Domains.Select(d => new CredentialDomainInfo(d)).ToArray(), response, env); break; case "host": HostWithCredentials[] hwc = new HostWithCredentials[0]; if (request.Query.ContainsKey("domain") && Guid.TryParse(request.Query["domain"], out id)) { CredentialDomain domain = dataStore.Domains.FirstOrDefault(d => d.ID.Equals(id)); if (domain != null) { if (request.Query.ContainsKey("id")) { if (Guid.TryParse(request.Query["id"], out id)) { hwc = domain.Hosts.Where(h => h.ID.Equals(id)).Select((h, i) => new HostWithCredentials(domain, i)).ToArray(); } } else { hwc = domain.Hosts.Select((h, i) => new HostWithCredentials(domain, i)).ToArray(); } } } HandleReturnResult <HostWithCredentials[]>(hwc, response, env); break; } }