001package com.nimbusds.jose.jwk.source; 002 003 004import java.util.List; 005 006import com.nimbusds.jose.KeySourceException; 007import com.nimbusds.jose.jwk.JWK; 008import com.nimbusds.jose.jwk.JWKSelector; 009import com.nimbusds.jose.proc.SecurityContext; 010 011 012/** 013 * JSON Web Key (JWK) source. Exposes a method for retrieving JWKs matching a 014 * specified selector. An optional context parameter is available to facilitate 015 * passing of additional data between the caller and the underlying JWK source 016 * (in both directions). Implementations must be thread-safe. 017 * 018 * @author Vladimir Dzhuvinov 019 * @version 2016-06-21 020 */ 021public interface JWKSource <C extends SecurityContext> { 022 023 024 /** 025 * Retrieves a list of JWKs matching the specified selector. 026 * 027 * @param jwkSelector A JWK selector. Must not be {@code null}. 028 * @param context Optional context, {@code null} if not required. 029 * 030 * @return The matching JWKs, empty list if no matches were found. 031 * 032 * @throws KeySourceException If key sourcing failed. 033 */ 034 List<JWK> get(final JWKSelector jwkSelector, final C context) 035 throws KeySourceException; 036}