001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.commons.secret;
018
019/**
020 * The policy a network- or OS-backed {@link SecretStore} applies when its backing store cannot answer — for
021 * example when the OS keychain tool is missing or a remote vault is unreachable.
022 *
023 * <p>
024 * Modeled on the {@code FailMode} of {@link org.apache.juneau.commons.concurrent.ReplayCache}: the policy is a
025 * consumer decision rather than a fixed SPI behavior.  The built-in {@link InMemorySecretStore} and
026 * {@link EnvVarSecretStore} never encounter an unavailable backend, so this enum is only meaningful for the
027 * out-of-commons implementations that reach an external secret backend.
028 *
029 * <p>
030 * Note this is orthogonal to a key simply being <i>absent</i> &mdash; a store that successfully answers "no secret
031 * under this key" is not a failure and is never resolved through a {@link FailMode}.
032 *
033 * @since 10.0.0
034 */
035public enum FailMode {
036
037   /** Treat a backend failure as a missing secret: {@code find} returns empty, {@code exists}/{@code delete} return <jk>false</jk> (availability-preserving). */
038   FAIL_OPEN,
039
040   /** Treat a backend failure as an error and propagate it, so the operation fails loudly rather than silently reporting a secret as absent (the safe default). */
041   FAIL_CLOSED
042}