HttpListenerBasicIdentity.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System.Security.Principal;
  2. namespace SocketHttpListener.Net
  3. {
  4. public class HttpListenerBasicIdentity : GenericIdentity
  5. {
  6. string password;
  7. public HttpListenerBasicIdentity(string username, string password)
  8. : base(username, "Basic")
  9. {
  10. this.password = password;
  11. }
  12. public virtual string Password
  13. {
  14. get { return password; }
  15. }
  16. }
  17. public class GenericIdentity : IIdentity
  18. {
  19. private string m_name;
  20. private string m_type;
  21. public GenericIdentity(string name)
  22. {
  23. if (name == null)
  24. throw new System.ArgumentNullException("name");
  25. m_name = name;
  26. m_type = "";
  27. }
  28. public GenericIdentity(string name, string type)
  29. {
  30. if (name == null)
  31. throw new System.ArgumentNullException("name");
  32. if (type == null)
  33. throw new System.ArgumentNullException("type");
  34. m_name = name;
  35. m_type = type;
  36. }
  37. public virtual string Name
  38. {
  39. get
  40. {
  41. return m_name;
  42. }
  43. }
  44. public virtual string AuthenticationType
  45. {
  46. get
  47. {
  48. return m_type;
  49. }
  50. }
  51. public virtual bool IsAuthenticated
  52. {
  53. get
  54. {
  55. return !m_name.Equals("");
  56. }
  57. }
  58. }
  59. }