You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace uPLibrary.Networking.M2Mqtt.Managers
|
|
{
|
|
/// <summary>
|
|
/// Delegate for executing user authentication
|
|
/// </summary>
|
|
/// <param name="username">Username</param>
|
|
/// <param name="password">Password</param>
|
|
/// <returns></returns>
|
|
public delegate bool MqttUserAuthenticationDelegate(string username, string password);
|
|
|
|
/// <summary>
|
|
/// Manager for User Access Control
|
|
/// </summary>
|
|
public class MqttUacManager
|
|
{
|
|
// user authentication delegate
|
|
private MqttUserAuthenticationDelegate userAuth;
|
|
|
|
/// <summary>
|
|
/// User authentication method
|
|
/// </summary>
|
|
public MqttUserAuthenticationDelegate UserAuth
|
|
{
|
|
get { return this.userAuth; }
|
|
set { this.userAuth = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Execute user authentication
|
|
/// </summary>
|
|
/// <param name="username">Username</param>
|
|
/// <param name="password">Password</param>
|
|
/// <returns>Access granted or not</returns>
|
|
public bool UserAuthentication(string username, string password)
|
|
{
|
|
if (this.userAuth == null)
|
|
return true;
|
|
else
|
|
return this.userAuth(username, password);
|
|
}
|
|
}
|
|
}
|