2019-01-13 20:03:10 +00:00
|
|
|
using System.Security.Principal;
|
2016-11-11 19:55:12 +00:00
|
|
|
|
|
|
|
namespace SocketHttpListener.Net
|
|
|
|
{
|
|
|
|
public class HttpListenerBasicIdentity : GenericIdentity
|
|
|
|
{
|
|
|
|
string password;
|
|
|
|
|
|
|
|
public HttpListenerBasicIdentity(string username, string password)
|
|
|
|
: base(username, "Basic")
|
|
|
|
{
|
|
|
|
this.password = password;
|
|
|
|
}
|
|
|
|
|
2019-01-13 20:31:14 +00:00
|
|
|
public virtual string Password => password;
|
2016-11-11 19:55:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public class GenericIdentity : IIdentity
|
|
|
|
{
|
|
|
|
private string m_name;
|
|
|
|
private string m_type;
|
|
|
|
|
|
|
|
public GenericIdentity(string name)
|
|
|
|
{
|
|
|
|
if (name == null)
|
2019-01-06 20:50:43 +00:00
|
|
|
throw new System.ArgumentNullException(nameof(name));
|
2016-11-11 19:55:12 +00:00
|
|
|
|
|
|
|
m_name = name;
|
|
|
|
m_type = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
public GenericIdentity(string name, string type)
|
|
|
|
{
|
|
|
|
if (name == null)
|
2019-01-06 20:50:43 +00:00
|
|
|
throw new System.ArgumentNullException(nameof(name));
|
2016-11-11 19:55:12 +00:00
|
|
|
if (type == null)
|
2019-01-06 20:50:43 +00:00
|
|
|
throw new System.ArgumentNullException(nameof(type));
|
2016-11-11 19:55:12 +00:00
|
|
|
|
|
|
|
m_name = name;
|
|
|
|
m_type = type;
|
|
|
|
}
|
|
|
|
|
2019-01-13 20:31:14 +00:00
|
|
|
public virtual string Name => m_name;
|
2016-11-11 19:55:12 +00:00
|
|
|
|
2019-01-13 20:31:14 +00:00
|
|
|
public virtual string AuthenticationType => m_type;
|
2016-11-11 19:55:12 +00:00
|
|
|
|
2019-01-13 20:31:14 +00:00
|
|
|
public virtual bool IsAuthenticated => !m_name.Equals("");
|
2016-11-11 19:55:12 +00:00
|
|
|
}
|
|
|
|
}
|