blob: e0026112426ff7f1d5e74d396df2c0d20633de63 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.http.filter.security.athenz;
import com.yahoo.component.annotation.Inject;
import com.yahoo.jdisc.http.filter.DiscFilterRequest;
import com.yahoo.vespa.athenz.api.AthenzResourceName;
import java.util.Optional;
/**
* A simple {@link RequestResourceMapper} that uses a fixed resource name and action
*
* @author bjorncs
*/
public class StaticRequestResourceMapper implements RequestResourceMapper {
private final AthenzResourceName resourceName;
private final String action;
@Inject
public StaticRequestResourceMapper(StaticRequestResourceMapperConfig config) {
this(AthenzResourceName.fromString(config.resourceName()), config.action());
}
StaticRequestResourceMapper(AthenzResourceName resourceName, String action) {
this.resourceName = resourceName;
this.action = action;
}
@Override
public Optional<ResourceNameAndAction> getResourceNameAndAction(DiscFilterRequest request) {
return Optional.of(new ResourceNameAndAction(resourceName, action));
}
}
|