aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/api/AthenzUser.java
blob: daf3ef254798e4a6682218b396eac8fa16026b60 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.athenz.api;

import com.yahoo.vespa.athenz.utils.AthenzIdentities;

import java.util.Objects;

/**
 * @author bjorncs
 */
public class AthenzUser implements AthenzIdentity {
    private final String userId;

    public AthenzUser(String userId) {
        this.userId = userId;
    }

    public static AthenzUser fromUserId(String userId) {
        return new AthenzUser(userId);
    }

    @Override
    public AthenzDomain getDomain() {
        return AthenzIdentities.USER_PRINCIPAL_DOMAIN;
    }

    @Override
    public String getName() {
        return userId;
    }

    @Override
    public String toString() {
        return "AthenzUser{" +
                "userId=" + userId +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AthenzUser that = (AthenzUser) o;
        return Objects.equals(userId, that.userId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(userId);
    }
}