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
02030d1e
Commit
02030d1e
authored
2 years ago
by
Martin Vogel
Browse files
Options
Downloads
Patches
Plain Diff
chore: add call back validation javadoc and readme code example
parent
c12979fb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!103
chore: add call back validation javadoc and readme code example
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+15
-0
15 additions, 0 deletions
README.md
client/src/main/java/dev/fitko/fitconnect/client/SenderClient.java
+11
-2
11 additions, 2 deletions
...c/main/java/dev/fitko/fitconnect/client/SenderClient.java
with
26 additions
and
2 deletions
README.md
+
15
−
0
View file @
02030d1e
...
...
@@ -229,6 +229,21 @@ Current status for submission 43cf7163-5163-4bc8-865e-be96e271ecc3 => incomplete
<img
src=
"https://docs.fitko.de/fit-connect/assets/images/status-ebe91122f32321e22f094882a66c1139.svg"
>
### Validating callbacks
Usage
```
java
final
SenderClient
senderClient
=
ClientFactory
.
senderClient
(
config
);
final
ValidationResult
validationResult
=
senderClient
.
validateCallback
(
"hmac"
,
0L
,
"body"
,
"secret"
);
if
(
validationResult
.
hasError
()){
LOGGER
.
error
(
validationresult
.
getError
().
getMessage
());
}
```
## API Usage for Subscriber
### Retrieving submissions
...
...
This diff is collapsed.
Click to expand it.
client/src/main/java/dev/fitko/fitconnect/client/SenderClient.java
+
11
−
2
View file @
02030d1e
...
...
@@ -70,8 +70,17 @@ public class SenderClient {
return
sender
.
getLastedEvent
(
destinationId
,
caseId
,
submissionId
,
authenticationTags
);
}
public
ValidationResult
validateCallback
(
String
hmac
,
Long
timestamp
,
String
httpBody
,
String
callbackSecret
)
{
return
this
.
sender
.
validateCallback
(
hmac
,
timestamp
,
httpBody
,
callbackSecret
);
/**
* Checks if a received callback can be trusted by validating the provided request data.
*
* @param hmac authentication code provided by the callback
* @param timestamp timestamp provided by the callback
* @param httpBody HTTP body provided by the callback
* @param callbackSecret secret owned by the client, which is used to calculate the hmac
* @return {@code true} if hmac and timestamp provided by the callback meet the required conditions
*/
public
ValidationResult
validateCallback
(
final
String
hmac
,
final
Long
timestamp
,
final
String
httpBody
,
final
String
callbackSecret
)
{
return
sender
.
validateCallback
(
hmac
,
timestamp
,
httpBody
,
callbackSecret
);
}
/**
...
...
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