Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
FIT-Connect-SDK - Java
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 - Java
Commits
14e407ee
Commit
14e407ee
authored
3 months ago
by
Martin Vogel
Browse files
Options
Downloads
Patches
Plain Diff
refactor: fix reply channel validation (
planning#2499
)
parent
96da35d1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!436
planning#2267: Destination API Client
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
client/src/main/java/dev/fitko/fitconnect/core/validation/DefaultValidationService.java
+13
-22
13 additions, 22 deletions
.../fitconnect/core/validation/DefaultValidationService.java
with
13 additions
and
22 deletions
client/src/main/java/dev/fitko/fitconnect/core/validation/DefaultValidationService.java
+
13
−
22
View file @
14e407ee
...
...
@@ -16,6 +16,7 @@ import com.nimbusds.jose.jwk.RSAKey;
import
dev.fitko.fitconnect.api.config.ApplicationConfig
;
import
dev.fitko.fitconnect.api.domain.model.attachment.Fragment
;
import
dev.fitko.fitconnect.api.domain.model.destination.Destination
;
import
dev.fitko.fitconnect.api.domain.model.destination.DestinationReplyChannels
;
import
dev.fitko.fitconnect.api.domain.model.destination.DestinationService
;
import
dev.fitko.fitconnect.api.domain.model.event.EventClaimFields
;
import
dev.fitko.fitconnect.api.domain.model.event.authtags.AuthenticationTags
;
...
...
@@ -76,7 +77,6 @@ import java.time.Instant;
import
java.time.ZoneId
;
import
java.time.ZonedDateTime
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
...
...
@@ -86,7 +86,6 @@ import java.util.Set;
import
java.util.UUID
;
import
java.util.function.Predicate
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
static
dev
.
fitko
.
fitconnect
.
core
.
crypto
.
constants
.
CryptoConstants
.
HASH_OF_ZERO_BYTES
;
import
static
dev
.
fitko
.
fitconnect
.
core
.
utils
.
EventLogUtil
.
getAuthenticationTagFromEncryptedData
;
...
...
@@ -418,7 +417,7 @@ public class DefaultValidationService implements ValidationService {
// https://docs.fitko.de/fit-connect/docs/receiving/verification/#r%C3%BCckkanal
if
(
metadata
.
getReplyChannel
()
!=
null
&&
serviceType
!=
null
)
{
final
Optional
<
ReplyChannel
>
matchingServiceReplyChannel
=
destination
.
getServices
().
stream
()
final
Optional
<
Destination
ReplyChannel
s
>
matchingServiceReplyChannel
=
destination
.
getServices
().
stream
()
.
filter
(
service
->
service
.
getIdentifier
().
equals
(
serviceType
.
getIdentifier
()))
.
filter
(
service
->
service
.
getSubmissionSchemas
().
stream
().
anyMatch
(
schema
->
schema
.
equals
(
submissionSchema
)))
.
map
(
DestinationService:
:
getReplyChannels
)
...
...
@@ -440,31 +439,23 @@ public class DefaultValidationService implements ValidationService {
.
stream
()
.
map
(
ApiAttachment:
:
getPurpose
)
.
noneMatch
(
purpose
->
purpose
.
equals
(
Purpose
.
DATA
));
return
noAttachmentWithDataPurpose
&&
!
data
.
getHash
().
getContent
().
equals
(
HASH_OF_ZERO_BYTES
);
}
private
Predicate
<
ReplyChannel
>
destinationAllowsSubmissionReplyChannel
(
final
ReplyChannel
submissionReplyChannel
)
{
return
replyChannel
->
{
final
var
destinationReplyChannelTypes
=
getNonNullReplyChannels
(
replyChannel
);
final
var
submissionReplyChannelTypes
=
getNonNullReplyChannels
(
submissionReplyChannel
);
return
new
HashSet
<>(
destinationReplyChannelTypes
).
containsAll
(
submissionReplyChannelTypes
);
private
Predicate
<
DestinationReplyChannels
>
destinationAllowsSubmissionReplyChannel
(
final
ReplyChannel
submissionReplyChannel
)
{
return
destinationReplyChannel
->
{
// build a comparison object because we have different types with different field declarations
DestinationReplyChannels
.
Builder
comparison
=
DestinationReplyChannels
.
builder
();
Optional
.
ofNullable
(
submissionReplyChannel
.
getEMail
()).
ifPresent
(
r
->
comparison
.
withEmail
(
r
.
getUsePgp
()));
Optional
.
ofNullable
(
submissionReplyChannel
.
getDeMail
()).
ifPresent
(
r
->
comparison
.
withDeMail
());
Optional
.
ofNullable
(
submissionReplyChannel
.
getFink
()).
ifPresent
(
r
->
comparison
.
withFink
());
Optional
.
ofNullable
(
submissionReplyChannel
.
getElster
()).
ifPresent
(
r
->
comparison
.
withElster
());
Optional
.
ofNullable
(
submissionReplyChannel
.
getIdBundDeMailbox
()).
ifPresent
(
r
->
comparison
.
withIdBundDeMailbox
(
r
.
getMailboxUuid
()
!=
null
));
Optional
.
ofNullable
(
submissionReplyChannel
.
getFitConnect
()).
ifPresent
(
r
->
comparison
.
withFitConnect
(
r
.
getProcessStandards
()));
return
destinationReplyChannel
.
equals
(
comparison
.
build
());
};
}
private
List
<
Class
<?>>
getNonNullReplyChannels
(
final
ReplyChannel
replyChannel
)
{
return
Stream
.
of
(
replyChannel
.
getEMail
(),
replyChannel
.
getDeMail
(),
replyChannel
.
getFink
(),
replyChannel
.
getElster
(),
replyChannel
.
getFitConnect
(),
replyChannel
.
getIdBundDeMailbox
())
.
filter
(
Objects:
:
nonNull
)
// Getting the type is sufficient. We do not want an actual content comparison of objects ,
// since the destinations reply channel content will be null even if they are set.
.
map
(
Object:
:
getClass
).
collect
(
Collectors
.
toList
());
}
private
static
boolean
matchingDestinationAndSubmissionSchema
(
final
Destination
destination
,
final
URI
submissionDataSchemaUri
)
{
return
destination
.
getServices
().
stream
()
.
flatMap
(
service
->
service
.
getSubmissionSchemas
().
stream
())
...
...
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