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
cdd902e4
Commit
cdd902e4
authored
2 years ago
by
Klaus Fischer
Browse files
Options
Downloads
Patches
Plain Diff
Implemented 4.3, 4.4
4 is finished
parent
d9af24d3
No related branches found
No related tags found
1 merge request
!24
AutoReject planning#594
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
FitConnect/Services/Models/v1/Api/Problems.cs
+6
-1
6 additions, 1 deletion
FitConnect/Services/Models/v1/Api/Problems.cs
FitConnect/Subscriber.cs
+43
-12
43 additions, 12 deletions
FitConnect/Subscriber.cs
with
49 additions
and
13 deletions
FitConnect/Services/Models/v1/Api/Problems.cs
+
6
−
1
View file @
cdd902e4
...
...
@@ -23,6 +23,9 @@ public class Problems {
public
const
string
TitleMissingData
=
"Fachdatensatz fehlt"
;
public
const
string
DetailMissingData
=
"Der Fachdatensatz fehlt."
;
public
const
string
TitleHashMismatch
=
"Prüfsumme stimmt nicht"
;
public
const
string
DetailDataHashMismatch
=
"Die Prüfsumme des Fachdatensatzes stimmt nicht."
;
public
const
string
TitleMissingSchema
=
"Schema-Referenz fehlt"
;
public
const
string
DetailMissingSchema
=
"Die Schema-Referenz fehlt im Metadatensatz."
;
...
...
@@ -33,7 +36,9 @@ public class Problems {
public
const
string
DetailUnsupportedService
=
"Die angegebene Verwaltungsleistung wird nicht unterstützt."
;
public
const
string
TitleSyntaxViolation
=
"Syntax-Fehler"
;
public
const
string
DetailSyntaxViolation
=
"Der Metadatensatz ist kein valides JSON."
;
public
const
string
DetailSyntaxViolationMetadata
=
"Der Metadatensatz ist kein valides JSON."
;
public
const
string
DetailSyntaxViolationDataJson
=
"Der Fachdatensatz ist kein valides JSON."
;
public
const
string
DetailSyntaxViolationDataXml
=
"Der Fachdatensatz ist kein valides XML."
;
public
const
string
TitleServiceMismatch
=
"Verwaltungsleistung stimmt nicht überein"
;
public
const
string
DetailServiceMismatch
=
"Die Verwaltungsleistung in Submission und Metadatensatz stimmen nicht überein."
;
...
...
This diff is collapsed.
Click to expand it.
FitConnect/Subscriber.cs
+
43
−
12
View file @
cdd902e4
using
System.Security
;
using
System.Xml
;
using
Autofac
;
using
FitConnect.Encryption
;
using
FitConnect.Interfaces.Subscriber
;
...
...
@@ -134,7 +135,7 @@ public class Subscriber : FitConnectClient,
// SuccessCriteria:3.3
if
(
submission
.
Metadata
==
null
)
{
var
problem
=
new
Problems
(
Problems
.
ProblemTypeEnum
.
SyntaxViolation
,
Problems
.
DetailSyntaxViolation
);
Problems
.
DetailSyntaxViolation
Metadata
);
RejectSubmission
(
submission
,
problem
);
throw
new
SecurityEventException
(
problem
);
}
...
...
@@ -167,6 +168,8 @@ public class Subscriber : FitConnectClient,
try
{
var
(
dataString
,
_
,
dataHash
)
=
Encryption
.
Decrypt
(
submission
.
EncryptedData
);
submission
.
Data
=
dataString
;
// SuccessCriteria: 4.3 (Wrong problem?!)
VerifyDataHash
(
submission
,
dataString
);
}
catch
(
Exception
e
)
{
...
...
@@ -189,7 +192,6 @@ public class Subscriber : FitConnectClient,
// SuccessCriteria:3.11
// TODO No test for data schema implemented, missing schema url
var
dataSchema
=
GetSchemaUrlFromJson
(
submission
.
Data
);
if
(
dataSchema
==
null
)
{
Logger
?.
LogWarning
(
"No data schema found for submission {SubmissionId}"
,
submissionId
);
...
...
@@ -205,7 +207,35 @@ public class Subscriber : FitConnectClient,
}
// SuccessCriteria:4.5
CheckDataSchema
(
dataSchema
,
submission
);
if
(
submission
.
DataMimeType
==
"application/json"
)
{
if
(
JsonConvert
.
DeserializeObject
(
submission
.
Data
)
==
null
)
{
var
problem
=
new
Problems
(
Problems
.
ProblemTypeEnum
.
SyntaxViolation
,
Problems
.
TitleSyntaxViolation
,
Problems
.
DetailSyntaxViolationDataJson
,
problemInstance
:
Problems
.
ProblemInstanceEnum
.
Data
);
RejectSubmission
(
submission
,
problem
);
throw
new
SecurityEventException
(
problem
);
}
CheckDataSchema
(
dataSchema
,
submission
);
}
if
(
submission
.
DataMimeType
==
"application/xml"
)
{
try
{
var
doc
=
new
XmlDocument
();
doc
.
LoadXml
(
submission
.
Data
);
}
catch
(
Exception
e
)
{
var
problem
=
new
Problems
(
Problems
.
ProblemTypeEnum
.
SyntaxViolation
,
Problems
.
TitleSyntaxViolation
,
Problems
.
DetailSyntaxViolationDataXml
,
problemInstance
:
Problems
.
ProblemInstanceEnum
.
Data
);
RejectSubmission
(
submission
,
problem
);
throw
new
SecurityEventException
(
problem
,
e
);
}
}
}
...
...
@@ -250,10 +280,10 @@ public class Subscriber : FitConnectClient,
submission
.
Metadata
?.
ContentStructure
.
Data
.
Hash
.
Content
,
FitEncryption
.
CalculateHash
(
dataString
));
// SuccessCriteria: 4.
1
var
problem
=
new
Problems
(
Problems
.
ProblemTypeEnum
.
IncorrectAuthenticationTag
,
Problems
.
Title
AuthenticationTagInvalid
,
detail
:
Problems
.
Detail
AuthenticationTagDataInvalid
,
Problems
.
ProblemInstanceEnum
.
Data
);
// SuccessCriteria: 4.
3
var
problem
=
new
Problems
(
Problems
.
ProblemTypeEnum
.
HashMismatch
,
Problems
.
Title
HashMismatch
,
detail
:
Problems
.
Detail
DataHashMismatch
,
Problems
.
ProblemInstanceEnum
.
Data
);
RejectSubmission
(
submission
,
Problems
.
EncryptionIssue
);
throw
new
SecurityEventException
(
problem
);
}
...
...
@@ -307,15 +337,16 @@ public class Subscriber : FitConnectClient,
metadataSignature
=
authenticationTag
?.
metadata
?.
ToString
()
??
""
;
if
(
submission
.
EncryptedData
?.
Split
(
'.'
).
Last
()
!=
dataSignature
)
{
RejectSubmission
(
submission
,
new
Problems
(
Problems
.
ProblemTypeEnum
.
IncorrectAuthenticationTag
,
Problems
.
DetailAuthenticationTagMissing
));
throw
new
AggregateException
(
"Data signature mismatch"
);
// SuccessCriteria: 4.1
var
problem
=
new
Problems
(
Problems
.
ProblemTypeEnum
.
IncorrectAuthenticationTag
,
Problems
.
DetailDataHashMismatch
);
RejectSubmission
(
submission
,
problem
);
throw
new
SecurityEventException
(
problem
);
}
if
(
submission
.
EncryptedMetadata
?.
Split
(
'.'
).
Last
()
!=
metadataSignature
)
{
RejectSubmission
(
submission
,
Problems
.
IncorrectAuthenticationTag
);
throw
new
AggregateException
(
"Metadata signature mismatch"
);
throw
new
SecurityEventException
(
Problems
.
IncorrectAuthenticationTag
);
}
return
submitEvent
;
...
...
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