diff options
author | Bjørn Christian Seime <bjorncs@oath.com> | 2018-11-19 16:37:09 +0100 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@oath.com> | 2018-11-19 16:37:09 +0100 |
commit | aa8dfde70a0c045629d645f49c50a2963f8ff66a (patch) | |
tree | a259b9adeb95cdc1d72e4374080c361de6eebfc1 /security-utils | |
parent | 3139324bd3b831a153d0d0841634ff8d9f75bb5c (diff) |
Add data model for AuthorizedPeers
Diffstat (limited to 'security-utils')
4 files changed, 182 insertions, 0 deletions
diff --git a/security-utils/src/main/java/com/yahoo/security/tls/policy/AuthorizedPeers.java b/security-utils/src/main/java/com/yahoo/security/tls/policy/AuthorizedPeers.java new file mode 100644 index 00000000000..b5d295e29c8 --- /dev/null +++ b/security-utils/src/main/java/com/yahoo/security/tls/policy/AuthorizedPeers.java @@ -0,0 +1,42 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.security.tls.policy; + +import java.util.Collections; +import java.util.Objects; +import java.util.Set; + +/** + * @author bjorncs + */ +public class AuthorizedPeers { + + private final Set<PeerPolicy> peerPolicies; + + public AuthorizedPeers(Set<PeerPolicy> peerPolicies) { + this.peerPolicies = Collections.unmodifiableSet(peerPolicies); + } + + public Set<PeerPolicy> peerPolicies() { + return peerPolicies; + } + + @Override + public String toString() { + return "AuthorizedPeers{" + + "peerPolicies=" + peerPolicies + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + AuthorizedPeers that = (AuthorizedPeers) o; + return Objects.equals(peerPolicies, that.peerPolicies); + } + + @Override + public int hashCode() { + return Objects.hash(peerPolicies); + } +} diff --git a/security-utils/src/main/java/com/yahoo/security/tls/policy/HostGlobPattern.java b/security-utils/src/main/java/com/yahoo/security/tls/policy/HostGlobPattern.java new file mode 100644 index 00000000000..dbe500836e5 --- /dev/null +++ b/security-utils/src/main/java/com/yahoo/security/tls/policy/HostGlobPattern.java @@ -0,0 +1,40 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.security.tls.policy; + +import java.util.Objects; + +/** + * @author bjorncs + */ +public class HostGlobPattern { + + private final String pattern; + + public HostGlobPattern(String pattern) { + this.pattern = pattern; + } + + public String asString() { + return pattern; + } + + @Override + public String toString() { + return "HostGlobPattern{" + + "pattern='" + pattern + '\'' + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + HostGlobPattern that = (HostGlobPattern) o; + return Objects.equals(pattern, that.pattern); + } + + @Override + public int hashCode() { + return Objects.hash(pattern); + } +} diff --git a/security-utils/src/main/java/com/yahoo/security/tls/policy/PeerPolicy.java b/security-utils/src/main/java/com/yahoo/security/tls/policy/PeerPolicy.java new file mode 100644 index 00000000000..77ee793777c --- /dev/null +++ b/security-utils/src/main/java/com/yahoo/security/tls/policy/PeerPolicy.java @@ -0,0 +1,50 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.security.tls.policy; + +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * @author bjorncs + */ +public class PeerPolicy { + + private final String peerName; + private final List<RequiredPeerCredential> requiredCredentials; + + public PeerPolicy(String peerName, List<RequiredPeerCredential> requiredCredentials) { + this.peerName = peerName; + this.requiredCredentials = Collections.unmodifiableList(requiredCredentials); + } + + public String peerName() { + return peerName; + } + + public List<RequiredPeerCredential> requiredCredentials() { + return requiredCredentials; + } + + @Override + public String toString() { + return "PeerPolicy{" + + "peerName='" + peerName + '\'' + + ", requiredCredentials=" + requiredCredentials + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PeerPolicy that = (PeerPolicy) o; + return Objects.equals(peerName, that.peerName) && + Objects.equals(requiredCredentials, that.requiredCredentials); + } + + @Override + public int hashCode() { + return Objects.hash(peerName, requiredCredentials); + } +} diff --git a/security-utils/src/main/java/com/yahoo/security/tls/policy/RequiredPeerCredential.java b/security-utils/src/main/java/com/yahoo/security/tls/policy/RequiredPeerCredential.java new file mode 100644 index 00000000000..4f028d8b1ab --- /dev/null +++ b/security-utils/src/main/java/com/yahoo/security/tls/policy/RequiredPeerCredential.java @@ -0,0 +1,50 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.security.tls.policy; + +import java.util.Objects; + +/** + * @author bjorncs + */ +public class RequiredPeerCredential { + + public enum Field { CN, SAN_DNS } + + private final Field field; + private final HostGlobPattern pattern; + + public RequiredPeerCredential(Field field, HostGlobPattern pattern) { + this.field = field; + this.pattern = pattern; + } + + public Field field() { + return field; + } + + public HostGlobPattern pattern() { + return pattern; + } + + @Override + public String toString() { + return "RequiredPeerCredential{" + + "field=" + field + + ", pattern=" + pattern + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RequiredPeerCredential that = (RequiredPeerCredential) o; + return field == that.field && + Objects.equals(pattern, that.pattern); + } + + @Override + public int hashCode() { + return Objects.hash(field, pattern); + } +} |