This repository has been archived by the owner on Sep 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from admin-ch/feature/timestamp-validation
explicit http status code for invalid timestamp (signaturePayload)
- Loading branch information
Showing
5 changed files
with
87 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...ag/covidcertificate/backend/delivery/ws/security/exception/InvalidTimestampException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package ch.admin.bag.covidcertificate.backend.delivery.ws.security.exception; | ||
|
||
import java.time.Duration; | ||
import java.time.Instant; | ||
|
||
public class InvalidTimestampException extends Exception { | ||
private final Instant acceptedFrom; | ||
private final Instant acceptedTo; | ||
private final Instant actual; | ||
|
||
public InvalidTimestampException(Instant now, Duration halfWindow, Instant timestamp) { | ||
this.acceptedFrom = now.minus(halfWindow); | ||
this.acceptedTo = now.plus(halfWindow); | ||
this.actual = timestamp; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "InvalidTimestampException{" | ||
+ "acceptedFrom=" | ||
+ acceptedFrom | ||
+ ", acceptedTo=" | ||
+ acceptedTo | ||
+ ", actual=" | ||
+ actual | ||
+ '}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters