Codebasis als Dateien ins Arbeitsrepo statt als Gitlink

QuellCode/CentronERP war nur als Gitlink (Submodul-Referenz auf 79c1142)
getrackt, ohne .gitmodules und ohne erreichbares Remote. Der
Untersuchungsgegenstand der Versuchsreihe war damit nicht reproduzierbar
gesichert: Ein Klon haette ein leeres Verzeichnis erhalten, und die Belege
der 3.287 Anforderungen waeren nicht ueberpruefbar gewesen.

Umstellung:
- Historie nach c:\DEV\CentronERP_git_snapshot_79c1142 ausgelagert
  (vollstaendig lesbar, enthaelt 79c1142 und Vorgaenger 89ccfd6)
- Gitlink aus dem Index entfernt
- Dateiinhalt aufgenommen: 24.557 Dateien, rund 333 MB

Die verschachtelte .gitignore der Codebasis gilt weiter, Build-Artefakte
bleiben ausgeschlossen. Details in Versuche/Versuch_01/_Codebasis-Nachweis.md
This commit is contained in:
Christoph Schwörer
2026-08-26 07:43:51 +02:00
parent 18edae75b6
commit f045b99a25
24664 changed files with 5846716 additions and 1 deletions
@@ -0,0 +1,70 @@
using Centron.Api.docuFORM.Models;
using System;
using System.Collections.Generic;
using System.Net;
using System.Reflection;
using System.Text;
using System.Text.Json.Serialization;
namespace Centron.Api.docuFORM.Helper
{
public static class DocuFormRequestHelper
{
public static string CreateAuthorizationRequestURI(AuthCodeRequest authCodeRequest, string? baseUriToAdd = null)
{
var parameters = RequestToParameterString(authCodeRequest);
var endPointAndParameters = DocuFormRestApiConstants._endpointAuthCode + "?" + parameters;
var baseUri = baseUriToAdd != null
? new Uri(baseUriToAdd)
: null;
return baseUri != null
? new Uri(baseUri, endPointAndParameters).ToString()
: endPointAndParameters;
}
public static string RequestToParameterString<T>(T request)
{
var parameters = RequestToParameters(request);
var parameterString = string.Join("&", parameters.Select(f => $"{WebUtility.UrlEncode(f.Key)}={WebUtility.UrlEncode(f.Value)}"));
return parameterString;
}
public static Dictionary<string, string> RequestToParameters<T>(T request, bool removeParameterWithoutValue = true)
{
var dict = new Dictionary<string, string>();
var props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (var prop in props)
{
var attr = prop.GetCustomAttribute<JsonPropertyNameAttribute>();
var key = attr?.Name ?? prop.Name;
var value = prop.GetValue(request)?.ToString();
if(removeParameterWithoutValue && string.IsNullOrWhiteSpace(value))
continue;
dict[key] = value ?? string.Empty;
}
return dict;
}
public static string CreateRedirectURI(int? portNumber = null)
{
var uriBuilder = new UriBuilder(DocuFormRestApiConstants._redirectURI);
uriBuilder.Port = portNumber.HasValue && portNumber.Value > 0
? portNumber.Value
: -1;
var uri = uriBuilder.ToString();
while(uri.EndsWith("/"))
uri = uri.Substring(0, uri.Length - 1);
return uri;
}
}
}
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Net.Http.Headers;
using System.Text;
namespace Centron.Api.docuFORM.Helper
{
public static class HttpClientExtensions
{
public static async Task<HttpResponseMessage> SendRequestWithToken(this HttpClient httpClient, HttpRequestMessage httpRequest, string token)
{
httpRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
if (httpRequest.Headers.Accept.Count == 0)
httpRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
return await httpClient.SendAsync(httpRequest).ConfigureAwait(false);
}
}
}
@@ -0,0 +1,50 @@
using Centron.Api.docuFORM.Models.Swagger.Responses;
using Centron.Interfaces.BL;
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Text.Json;
namespace Centron.Api.docuFORM.Helper
{
public static class HttpResponseMessageExtensions
{
public static async Task<string> ReadContentAndThrowIfError(this HttpResponseMessage? response)
{
if(response == null)
throw new HttpRequestException ($"No http response received!");
var content = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
throw new HttpRequestException ($"An error occured during the http request: {content}");
return content;
}
public static async Task<Result<T>> CheckResponseAndDeserializeContent<T>(this HttpResponseMessage? response)
{
try
{
if(response == null)
throw new HttpRequestException ($"No http response received!");
var content = await ReadContentAndThrowIfError(response);
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
var obj = JsonSerializer.Deserialize<T>(content, options);
if(obj != null)
return Result<T>.AsSuccess(obj);
return Result<T>.AsError("Unable to deserialize object!");
}
catch (Exception ex)
{
return Result<T>.FromException(ex);
}
}
}
}
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
namespace Centron.Api.docuFORM.Helper
{
public static class OAuthHelper
{
// Can be used to generate a "state" or the codeVerifier for the "code challenge"
public static string GenerateRandomBase64String(int byteLength = 32)
{
byte[] randomBytes = new byte[byteLength];
using (var rng = RandomNumberGenerator.Create())
{
rng.GetBytes(randomBytes);
}
// Base64 URL-safe encoding
string state = Convert.ToBase64String(randomBytes)
.Replace("+", "-")
.Replace("/", "_")
.Replace("=", "");
return state;
}
public static string GenerateCodeChallenge(string codeVerifier)
{
using (var sha256 = SHA256.Create())
{
byte[] hash = sha256.ComputeHash(Encoding.ASCII.GetBytes(codeVerifier));
string codeChallenge = Convert.ToBase64String(hash)
.Replace("+", "-")
.Replace("/", "_")
.Replace("=", "");
return codeChallenge;
}
}
}
}