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 * Provider SPI for contributing a {@link SecretStore} via {@code ServiceLoader}.
021 *
022 * <p>
023 * Mirrors {@link org.apache.juneau.commons.settings.PropertySourceProvider}: a module on the classpath can register
024 * a store (for example an OS-keychain-backed store, or the {@link EnvVarSecretStore}) by listing its provider in a
025 * {@code META-INF/services/org.apache.juneau.commons.secret.SecretStoreProvider} file.  Discovery is opt-in through
026 * {@link SecretStores#fromServiceLoader()}; it does not change the {@link SecretStores#resolve} default, which
027 * remains {@link InMemorySecretStore}.
028 *
029 * @since 10.0.0
030 */
031public interface SecretStoreProvider {
032
033   /**
034    * Creates a secret store.
035    *
036    * @return The secret store, or <jk>null</jk> to skip registration.
037    */
038   SecretStore create();
039
040   /**
041    * Sort key used by {@code ServiceLoader} wiring.
042    *
043    * <p>
044    * Lower values sort first.
045    *
046    * @return The order value.
047    */
048   default int order() {
049      return 0;
050   }
051}