2
0

HttpListenerBasicIdentity.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 => password;
  13. }
  14. public class GenericIdentity : IIdentity
  15. {
  16. private string m_name;
  17. private string m_type;
  18. public GenericIdentity(string name)
  19. {
  20. if (name == null)
  21. throw new System.ArgumentNullException(nameof(name));
  22. m_name = name;
  23. m_type = "";
  24. }
  25. public GenericIdentity(string name, string type)
  26. {
  27. if (name == null)
  28. throw new System.ArgumentNullException(nameof(name));
  29. if (type == null)
  30. throw new System.ArgumentNullException(nameof(type));
  31. m_name = name;
  32. m_type = type;
  33. }
  34. public virtual string Name => m_name;
  35. public virtual string AuthenticationType => m_type;
  36. public virtual bool IsAuthenticated => !m_name.Equals("");
  37. }
  38. }