Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FIT-Connect-SDK - .NET
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FIT-Connect
FIT-Connect-SDK - .NET
Commits
d70ff16e
Commit
d70ff16e
authored
1 year ago
by
Klaus Fischer
Browse files
Options
Downloads
Patches
Plain Diff
feature: throwing exception on missing content type
parent
cec7e836
No related branches found
No related tags found
1 merge request
!108
Bug/1244 cty
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
FitConnect/Encryption/JoseEncryptor.cs
+7
-0
7 additions, 0 deletions
FitConnect/Encryption/JoseEncryptor.cs
FitConnect/FitConnectClient.cs
+1
-1
1 addition, 1 deletion
FitConnect/FitConnectClient.cs
Tests/E2ETest/StraightForwardTest.cs
+3
-3
3 additions, 3 deletions
Tests/E2ETest/StraightForwardTest.cs
with
11 additions
and
4 deletions
FitConnect/Encryption/JoseEncryptor.cs
+
7
−
0
View file @
d70ff16e
using
System.Net.Mime
;
using
FitConnect.Exceptions
;
using
Jose
;
using
Microsoft.IdentityModel.Tokens
;
// ReSharper disable RedundantExplicitArrayCreation
...
...
@@ -30,6 +32,8 @@ public class JoseEncryptor : IEncryptor {
}
public
string
Encrypt
(
string
key
,
string
plain
,
string
contentType
)
{
if
(
contentType
.
IsNullOrEmpty
())
throw
new
FitConnectSenderException
(
"Content Type is not set"
);
try
{
var
jwk
=
Jwk
.
FromJson
(
key
,
new
JsonMapper
());
if
(!
jwk
.
KeyOps
.
Contains
(
EncryptionSettings
.
KeyOpsWrapKey
))
...
...
@@ -51,6 +55,9 @@ public class JoseEncryptor : IEncryptor {
}
public
string
Encrypt
(
string
key
,
byte
[]
plain
,
string
contentType
)
{
if
(
contentType
.
IsNullOrEmpty
())
throw
new
FitConnectSenderException
(
"Content Type is not set"
);
try
{
var
jwk
=
Jwk
.
FromJson
(
key
,
new
JsonMapper
());
return
JWE
.
EncryptBytes
(
plain
,
...
...
This diff is collapsed.
Click to expand it.
FitConnect/FitConnectClient.cs
+
1
−
1
View file @
d70ff16e
...
...
@@ -242,7 +242,7 @@ public abstract class FitConnectClient: IFitConnectClient {
/// <param name="attachment"></param>
/// <returns></returns>
public
KeyValuePair
<
Guid
,
string
>
Encrypt
(
string
publicKey
,
Attachment
attachment
)
{
var
content
=
Encryption
.
Encrypt
(
attachment
.
GetBytes
(),
publicKey
);
var
content
=
Encryption
.
Encrypt
(
attachment
.
GetBytes
(),
publicKey
,
attachment
.
MimeType
);
return
new
KeyValuePair
<
Guid
,
string
>(
attachment
.
Id
,
content
);
}
...
...
This diff is collapsed.
Click to expand it.
Tests/E2ETest/StraightForwardTest.cs
+
3
−
3
View file @
d70ff16e
...
...
@@ -31,11 +31,11 @@ public class StraightForwardTest : EndToEndTestBase {
.
SetServiceType
(
Settings
.
ServiceIdentifier
,
"Straight forward test"
)
.
SetJsonData
(
JSON_DATA
,
new
Uri
(
JSON_SCHEMA_URI
))
.
AddAttachments
(
Attachment
.
FromPath
(
"Test.pdf"
,
"a
pplication
/p
df
"
,
description
:
"Attachment #1"
,
Attachment
.
FromPath
(
"Test.pdf"
,
MediaTypeNames
.
A
pplication
.
P
df
,
description
:
"Attachment #1"
,
fileName
:
"Test.pdf"
),
Attachment
.
FromPath
(
"Test.pdf"
,
"a
pplication
/p
df
"
,
description
:
"Attachment #2"
,
Attachment
.
FromPath
(
"Test.pdf"
,
MediaTypeNames
.
A
pplication
.
P
df
,
description
:
"Attachment #2"
,
fileName
:
"Test.pdf"
))
.
AddAttachment
(
Attachment
.
FromPath
(
"Test.pdf"
,
"a
pplication
/p
df
"
,
.
AddAttachment
(
Attachment
.
FromPath
(
"Test.pdf"
,
MediaTypeNames
.
A
pplication
.
P
df
,
description
:
"Attachment #3"
,
fileName
:
"Test.pdf"
))
.
AddAttachment
(
Attachment
.
FromByteArray
(
Encoding
.
UTF8
.
GetBytes
(
"{\"message\":\"Hello World\"}"
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment