@@ -0,0 +1,2011 @@
+/*%0A * Copyright 2002-2018 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.springframework.security.oauth2.jwt;%0A%0Aimport com.nimbusds.jose.JWSAlgorithm;%0Aimport com.nimbusds.jose.JWSHeader;%0Aimport com.nimbusds.jose.KeySourceException;%0Aimport com.nimbusds.jose.jwk.JWKMatcher;%0Aimport com.nimbusds.jose.jwk.JWKSelector;%0Aimport com.nimbusds.jose.proc.JWSVerificationKeySelector;%0A%0A/**%0A * @author Rob Winch%0A * @since 5.1%0A */%0Aclass JWKSelectorFactory %7B%0A%09private final DelegateSelectorFactory delegate;%0A%0A%09JWKSelectorFactory(JWSAlgorithm expectedJWSAlgorithm) %7B%0A%09%09this.delegate = new DelegateSelectorFactory(expectedJWSAlgorithm);%0A%09%7D%0A%0A%09JWKSelector createSelector(JWSHeader jwsHeader) %7B%0A%09%09return new JWKSelector(this.delegate.createJWKMatcher(jwsHeader));%0A%09%7D%0A%0A%09/**%0A%09 * Used to expose the protected %7B@link #createJWKMatcher(JWSHeader)%7D method.%0A%09 */%0A%09private static class DelegateSelectorFactory extends JWSVerificationKeySelector %7B%0A%09%09/**%0A%09%09 * Creates a new JWS verification key selector.%0A%09%09 *%0A%09%09 * @param jwsAlg    The expected JWS algorithm for the objects to be%0A%09%09 *                  verified. Must not be %7B@code null%7D.%0A%09%09 */%0A%09%09public DelegateSelectorFactory(JWSAlgorithm jwsAlg) %7B%0A%09%09%09super(jwsAlg, (jwkSelector, context) -%3E %7B%0A%09%09%09%09throw new KeySourceException(%22JWKSelectorFactory is only intended for creating a selector%22);%0A%09%09%09%7D);%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public JWKMatcher createJWKMatcher(JWSHeader jwsHeader) %7B%0A%09%09%09return super.createJWKMatcher(jwsHeader);%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add JWKSelectorFactory