private TicketIdentity AuthorizeUser(string ticket, string role) { TicketIdentity ticketIdentity = AuthorizeUser(ticket); if (Array.IndexOf(ticketIdentity.Roles, role) == -1) { throw new SecurityException("Insufficient permissions."); } else { return(ticketIdentity); } }
private TicketIdentity AuthorizeUser(string ticket) { TicketIdentity ticketIdentity = (TicketIdentity)Application[ticket]; if (ticket != null) { return(ticketIdentity); } else { throw new SecurityException("Invalid ticket."); } }
public void Login(string userName, string password, HashAlgorithm hashAlgorithm) { if (Authenticate(userName, password, hashAlgorithm)) { // Get the user roles. string[] roles = GetRoles(userName); // Create a new ticket. TicketIdentity ticket = new TicketIdentity(userName, roles); // Add this ticket to Application state. Application[ticket.Ticket] = ticket; // Create the SOAP header. Ticket = new TicketHeader(ticket.Ticket); } else { throw new SecurityException("Invalid credentials."); } }