public static void Run() { Protector.Register("Alice", "Pa$$w0rd", new[] { "Admins" }); Protector.Register("Bob", "Pa$$w0rd", new[] { "Sales", "TeamLeads" }); Protector.Register("Eve", "Pa$$w0rd"); Write($"Enter your user name: "); string username = ReadLine(); Write($"Enter your password: "******"Log in failed."); return; } var p = Thread.CurrentPrincipal; WriteLine($"IsAuthenticated: {p.Identity.IsAuthenticated}"); WriteLine($"AuthenticationType: {p.Identity.AuthenticationType}"); WriteLine($"Name: {p.Identity.Name}"); WriteLine($"IsInRole(\"Admins\"): {p.IsInRole("Admins")}"); WriteLine($"IsInRole(\"Sales\"): {p.IsInRole("Sales")}"); if (p is ClaimsPrincipal) { WriteLine($"{p.Identity.Name} has the following claims:"); foreach (Claim claim in (p as ClaimsPrincipal).Claims) { WriteLine($"{claim.Type}: {claim.Value}"); } } try { SecureFeature(); } catch (System.Exception ex) { WriteLine($"{ex.GetType()}: {ex.Message}"); } }