diff --git a/E2ETests/SenderTest.cs b/E2ETests/SenderTest.cs index 2f6be8761a5325fe4ef693c0fbd06b09ad99cacb..89e24617b2312435da908c105953782d2d33dfa1 100644 --- a/E2ETests/SenderTest.cs +++ b/E2ETests/SenderTest.cs @@ -85,7 +85,7 @@ public class SenderTest { // Arrange var dut = _fluentSender .WithDestination(desitnationId) - .WithServiceType("ServcieName", "urn:de:fim:leika:leistung:99400048079000"); + .WithServiceType("ServiceName", "urn:de:fim:leika:leistung:99400048079000"); var attachments = new List<Attachment>(); for (var i = 0; i < 10; i++) { diff --git a/Encryption/JoseEncryptor.cs b/Encryption/JoseEncryptor.cs index 8d4d7adcdee978788cfcba912d1dccd853df3bcd..c930cd2c02c8885877a26075013b4c1174e63b77 100644 --- a/Encryption/JoseEncryptor.cs +++ b/Encryption/JoseEncryptor.cs @@ -7,6 +7,9 @@ public class JoseEncryptor : IEncryptor { private const JweCompression Compression = JweCompression.DEF; private const JweAlgorithm Algorithm = JweAlgorithm.RSA_OAEP; + private const string ErrorMessage = + "On macOS add DYLD_LIBRARY_PATH to your environment variables. Look at the README for more information."; + private (string plainText, byte[] plainBytes, byte[] tag) Decrypt(Jwk key, string payload) { var result = JWE.Decrypt(payload, key); @@ -15,21 +18,36 @@ public class JoseEncryptor : IEncryptor { public (string plainText, byte[] plainBytes, byte[] tag) Decrypt(string key, string cipher) { - var jwk = Jwk.FromJson(key, new Jose.JsonMapper()); - return Decrypt(jwk, cipher); + try { + var jwk = Jwk.FromJson(key, new Jose.JsonMapper()); + return Decrypt(jwk, cipher); + } + catch (PlatformNotSupportedException e) { + throw new PlatformNotSupportedException(ErrorMessage, e); + } } public string Encrypt(string key, string plain) { - var jwk = Jwk.FromJson(key, new Jose.JsonMapper()); - return JWE.Encrypt(plain, - new JweRecipient[] { new JweRecipient(Algorithm, jwk) }, - Encryption, compression: Compression); + try { + var jwk = Jwk.FromJson(key, new Jose.JsonMapper()); + return JWE.Encrypt(plain, + new JweRecipient[] { new JweRecipient(Algorithm, jwk) }, + Encryption, compression: Compression); + } + catch (PlatformNotSupportedException e) { + throw new PlatformNotSupportedException(ErrorMessage, e); + } } public string Encrypt(string key, byte[] plain) { - var jwk = Jwk.FromJson(key, new Jose.JsonMapper()); - return JWE.EncryptBytes(plain, - new JweRecipient[] { new JweRecipient(Algorithm, jwk) }, - Encryption, compression: Compression); + try { + var jwk = Jwk.FromJson(key, new Jose.JsonMapper()); + return JWE.EncryptBytes(plain, + new JweRecipient[] { new JweRecipient(Algorithm, jwk) }, + Encryption, compression: Compression); + } + catch (PlatformNotSupportedException e) { + throw new PlatformNotSupportedException(ErrorMessage, e); + } } } diff --git a/FitConnect/FluentSender.cs b/FitConnect/FluentSender.cs index 5f31286773054f179c9c2af9c94c049dd8fad5f0..7b0eeaaf0b1033d23ec6f2a9af800db9faeb8eff 100644 --- a/FitConnect/FluentSender.cs +++ b/FitConnect/FluentSender.cs @@ -38,9 +38,9 @@ public class FluentSender : Sender, IFluentSender, IFluentSenderWithDestination, routeService, destinationService, logger) { } - public string PublicKey { get; set; } + public string? PublicKey { get; set; } public CreateSubmissionDto? NewSubmission { get; set; } - public Submission Submission { get; set; } + public Submission? Submission { get; set; } public IFluentSenderWithDestination FindDestinationId(string leiaKey, string? ags, string? ars, diff --git a/FitConnect/Models/Destination.cs b/FitConnect/Models/Destination.cs index fe73e08aa441ed499c07cc121caa587e3109fef5..7230666d2695cb586c0e39d804a357564872e304 100644 --- a/FitConnect/Models/Destination.cs +++ b/FitConnect/Models/Destination.cs @@ -1,11 +1,11 @@ namespace FitConnect.Models; public class Destination { - public string LeikaKey { get; set; } + public string? LeikaKey { get; set; } public string? Ags { get; set; } public string? Ars { get; set; } public string? AreaId { get; set; } - public string DestinationId { get; set; } + public string? DestinationId { get; set; } public bool Valid => !((string.IsNullOrWhiteSpace(Ags) && string.IsNullOrWhiteSpace(Ars) diff --git a/FitConnect/Models/Submission.cs b/FitConnect/Models/Submission.cs index 6917a36fe561bcfc789780726ae292213b798858..638397fec38d446f0542d2e1ca5065005e0164d1 100644 --- a/FitConnect/Models/Submission.cs +++ b/FitConnect/Models/Submission.cs @@ -4,9 +4,9 @@ using FitConnect.Services.Models.v1; namespace FitConnect.Models; public class Submission { - public string Id { get; set; } + public string? Id { get; set; } public string? CaseId { get; set; } - public Destination Destination { get; set; } = new(); + public Destination? Destination { get; set; } = new(); public string DestinationId { get => Destination.DestinationId; diff --git a/Services/Models/CallbackDto.cs b/Services/Models/CallbackDto.cs index 2a2e45adfbdf83955c5c784b972d4786f80783c3..0228e1f89d81fb88a94ded3a2d5f45f55f8789f0 100644 --- a/Services/Models/CallbackDto.cs +++ b/Services/Models/CallbackDto.cs @@ -4,7 +4,7 @@ namespace FitConnect.Services.Models; public class CallbackDto { [JsonPropertyName("url")] - public string Url { get; set; } + public string? Url { get; set; } [JsonPropertyName("secret")] public string? Secret { get; set; } diff --git a/Services/Models/OAuthAccessToken.cs b/Services/Models/OAuthAccessToken.cs index 3fc70d9b9c1063c2df508e3accbd4756e85939e4..57b9ac9e916f330ad990e3d319ca1320387263ef 100644 --- a/Services/Models/OAuthAccessToken.cs +++ b/Services/Models/OAuthAccessToken.cs @@ -4,13 +4,13 @@ namespace FitConnect.Services.Models; public class OAuthAccessToken { [JsonPropertyName("access_token")] - public string AccessToken { get; set; } + public string? AccessToken { get; set; } [JsonPropertyName("scope")] - public string Scope { get; set; } + public string? Scope { get; set; } [JsonPropertyName("token_type")] - public string TokenType { get; set; } + public string? TokenType { get; set; } [JsonPropertyName("expires_in")] public int ExpiresIn { get; set; } diff --git a/Services/Models/v1/Case/EventLogDto.cs b/Services/Models/v1/Case/EventLogDto.cs index 54598c77b3ef2ca51c05ab3b70415e9c2e814788..6e40e32a6c35dc07330380daae72d45f02d2a597 100644 --- a/Services/Models/v1/Case/EventLogDto.cs +++ b/Services/Models/v1/Case/EventLogDto.cs @@ -4,14 +4,14 @@ namespace FitConnect.Services.Models.v1; public class EventLogDto { [JsonPropertyName("count")] - public int Count; + public int Count{ get; set; } [JsonPropertyName("eventLog")] - public List<string> EventLog; + public List<string>? EventLog{ get; set; } [JsonPropertyName("offset")] - public int Offset; + public int Offset{ get; set; } [JsonPropertyName("totalCount")] - public long TotalCount; + public long TotalCount{ get; set; } } diff --git a/Services/Models/v1/Destination/ContactInformationDto.cs b/Services/Models/v1/Destination/ContactInformationDto.cs index cb65d109388f8002bb6be72c5f9526ece5246869..c715f6adbbe3b7a0ac98f3153bea4a6cf772d675 100644 --- a/Services/Models/v1/Destination/ContactInformationDto.cs +++ b/Services/Models/v1/Destination/ContactInformationDto.cs @@ -4,17 +4,17 @@ namespace FitConnect.Services.Models.v1; public class ContactInformationDto { [JsonPropertyName("address")] - public string Address; + public string? Address{ get; set; } [JsonPropertyName("email")] - public string Email; + public string? Email{ get; set; } [JsonPropertyName("legalName")] - public string LegalName; + public string? LegalName{ get; set; } [JsonPropertyName("phone")] - public string Phone; + public string? Phone{ get; set; } [JsonPropertyName("unit")] - public string Unit; + public string? Unit{ get; set; } } diff --git a/Services/Models/v1/Destination/CreateDestinationDto.cs b/Services/Models/v1/Destination/CreateDestinationDto.cs index 984fb40e18cb2193e93531b7e7a04b40cb5ce44b..8f731baf06d481c905dfce06daed7f650235c3f9 100644 --- a/Services/Models/v1/Destination/CreateDestinationDto.cs +++ b/Services/Models/v1/Destination/CreateDestinationDto.cs @@ -4,32 +4,32 @@ namespace FitConnect.Services.Models.v1; public class CreateDestinationDto { [JsonPropertyName("callback")] - public CallbackDto Callback; + public CallbackDto? Callback { get; set; } [JsonPropertyName("contactInformation")] - public ContactInformationDto ContactInformation; + public ContactInformationDto? ContactInformation { get; set; } [JsonPropertyName("encryptionKid")] - public string EncryptionKid; + public string? EncryptionKid { get; set; } [JsonPropertyName("encryptionPublicKey")] - public string EncryptionPublicKey; + public string? EncryptionPublicKey { get; set; } [JsonPropertyName("metadataVersions")] - public List<string> metadataVersions; + public List<string>? MetadataVersions { get; set; } [JsonPropertyName("replyChannels")] - public DestinationReplyChannelsDto ReplyChannels; + public DestinationReplyChannelsDto? ReplyChannels { get; set; } [JsonPropertyName("services")] - public List<DestinationServiceDto> Services; + public List<DestinationServiceDto>? Services { get; set; } [JsonPropertyName("signingPublicKey")] - public string SigningPublicKey; + public string? SigningPublicKey { get; set; } } diff --git a/Services/Models/v1/Destination/DestinationListDto.cs b/Services/Models/v1/Destination/DestinationListDto.cs index e90eeca4d167a56ccaa79eb1e516b9bfe077689c..ce9324b8a5b4ddbb6ad2928c66d8b4aef87e9a4e 100644 --- a/Services/Models/v1/Destination/DestinationListDto.cs +++ b/Services/Models/v1/Destination/DestinationListDto.cs @@ -4,17 +4,17 @@ namespace FitConnect.Services.Models.v1; public class DestinationListDto { [JsonPropertyName("count")] - public int Count; + public int Count{ get; set; } [JsonPropertyName("destinations")] - public List<PrivateDestinationDto> Destinations; + public List<PrivateDestinationDto>? Destinations{ get; set; } [JsonPropertyName("offset")] - public int Offset; + public int Offset{ get; set; } [JsonPropertyName("totalCount")] - public long TotalCount; + public long TotalCount{ get; set; } } diff --git a/Services/Models/v1/Destination/DestinationServiceDto.cs b/Services/Models/v1/Destination/DestinationServiceDto.cs index 9bb36958dc67c86c3d8d83405ede7a56c6b69052..bb79fda5abbf22b1c035c69b4e3190c1da7911d8 100644 --- a/Services/Models/v1/Destination/DestinationServiceDto.cs +++ b/Services/Models/v1/Destination/DestinationServiceDto.cs @@ -4,12 +4,12 @@ namespace FitConnect.Services.Models.v1; public class DestinationServiceDto { [JsonPropertyName("identifier")] - public string Identifier; + public string? Identifier{ get; set; } [JsonPropertyName("regions")] - public List<string> Regions; + public List<string>? Regions{ get; set; } [JsonPropertyName("submissionSchemas")] - public List<SubmissionSchemaDto> SubmissionSchemas; + public List<SubmissionSchemaDto>? SubmissionSchemas{ get; set; } } diff --git a/Services/Models/v1/Destination/PatchDestinationDto.cs b/Services/Models/v1/Destination/PatchDestinationDto.cs index 16986f770312ea3a038fb01696070ccae86dd666..844682f280a56f253df483099313fa8d50d80b46 100644 --- a/Services/Models/v1/Destination/PatchDestinationDto.cs +++ b/Services/Models/v1/Destination/PatchDestinationDto.cs @@ -4,28 +4,28 @@ namespace FitConnect.Services.Models.v1; public class PatchDestinationDto { [JsonPropertyName("callback")] - public CallbackDto Callback; + public CallbackDto? Callback{ get; set; } [JsonPropertyName("contactInformation")] - public ContactInformationDto ContactInformation; + public ContactInformationDto? ContactInformation{ get; set; } [JsonPropertyName("encryptionKid")] - public string EncryptionKid; + public string? EncryptionKid{ get; set; } [JsonPropertyName("metadataVersions")] - public List<string> metadataVersions; + public List<string>? metadataVersions{ get; set; } [JsonPropertyName("replyChannels")] - public DestinationReplyChannelsDto ReplyChannels; + public DestinationReplyChannelsDto? ReplyChannels{ get; set; } [JsonPropertyName("services")] - public List<DestinationServiceDto> Services; + public List<DestinationServiceDto>? Services{ get; set; } [JsonPropertyName("status")] - public string Status; + public string? Status{ get; set; } } diff --git a/Services/Models/v1/Destination/PrivateDestinationDto.cs b/Services/Models/v1/Destination/PrivateDestinationDto.cs index 28f5170880bd65749cca99ce9b3f368eae0f7948..e2dcc4e4cf1fd7d088fb9c00ee69f84dbee74b21 100644 --- a/Services/Models/v1/Destination/PrivateDestinationDto.cs +++ b/Services/Models/v1/Destination/PrivateDestinationDto.cs @@ -4,32 +4,32 @@ namespace FitConnect.Services.Models.v1; public class PrivateDestinationDto { [JsonPropertyName("callback")] - public CallbackDto Callback; + public CallbackDto? Callback{ get; set; } [JsonPropertyName("contactInformation")] - public ContactInformationDto ContactInformation; + public ContactInformationDto? ContactInformation{ get; set; } [JsonPropertyName("destinationId")] - public string DestinationId; + public string? DestinationId{ get; set; } [JsonPropertyName("encryptionKid")] - public string EncryptionKid; + public string? EncryptionKid{ get; set; } [JsonPropertyName("metadataVersions")] - public List<string> MetadataVersions; + public List<string>? MetadataVersions{ get; set; } [JsonPropertyName("replyChannels")] - public DestinationReplyChannelsDto ReplyChannels; + public DestinationReplyChannelsDto? ReplyChannels{ get; set; } [JsonPropertyName("services")] - public List<DestinationServiceDto> Services; + public List<DestinationServiceDto>? Services{ get; set; } [JsonPropertyName("status")] - public string Status; + public string? Status{ get; set; } } diff --git a/Services/Models/v1/Destination/SubmissionSchemaDto.cs b/Services/Models/v1/Destination/SubmissionSchemaDto.cs index 39a509d7584614d9265174b2cadafd5786b57b0c..e44d9029ab6953901fd4bd6daba0d34b47c0a16e 100644 --- a/Services/Models/v1/Destination/SubmissionSchemaDto.cs +++ b/Services/Models/v1/Destination/SubmissionSchemaDto.cs @@ -8,5 +8,5 @@ public class SubmissionSchemaDto { public int mimeType; [JsonPropertyName("schemaUri")] - public string schemaUri; + public string? SchemaUri{ get; set; } } diff --git a/Services/Models/v1/Destination/UpdateDestinationDto.cs b/Services/Models/v1/Destination/UpdateDestinationDto.cs index ab9c5677043bd20e565daebd7dfc6dceb9dc5353..8a9d849316766e4fbe14be86e93e3ed89e0db2cb 100644 --- a/Services/Models/v1/Destination/UpdateDestinationDto.cs +++ b/Services/Models/v1/Destination/UpdateDestinationDto.cs @@ -4,28 +4,28 @@ namespace FitConnect.Services.Models.v1; public class UpdateDestinationDto { [JsonPropertyName("callback")] - public CallbackDto Callback; + public CallbackDto? Callback{ get; set; } [JsonPropertyName("contactInformation")] - public ContactInformationDto ContactInformation; + public ContactInformationDto? ContactInformation{ get; set; } [JsonPropertyName("encryptionKid")] - public string EncryptionKid; + public string? EncryptionKid{ get; set; } [JsonPropertyName("metadataVersions")] - public List<string> metadataVersions; + public List<string>? metadataVersions{ get; set; } [JsonPropertyName("replyChannels")] - public DestinationReplyChannelsDto ReplyChannels; + public DestinationReplyChannelsDto? ReplyChannels{ get; set; } [JsonPropertyName("services")] - public List<DestinationServiceDto> Services; + public List<DestinationServiceDto>? Services{ get; set; } [JsonPropertyName("status")] - public string Status; + public string? Status{ get; set; } } diff --git a/Services/Models/v1/Submission/SubmissionCreatedDto.cs b/Services/Models/v1/Submission/SubmissionCreatedDto.cs index 4b4ac1832848067c0bc514236fe8f525b5954d81..91da9d8639c949b7762ec2670f520a92c0f11bd4 100644 --- a/Services/Models/v1/Submission/SubmissionCreatedDto.cs +++ b/Services/Models/v1/Submission/SubmissionCreatedDto.cs @@ -4,11 +4,11 @@ namespace FitConnect.Services.Models.v1; public class SubmissionCreatedDto { [JsonPropertyName("destinationId")] - public string DestinationId { get; set; } + public string? DestinationId { get; set; } [JsonPropertyName("submissionId")] - public string SubmissionId { get; set; } + public string? SubmissionId { get; set; } [JsonPropertyName("caseId")] - public string CaseId { get; set; } + public string? CaseId { get; set; } } diff --git a/Services/Models/v1/Submission/SubmissionDto.cs b/Services/Models/v1/Submission/SubmissionDto.cs index 9430bbc53c44b03f499380f6a2d3418b4a4511f1..05a079924eccff1989c3d7230ca5cfa4643caa4b 100644 --- a/Services/Models/v1/Submission/SubmissionDto.cs +++ b/Services/Models/v1/Submission/SubmissionDto.cs @@ -4,32 +4,32 @@ namespace FitConnect.Services.Models.v1; public class SubmissionDto { [JsonPropertyName("attachments")] - public List<string> Attachments; + public List<string>? Attachments{ get; set; } [JsonPropertyName("callback")] - public CallbackDto Callback; + public CallbackDto? Callback{ get; set; } [JsonPropertyName("caseId")] - public string CaseId; + public string? CaseId{ get; set; } [JsonPropertyName("destinationId")] - public string DestinationId; + public string? DestinationId{ get; set; } [JsonPropertyName("encryptedData")] - public string EncryptedData; + public string? EncryptedData{ get; set; } [JsonPropertyName("encryptedMetadata")] - public string EncryptedMetadata; + public string? EncryptedMetadata{ get; set; } [JsonPropertyName("serviceType")] - public ServiceTypeDto ServiceType; + public ServiceTypeDto? ServiceType{ get; set; } [JsonPropertyName("submissionId")] - public string SubmissionId; + public string? SubmissionId{ get; set; } } diff --git a/Services/Models/v1/Submission/SubmissionForPickupDto.cs b/Services/Models/v1/Submission/SubmissionForPickupDto.cs index 433b898368dee5fb2f6e7970ec7b18b3cad36c64..d4fdfba358e6037553b0aa0d8b8807f6647f3d25 100644 --- a/Services/Models/v1/Submission/SubmissionForPickupDto.cs +++ b/Services/Models/v1/Submission/SubmissionForPickupDto.cs @@ -4,11 +4,11 @@ namespace FitConnect.Services.Models.v1; public class SubmissionForPickupDto { [JsonPropertyName("caseId")] - public string CaseId; + public string? CaseId{ get; set; } [JsonPropertyName("destinationId")] - public string DestinationId; + public string? DestinationId{ get; set; } [JsonPropertyName("submissionId")] - public string SubmissionId; + public string? SubmissionId{ get; set; } } diff --git a/Services/Models/v1/Submission/SubmissionReducedDto.cs b/Services/Models/v1/Submission/SubmissionReducedDto.cs index 768d3632d98983bc4407ab8c8b2656ff956f2d9e..e01f28a8f4be6f8ef8fbf4e53cbbb17084644305 100644 --- a/Services/Models/v1/Submission/SubmissionReducedDto.cs +++ b/Services/Models/v1/Submission/SubmissionReducedDto.cs @@ -4,24 +4,24 @@ namespace FitConnect.Services.Models.v1; public class SubmissionReducedDto { [JsonPropertyName("serviceType")] - private ServiceTypeDto _serviceTypeDto; + private ServiceTypeDto? ServiceTypeDto { get; set; } [JsonPropertyName("attachments")] - private List<string> Attachments; + private List<string>? Attachments { get; set; } [JsonPropertyName("callback")] - private CallbackDto Callback; + private CallbackDto? Callback { get; set; } [JsonPropertyName("caseId")] - private string CaseId; + private string? CaseId { get; set; } [JsonPropertyName("destinationId")] - private string DestinationId; + private string? DestinationId { get; set; } [JsonPropertyName("submissionId")] - private string SubmissionId; + private string? SubmissionId { get; set; } } diff --git a/Services/Models/v1/Submission/SubmissionsForPickupDto.cs b/Services/Models/v1/Submission/SubmissionsForPickupDto.cs index 564c2d8a48bcc53f74847769654d6f9e75e3f319..cd7850442df76d0c7995f0b56f34b6295acf3948 100644 --- a/Services/Models/v1/Submission/SubmissionsForPickupDto.cs +++ b/Services/Models/v1/Submission/SubmissionsForPickupDto.cs @@ -4,14 +4,14 @@ namespace FitConnect.Services.Models.v1; public class SubmissionsForPickupDto { [JsonPropertyName("count")] - public int Count; + public int Count { get; set; } [JsonPropertyName("offset")] - public int Offset; + public int Offset { get; set; } [JsonPropertyName("submissions")] - public List<SubmissionForPickupDto> Submissions; + public List<SubmissionForPickupDto>? Submissions { get; set; } [JsonPropertyName("totalCount")] - public long TotalCount; + public long TotalCount { get; set; } } diff --git a/Services/Models/v1/Submission/SubmitSubmissionDto.cs b/Services/Models/v1/Submission/SubmitSubmissionDto.cs index 14271f2ea3b7b31a28783f4e6ea541dde919cbb7..061aa637ca35b766e0ed9f6f9c318b2a5148d84d 100644 --- a/Services/Models/v1/Submission/SubmitSubmissionDto.cs +++ b/Services/Models/v1/Submission/SubmitSubmissionDto.cs @@ -4,8 +4,8 @@ namespace FitConnect.Services.Models.v1; public class SubmitSubmissionDto { [JsonPropertyName("encryptedData")] - public string? EncryptedData; + public string? EncryptedData{ get; set; } [JsonPropertyName("encryptedMetadata")] - public string EncryptedMetadata; + public string? EncryptedMetadata{ get; set; } }