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; 022import java.util.Optional; 023 024/** 025 * Application-owned lookup of trusted, pre-registered client configuration. 026 * Implementations must be thread safe and honor the remaining budget. Absence means a genuinely unknown client; 027 * exceptions, null results and exhausted budgets are infrastructure faults, never an unknown-client decision. 028 * A returned registration must retain the exact requested client identifier. 029 * 030 * @author <a href="https://www.revetkn.com">Mark Allen</a> 031 * @since 1.0.0 032 */ 033@ThreadSafe 034@FunctionalInterface 035public interface OAuthServerClientRepository { 036 /** 037 * Looks up trusted registration without interpreting the identifier as an outbound URL. 038 * @param clientId the exact client identifier 039 * @param remainingTime the cooperative remaining operation budget 040 * @return the registration, or genuine absence 041 * @since 1.0.0 042 */ 043 @NonNull Optional<@NonNull OAuthServerClientRegistration> findRegisteredClient(@NonNull String clientId, 044 @NonNull Duration remainingTime); 045}