summaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/EndpointCertificateMetadata.java
blob: 4d2cafa3e485441cc4b187d5572b37c26026a80e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package com.yahoo.vespa.hosted.controller.api.integration.certificates;

import java.util.List;
import java.util.Objects;
import java.util.Optional;

/**
 * This class is used for metadata about an application's endpoint certificate on the controller.
 * <p>
 * It has more properties than com.yahoo.config.model.api.EndpointCertificateMetadata.
 *
 * @author andreer
 */
public class EndpointCertificateMetadata {

    private final String keyName;
    private final String certName;
    private final int version;
    private final long lastRequested;
    private final String request_id;
    private final List<String> requestedDnsSans;
    private final String issuer;
    private final Optional<Long> expiry;
    private final Optional<Long> lastRefreshed;

    public EndpointCertificateMetadata(String keyName, String certName, int version, long lastRequested, String request_id, List<String> requestedDnsSans, String issuer, Optional<Long> expiry, Optional<Long> lastRefreshed) {
        this.keyName = keyName;
        this.certName = certName;
        this.version = version;
        this.lastRequested = lastRequested;
        this.request_id = request_id;
        this.requestedDnsSans = requestedDnsSans;
        this.issuer = issuer;
        this.expiry = expiry;
        this.lastRefreshed = lastRefreshed;
    }

    public String keyName() {
        return keyName;
    }

    public String certName() {
        return certName;
    }

    public int version() {
        return version;
    }

    public long lastRequested() {
        return lastRequested;
    }

    public String request_id() {
        return request_id;
    }

    public List<String> requestedDnsSans() {
        return requestedDnsSans;
    }

    public String issuer() {
        return issuer;
    }

    public Optional<Long> expiry() {
        return expiry;
    }

    public Optional<Long> lastRefreshed() {
        return lastRefreshed;
    }

    public EndpointCertificateMetadata withVersion(int version) {
        return new EndpointCertificateMetadata(
                this.keyName,
                this.certName,
                version,
                this.lastRequested,
                this.request_id,
                this.requestedDnsSans,
                this.issuer,
                this.expiry,
                this.lastRefreshed);
    }

    public EndpointCertificateMetadata withLastRequested(long lastRequested) {
        return new EndpointCertificateMetadata(
                this.keyName,
                this.certName,
                this.version,
                lastRequested,
                this.request_id,
                this.requestedDnsSans,
                this.issuer,
                this.expiry,
                this.lastRefreshed);
    }

    public EndpointCertificateMetadata withLastRefreshed(long lastRefreshed) {
        return new EndpointCertificateMetadata(
                this.keyName,
                this.certName,
                this.version,
                this.lastRequested,
                this.request_id,
                this.requestedDnsSans,
                this.issuer,
                this.expiry,
                Optional.of(lastRefreshed));
    }

    @Override
    public String toString() {
        return "EndpointCertificateMetadata{" +
                "keyName='" + keyName + '\'' +
                ", certName='" + certName + '\'' +
                ", version=" + version +
                ", lastRequested=" + lastRequested +
                ", request_id=" + request_id +
                ", requestedDnsSans=" + requestedDnsSans +
                ", issuer=" + issuer +
                ", expiry=" + expiry +
                ", lastRefreshed=" + lastRefreshed +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        EndpointCertificateMetadata that = (EndpointCertificateMetadata) o;
        return version == that.version &&
                lastRequested == that.lastRequested &&
                keyName.equals(that.keyName) &&
                certName.equals(that.certName) &&
                request_id.equals(that.request_id) &&
                requestedDnsSans.equals(that.requestedDnsSans) &&
                issuer.equals(that.issuer) &&
                expiry.equals(that.expiry) &&
                lastRefreshed.equals(that.lastRefreshed);
    }

    @Override
    public int hashCode() {
        return Objects.hash(keyName, certName, version, lastRequested, request_id, requestedDnsSans, issuer, expiry, lastRefreshed);
    }
}