From 05c263ea66f1d81b69a32452bfcf5a61d4c712c9 Mon Sep 17 00:00:00 2001
From: Klaus Fischer <klaus.fischer@eloware.com>
Date: Wed, 8 Jun 2022 14:57:57 +0200
Subject: [PATCH] Renamed Encryption classes due to extraction from inheritance

---
 ...nderEncryptionWithSelfSignedCertificateTest.cs |  2 +-
 FitConnect/FitConnect.csproj                      | 14 +++++++-------
 FitConnect/FunctionalBaseClass.cs                 | 15 ++++++++++-----
 .../{IEncryptionBaseClass.cs => IEncryption.cs}   |  2 +-
 .../{EncryptionBaseClass.cs => RsaEncryption.cs}  |  4 ++--
 5 files changed, 21 insertions(+), 16 deletions(-)
 rename FitConnect/{IEncryptionBaseClass.cs => IEncryption.cs} (95%)
 rename FitConnect/{EncryptionBaseClass.cs => RsaEncryption.cs} (97%)

diff --git a/EncryptionTests/SenderEncryptionWithSelfSignedCertificateTest.cs b/EncryptionTests/SenderEncryptionWithSelfSignedCertificateTest.cs
index 0746fc64..6c81f27c 100644
--- a/EncryptionTests/SenderEncryptionWithSelfSignedCertificateTest.cs
+++ b/EncryptionTests/SenderEncryptionWithSelfSignedCertificateTest.cs
@@ -24,7 +24,7 @@ public class SenderEncryptionWithSelfSignedCertificateTest {
 
     [OneTimeSetUp]
     public void OneTimeSetup() {
-        _certificate = EncryptionBaseClass.CreateSelfSignedCertificate("./");
+        _certificate = RsaEncryption.CreateSelfSignedCertificate("./");
     }
 
     [OneTimeTearDown]
diff --git a/FitConnect/FitConnect.csproj b/FitConnect/FitConnect.csproj
index 868bb140..fa839cf2 100644
--- a/FitConnect/FitConnect.csproj
+++ b/FitConnect/FitConnect.csproj
@@ -11,19 +11,19 @@
     </PropertyGroup>
 
     <ItemGroup>
-        <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1"/>
-        <PackageReference Include="Newtonsoft.Json" Version="13.0.1"/>
-        <PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.14"/>
-        <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.19.0"/>
+        <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
+        <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
+        <PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.14" />
+        <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.19.0" />
     </ItemGroup>
 
     <ItemGroup>
-        <None Remove="metadata.schema.json"/>
-        <EmbeddedResource Include="metadata.schema.json"/>
+        <None Remove="metadata.schema.json" />
+        <EmbeddedResource Include="metadata.schema.json" />
     </ItemGroup>
 
     <ItemGroup>
-        <Folder Include="Interfaces"/>
+        <Folder Include="Interfaces" />
     </ItemGroup>
 
 </Project>
diff --git a/FitConnect/FunctionalBaseClass.cs b/FitConnect/FunctionalBaseClass.cs
index a8dd49b7..41fa5dea 100644
--- a/FitConnect/FunctionalBaseClass.cs
+++ b/FitConnect/FunctionalBaseClass.cs
@@ -9,20 +9,24 @@ namespace FitConnect;
 
 public class FunctionalBaseClass {
     protected readonly ILogger? Logger;
-    public IEncryptionBaseClass Encryption;
+    public readonly IEncryption Encryption;
 
     /// <summary>
     ///     Constructor for the FunctionalBaseClass
     /// </summary>
     /// <param name="logger">ILogger implementation</param>
     /// <param name="endpoints">FitConnect endpoints</param>
+    /// <param name="certificate">The Encryption certificate</param>
+    /// <example>
+    /// new Sender(logger, FitConnectEndpoints.Create(FitConnectEndpoints.EndpointType.Development))
+    /// </example>
     protected FunctionalBaseClass(ILogger? logger, FitConnectEndpoints? endpoints,
         X509Certificate2? certificate) {
         Endpoints = endpoints ??
                     FitConnectEndpoints.Create(FitConnectEndpoints.EndpointType.Development);
 
         Logger = logger;
-        Encryption = new EncryptionBaseClass(logger, certificate);
+        Encryption = new RsaEncryption(logger, certificate);
     }
 
     public FitConnectEndpoints Endpoints { get; }
@@ -30,13 +34,14 @@ public class FunctionalBaseClass {
 
     /// <summary>
     ///     Requesting an OAuth token from the FitConnect API.
-    ///     You can get the Client ID and Client Secret from the FitConnect Self Service portal
-    ///     under https://portal.auth-testing.fit-connect.fitko.dev
+    ///     <para>You can get the Client ID and Client Secret from the FitConnect Self Service portal
+    ///     under <br/>
+    ///     https://portal.auth-testing.fit-connect.fitko.dev</para>
     /// </summary>
     /// <param name="clientId">Your client Id</param>
     /// <param name="clientSecret">Your client Secret</param>
     /// <param name="scope">Scope if needed</param>
-    /// <returns></returns>
+    /// <returns>The received token or null</returns>
     public async Task<OAuthAccessToken?> GetTokenAsync(string clientId, string clientSecret,
         string? scope = null) {
         var client = new HttpClient();
diff --git a/FitConnect/IEncryptionBaseClass.cs b/FitConnect/IEncryption.cs
similarity index 95%
rename from FitConnect/IEncryptionBaseClass.cs
rename to FitConnect/IEncryption.cs
index ce031972..5798a77c 100644
--- a/FitConnect/IEncryptionBaseClass.cs
+++ b/FitConnect/IEncryption.cs
@@ -2,7 +2,7 @@ using System.Security.Cryptography.X509Certificates;
 
 namespace FitConnect;
 
-public interface IEncryptionBaseClass {
+public interface IEncryption {
     /// <summary>
     ///     Just for Proof of Concept
     /// </summary>
diff --git a/FitConnect/EncryptionBaseClass.cs b/FitConnect/RsaEncryption.cs
similarity index 97%
rename from FitConnect/EncryptionBaseClass.cs
rename to FitConnect/RsaEncryption.cs
index f244489f..0a46a1e4 100644
--- a/FitConnect/EncryptionBaseClass.cs
+++ b/FitConnect/RsaEncryption.cs
@@ -7,7 +7,7 @@ using Microsoft.IdentityModel.Tokens;
 
 namespace FitConnect;
 
-public class EncryptionBaseClass : IEncryptionBaseClass {
+public class RsaEncryption : IEncryption {
     private readonly ILogger? _logger;
     private readonly RSA _rsa;
     private readonly X509Certificate2? certificate;
@@ -15,7 +15,7 @@ public class EncryptionBaseClass : IEncryptionBaseClass {
     private RSA? _publicKey;
 
 
-    internal EncryptionBaseClass(ILogger? logger, X509Certificate2? certificate) {
+    internal RsaEncryption(ILogger? logger, X509Certificate2? certificate) {
         _logger = logger;
         _rsa = RSA.Create(4096);
 
-- 
GitLab