diff options
Diffstat (limited to 'container-core/src/main/java/com/yahoo/container/jdisc/AclMapping.java')
-rw-r--r-- | container-core/src/main/java/com/yahoo/container/jdisc/AclMapping.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/jdisc/AclMapping.java b/container-core/src/main/java/com/yahoo/container/jdisc/AclMapping.java new file mode 100644 index 00000000000..e7c3d71ba44 --- /dev/null +++ b/container-core/src/main/java/com/yahoo/container/jdisc/AclMapping.java @@ -0,0 +1,50 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +package com.yahoo.container.jdisc; + +import java.util.Objects; + +/** + * Mapping from request to action + * + * @author mortent + */ +public interface AclMapping { + class Action { + public static final Action READ = new Action("read"); + public static final Action WRITE = new Action("write"); + private final String name; + public static Action custom(String name) { + return new Action(name); + } + private Action(String name) { + if(Objects.requireNonNull(name).isBlank()) { + throw new IllegalArgumentException("Name cannot be blank"); + } + this.name = Objects.requireNonNull(name); + } + public String name() { return name; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Action action = (Action) o; + return Objects.equals(name, action.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } + + @Override + public String toString() { + return "Action{" + + "name='" + name + '\'' + + '}'; + } + } + + Action get(RequestView requestView); +} |