001package org.kuali.common.devops.jenkins.updates.model;
002
003import java.util.List;
004
005import org.kuali.common.core.build.ValidatingBuilder;
006import org.kuali.common.core.validate.annotation.IdiotProofImmutable;
007
008import com.fasterxml.jackson.annotation.JsonProperty;
009import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
010import com.google.common.collect.ImmutableList;
011
012@IdiotProofImmutable
013@JsonDeserialize(builder = JenkinsSignature.Builder.class)
014public final class JenkinsSignature {
015
016        private final String digest;
017        private final String signature;
018
019        @JsonProperty("correct_digest")
020        private final String correctDigest;
021
022        @JsonProperty("correct_signature")
023        private final String correctSignature;
024        private final ImmutableList<String> certificates;
025
026        private JenkinsSignature(Builder builder) {
027                this.digest = builder.digest;
028                this.signature = builder.signature;
029                this.correctDigest = builder.correctDigest;
030                this.correctSignature = builder.correctSignature;
031                this.certificates = ImmutableList.copyOf(builder.certificates);
032        }
033
034        public static Builder builder() {
035                return new Builder();
036        }
037
038        public static class Builder extends ValidatingBuilder<JenkinsSignature> {
039
040                private String digest;
041                private String signature;
042                @JsonProperty("correct_digest")
043                private String correctDigest;
044                @JsonProperty("correct_signature")
045                private String correctSignature;
046                private List<String> certificates;
047
048                public Builder withDigest(String digest) {
049                        this.digest = digest;
050                        return this;
051                }
052
053                public Builder withSignature(String signature) {
054                        this.signature = signature;
055                        return this;
056                }
057
058                public Builder withCorrectDigest(String correctDigest) {
059                        this.correctDigest = correctDigest;
060                        return this;
061                }
062
063                public Builder withCorrectSignature(String correctSignature) {
064                        this.correctSignature = correctSignature;
065                        return this;
066                }
067
068                public Builder withCertificates(ImmutableList<String> certificates) {
069                        this.certificates = certificates;
070                        return this;
071                }
072
073                @Override
074                public JenkinsSignature build() {
075                        return validate(new JenkinsSignature(this));
076                }
077        }
078
079        public String getDigest() {
080                return digest;
081        }
082
083        public String getSignature() {
084                return signature;
085        }
086
087        public String getCorrectDigest() {
088                return correctDigest;
089        }
090
091        public String getCorrectSignature() {
092                return correctSignature;
093        }
094
095        public List<String> getCertificates() {
096                return certificates;
097        }
098
099}