1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.linecorp.centraldogma.server.internal.api.sysadmin;
17
18 import static com.google.common.base.MoreObjects.toStringHelper;
19 import static com.google.common.base.Preconditions.checkArgument;
20 import static java.time.format.DateTimeFormatter.ISO_INSTANT;
21 import static java.util.Objects.requireNonNull;
22
23 import java.time.Instant;
24
25 import com.fasterxml.jackson.annotation.JsonCreator;
26 import com.fasterxml.jackson.annotation.JsonProperty;
27
28
29
30
31
32 public final class SessionMasterKeyDto {
33
34 private final int version;
35 private final String kekId;
36 private final String creation;
37
38
39
40
41 @JsonCreator
42 public SessionMasterKeyDto(@JsonProperty("version") int version,
43 @JsonProperty("kekId") String kekId,
44 @JsonProperty("creation") Instant creation) {
45 checkArgument(version > 0, "version must be positive: %s", version);
46 this.version = version;
47 this.kekId = requireNonNull(kekId, "kekId");
48 this.creation = ISO_INSTANT.format(requireNonNull(creation, "creation"));
49 }
50
51
52
53
54 @JsonProperty
55 public int version() {
56 return version;
57 }
58
59
60
61
62 @JsonProperty
63 public String kekId() {
64 return kekId;
65 }
66
67
68
69
70 @JsonProperty
71 public String creation() {
72 return creation;
73 }
74
75 @Override
76 public String toString() {
77 return toStringHelper(this).add("version", version)
78 .add("kekId", kekId)
79 .add("creation", creation)
80 .toString();
81 }
82 }