internal static void ApplicationInfo(GenericApplicationParms parms) { if (parms.ApplictionId == null) { throw new InvalidOperationException("Must specify a application"); } foreach (var un in parms.ApplictionId) { var device = m_client.GetApplications(o => o.Name == un).CollectionItem.FirstOrDefault() as SecurityApplicationInfo; if (device == null) { throw new KeyNotFoundException($"Application {un} not found"); } DisplayUtil.PrintPolicies(device, new string[] { "Name", "SID", "Invalid Auth", "Lockout", "Last Auth", "Created", "Updated", "De-Activated" }, u => u.Name, u => u.Key, u => u.InvalidAuthAttempts, u => u.LockoutXml, u => u.LastAuthenticationXml, u => String.Format("{0} ({1})", u.CreationTimeXml, m_client.GetUser(m_client.GetProvenance(u.CreatedByKey.Value).UserKey.Value).Entity.UserName), u => String.Format("{0} ({1})", u.UpdatedTimeXml, m_client.GetUser(m_client.GetProvenance(u.UpdatedByKey.Value).UserKey.Value).Entity.UserName), u => String.Format("{0} ({1})", u.ObsoletionTimeXml, m_client.GetUser(m_client.GetProvenance(u.ObsoletedByKey.Value).UserKey.Value).Entity.UserName) ); } }
// [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); } }