summaryrefslogtreecommitdiffstats
path: root/security-utils/src/main/java/com/yahoo/security/tls/policy/PeerPolicy.java
blob: 77ee793777cf97ec675eb770d609553c6069d39b (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
// 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);
    }
}