aboutsummaryrefslogtreecommitdiffstats
path: root/security-utils/src/main/java/com/yahoo/security/tls/CapabilityMode.java
blob: c2fa11ce7f77a0b8d57da83201d6004da8f54e70 (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
// Copyright Yahoo. 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 CapabilityMode {
    DISABLE("disable"), LOG_ONLY("log_only"), ENFORCE("enforce");

    private final String configValue;

    CapabilityMode(String configValue) { this.configValue = configValue; }

    public String configValue() { return configValue; }

    /** @return Default value when mode is not explicitly specified */
    public static CapabilityMode defaultValue() { return DISABLE; }

    public static CapabilityMode fromConfigValue(String configValue) {
        return Arrays.stream(values())
                .filter(c -> c.configValue.equals(configValue))
                .findFirst().orElseThrow(() -> new IllegalArgumentException("Unknown value: " + configValue));
    }
}