blob: bcc2fa0e698d20625976d65bc26fc855ebb88e35 (
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
|
// 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.authz;
import com.yahoo.security.tls.policy.Role;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;
/**
* @author bjorncs
*/
public class AuthorizationResult {
private final Set<Role> assumedRoles;
private final Set<String> matchedPolicies;
public AuthorizationResult(Set<Role> assumedRoles, Set<String> matchedPolicies) {
this.assumedRoles = Collections.unmodifiableSet(assumedRoles);
this.matchedPolicies = Collections.unmodifiableSet(matchedPolicies);
}
public Set<Role> assumedRoles() {
return assumedRoles;
}
public Set<String> matchedPolicies() {
return matchedPolicies;
}
public boolean succeeded() {
return matchedPolicies.size() > 0;
}
@Override
public String toString() {
return "AuthorizationResult{" +
"assumedRoles=" + assumedRoles +
", matchedPolicies=" + matchedPolicies +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AuthorizationResult that = (AuthorizationResult) o;
return Objects.equals(assumedRoles, that.assumedRoles) &&
Objects.equals(matchedPolicies, that.matchedPolicies);
}
@Override
public int hashCode() {
return Objects.hash(assumedRoles, matchedPolicies);
}
}
|