-
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.
- Loading branch information
Showing
7 changed files
with
70 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,28 @@ | ||
package nl.ictu; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
import java.util.Date; | ||
|
||
|
||
@Getter | ||
@Setter | ||
public final class Token { | ||
|
||
@Getter | ||
@Setter | ||
public final class Identifier { | ||
private String type; | ||
private String value; | ||
} | ||
|
||
private final String version = "v1"; | ||
private String recipientOIN; | ||
private String identifierType; | ||
private String identifierValue; | ||
private Identifier identifier = new Identifier(); | ||
|
||
@JsonFormat | ||
(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy hh:mm:ss") | ||
private Date creationDate; | ||
} |
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 was deleted.
Oops, something went wrong.
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,12 @@ | ||
package nl.ictu.service; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import nl.ictu.Token; | ||
|
||
import java.io.IOException; | ||
|
||
public interface TokenConverter { | ||
String encode(Token token) throws IOException; | ||
|
||
Token decode(String encodedToken) throws JsonProcessingException; | ||
} |
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,30 @@ | ||
package nl.ictu.service; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import lombok.RequiredArgsConstructor; | ||
import nl.ictu.Token; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.io.IOException; | ||
import java.io.StringWriter; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class TokenConverterImpl implements TokenConverter { | ||
|
||
private final ObjectMapper objectMapper; | ||
|
||
@Override | ||
public String encode(final Token token) throws IOException { | ||
final StringWriter stringWriter = new StringWriter(); | ||
objectMapper.writeValue(stringWriter, token); | ||
return stringWriter.toString(); | ||
} | ||
|
||
@Override | ||
public Token decode(final String encodedToken) throws JsonProcessingException { | ||
return objectMapper.readValue(encodedToken, Token.class); | ||
} | ||
|
||
} |
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