blob: c83e25c60730796131fc86b04ed3fc104988e563 (
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
|
package com.yahoo.vespa.hosted.controller.api.role;
import com.yahoo.config.provision.SystemName;
import java.net.URI;
/**
* Checks whether {@link Role}s have the required {@link Privilege}s to perform {@link Action}s on given {@link java.net.URI}s.
*
* @author jonmv
*/
public class Enforcer {
private final SystemName system;
public Enforcer(SystemName system) {
this.system = system;
}
/** Returns whether {@code role} has permission to perform {@code action} on {@code resource}, in this enforcer's system. */
public boolean allows(Role role, Action action, URI resource) {
return role.definition().policies().stream().anyMatch(policy -> policy.evaluate(action, resource, role.context, system));
}
}
|