Skip to content

Commit

Permalink
use LocalDateTime
Browse files Browse the repository at this point in the history
  • Loading branch information
bhuism committed Nov 28, 2024
1 parent 741a2fe commit bb0aee1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
7 changes: 2 additions & 5 deletions src/main/java/nl/ictu/Token.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package nl.ictu;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.time.LocalDateTime;


@Getter
Expand All @@ -15,8 +14,6 @@ public final class Token {
private String version = "v1";
private String bsn;
private String recipientOIN;
private LocalDateTime creationDate;

@JsonFormat
(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy hh:mm:ss")
private Date creationDate;
}
8 changes: 7 additions & 1 deletion src/main/java/nl/ictu/controller/v1/ExchangeToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import nl.ictu.pseudoniemenservice.generated.server.model.WsIdentifier;
import nl.ictu.service.Cryptographer;
import nl.ictu.service.TokenConverter;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -28,6 +30,8 @@ public final class ExchangeToken implements ExchangeTokenApi, VersionOneControll

private final ObjectMapper objectMapper;

private final Environment environment;

@Override
@SneakyThrows
public ResponseEntity<WsExchangeTokenForIdentifier200Response> exchangeTokenForIdentifier(final String callerOIN, final WsExchangeTokenForIdentifierRequest wsExchangeTokenForIdentifierRequest) {
Expand All @@ -36,7 +40,9 @@ public ResponseEntity<WsExchangeTokenForIdentifier200Response> exchangeTokenForI

final Token token = tokenConverter.decode(encodedToken);

//log.info("Received token: {}", objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(token));
if (environment.acceptsProfiles(Profiles.of("test"))) {
log.info("Received token: {}", objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(token));
}

if (!callerOIN.equals(token.getRecipientOIN())) {
throw new RuntimeException("Sink OIN not the same");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/nl/ictu/controller/v1/GetToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.time.LocalDateTime;

@RestController
@RequiredArgsConstructor
Expand All @@ -32,7 +32,7 @@ public ResponseEntity<WsGetToken200Response> getToken(final String callerOIN, fi

final Token token = new Token();

token.setCreationDate(new Date(System.currentTimeMillis()));
token.setCreationDate(LocalDateTime.now());
token.setRecipientOIN(wsGetTokenRequest.getRecipientOIN());

if (wsGetTokenRequest.getIdentifier() != null) {
Expand Down

0 comments on commit bb0aee1

Please sign in to comment.