// [PolicyPermission(System.Security.Permissions.SecurityAction.Demand, PolicyId = PermissionPolicyIdentifiers.UnrestrictedMetadata)] public static void AddAssigningAuthority(AddAssigningAuthorityParams parms) { // First, resolve the assigner SecurityApplicationInfo assigner = null; if (!String.IsNullOrEmpty(parms.Assigner)) { assigner = m_amiClient.GetApplications(o => o.Name == parms.Assigner).CollectionItem.FirstOrDefault() as SecurityApplicationInfo; if (assigner == null) { throw new KeyNotFoundException("Assigner unknown"); } } // Scope List <Concept> scope = new List <Concept>(); if (parms.Scope?.Count > 0) { foreach (var s in parms.Scope) { var scp = m_hdsiClient.Query <Concept>(o => o.Mnemonic == s, 0, 1, false).Item.OfType <Concept>().FirstOrDefault(); if (scp == null) { throw new KeyNotFoundException($"Scope {s} unknown"); } scope.Add(scp); } } // Construct AA foreach (var domainName in parms.Authority) { var aa = new AssigningAuthority(domainName, parms.Name, parms.Oid) { Url = parms.Url, AuthorityScope = scope, AssigningApplication = assigner?.Entity, IsUnique = parms.Unique }; aa = m_amiClient.CreateAssigningAuthority(aa); Console.WriteLine("CREATE AUTHORITY {0} = {1}", aa.DomainName, aa.Key); } }