feat: Füge UserCredential-Klasse für die Windream-API-Integration hinzu
- UserCredential-Klasse erstellt, um Benutzerdaten für die Windream-API zu verwalten. - Konstruktor implementiert, um Domain, Name und Passwort zu initialisieren. - ConvertToBase64-Methode hinzugefügt, um Anmeldeinformationen für den Autorisierungsheader zu kodieren.
This commit is contained in:
28
src/WindreamHub.Legacy.Client/Models/UserCredential.cs
Normal file
28
src/WindreamHub.Legacy.Client/Models/UserCredential.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace WindreamHub.Legacy.Client.Models
|
||||
{
|
||||
public class UserCredential
|
||||
{
|
||||
public readonly string Domain;
|
||||
|
||||
public readonly string Name;
|
||||
|
||||
public readonly string AuthorizationHeader;
|
||||
|
||||
public UserCredential(string domain, string name, string password)
|
||||
{
|
||||
Domain = domain;
|
||||
Name = name;
|
||||
AuthorizationHeader = ConvertToBase64(domain, name, password);
|
||||
}
|
||||
|
||||
private static string ConvertToBase64(string domain, string username, string password)
|
||||
{
|
||||
string credentials = $"{domain}\\{username}:{password}";
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(credentials);
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using DigitalData.Core.Legacy.Client;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using WindreamHub.Legacy.Client.Routes;
|
||||
|
||||
@@ -87,6 +87,7 @@
|
||||
<Compile Include="Models\SimplifiedResponse.cs" />
|
||||
<Compile Include="Models\SystemDetails.cs" />
|
||||
<Compile Include="Models\SystemDetailsResponse.cs" />
|
||||
<Compile Include="Models\UserCredential.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Routes\BaseRouteService.cs" />
|
||||
<Compile Include="Routes\RouteExtensions.cs" />
|
||||
|
||||
Reference in New Issue
Block a user