diff options
author | Bjørn Christian Seime <bjorncs@oath.com> | 2018-12-05 16:13:08 +0100 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@oath.com> | 2018-12-05 16:35:35 +0100 |
commit | b3758264b1f374500408ecc8c6a5976012749574 (patch) | |
tree | b4751c49703c1d5ebbccdc7af67e300d963d3bd0 | |
parent | 0b4bd58456ae968d17e0a1a56486f1051f8dc1fe (diff) |
Add AutorizationMode
-rw-r--r-- | security-utils/src/main/java/com/yahoo/security/tls/AuthorizationMode.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/security-utils/src/main/java/com/yahoo/security/tls/AuthorizationMode.java b/security-utils/src/main/java/com/yahoo/security/tls/AuthorizationMode.java new file mode 100644 index 00000000000..141214dc478 --- /dev/null +++ b/security-utils/src/main/java/com/yahoo/security/tls/AuthorizationMode.java @@ -0,0 +1,30 @@ +// 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; + +import java.util.Arrays; + +/** + * @author bjorncs + */ +public enum AuthorizationMode { + DISABLE("disable"), + LOG_ONLY("log-only"), + ENFORCE("enforce"); + + final String configValue; + + AuthorizationMode(String configValue) { + this.configValue = configValue; + } + + public String configValue() { + return configValue; + } + + static AuthorizationMode fromConfigValue(String configValue) { + return Arrays.stream(values()) + .filter(v -> v.configValue.equals(configValue)) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException("Unknown value: " + configValue)); + } +} |