001/*
002 * Copyright 2026 Revetware LLC.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package com.revetsec.oauth.server;
018
019import org.jspecify.annotations.NonNull;
020import javax.annotation.concurrent.ThreadSafe;
021import java.time.Duration;
022
023/**
024 * Application-owned verification of a pre-registered confidential client's secret.
025 * Implementations must be thread safe, honor the remaining budget and use constant-time secret verification.
026 * The issuer owns Basic decoding and clears the temporary secret after the callback; do not retain its bytes.
027 * A false result means invalid credentials; a null result, exception or exhausted budget is an infrastructure fault.
028 *
029 * @author <a href="https://www.revetkn.com">Mark Allen</a>
030 * @since 1.0.0
031 */
032@ThreadSafe
033@FunctionalInterface
034public interface OAuthClientSecretVerifier {
035        /**
036         * Checks a temporary decoded secret against application-managed credentials.
037         * @param clientId the exact registered client identifier
038         * @param presentedSecret temporary secret bytes, valid only for this callback
039         * @param remainingTime the cooperative remaining operation budget
040         * @return whether the secret matches
041         * @since 1.0.0
042         */
043        @NonNull Boolean verifiesClientSecret(@NonNull String clientId, byte @NonNull [] presentedSecret,
044                        @NonNull Duration remainingTime);
045}