blob: b31cb4a26bb612b739dbd708b8686ff9583f824b (
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.athenz;
import com.yahoo.vespa.hosted.controller.api.identifiers.AthenzDomain;
import java.security.Principal;
import java.util.Objects;
import java.util.Optional;
/**
* @author bjorncs
*/
public class AthenzPrincipal implements Principal {
private final AthenzIdentity athenzIdentity;
private final NToken nToken;
public AthenzPrincipal(AthenzIdentity athenzIdentity) {
this(athenzIdentity, null);
}
public AthenzPrincipal(AthenzIdentity athenzIdentity,
NToken nToken) {
this.athenzIdentity = athenzIdentity;
this.nToken = nToken;
}
public AthenzIdentity getIdentity() {
return athenzIdentity;
}
@Override
public String getName() {
return athenzIdentity.getFullName();
}
public AthenzDomain getDomain() {
return athenzIdentity.getDomain();
}
public Optional<NToken> getNToken() {
return Optional.ofNullable(nToken);
}
@Override
public String toString() {
return "AthenzPrincipal{" +
"athenzIdentity=" + athenzIdentity +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AthenzPrincipal principal = (AthenzPrincipal) o;
return Objects.equals(athenzIdentity, principal.athenzIdentity);
}
@Override
public int hashCode() {
return Objects.hash(athenzIdentity);
}
}
|