mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-15 00:15:15 +08:00
* Implement enhanced authentication for client and server. * Update samples * Add abstraction layer * Merge master * Use dedicated class for public API. * Update release notes * Rename methods to fit naming scheme * Fix unit tests and samples
34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using MQTTnet.Packets;
|
|
|
|
namespace MQTTnet.Server.EnhancedAuthentication;
|
|
|
|
public static class ExchangeEnhancedAuthenticationResultFactory
|
|
{
|
|
public static ExchangeEnhancedAuthenticationResult Create(MqttAuthPacket authPacket)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(authPacket);
|
|
|
|
return new ExchangeEnhancedAuthenticationResult
|
|
{
|
|
AuthenticationData = authPacket.AuthenticationData,
|
|
|
|
ReasonString = authPacket.ReasonString,
|
|
UserProperties = authPacket.UserProperties
|
|
};
|
|
}
|
|
|
|
public static ExchangeEnhancedAuthenticationResult Create(MqttDisconnectPacket disconnectPacket)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(disconnectPacket);
|
|
|
|
return new ExchangeEnhancedAuthenticationResult
|
|
{
|
|
AuthenticationData = null,
|
|
ReasonString = disconnectPacket.ReasonString,
|
|
UserProperties = disconnectPacket.UserProperties
|
|
|
|
// SessionExpiryInterval makes no sense because the connection is not yet made!
|
|
// ServerReferences makes no sense when the client initiated a DISCONNECT!
|
|
};
|
|
}
|
|
} |