001/* 002 * nimbus-jose-jwt 003 * 004 * Copyright 2012-2022, Connect2id Ltd. 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use 007 * this file except in compliance with the License. You may obtain a copy of the 008 * License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software distributed 013 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 014 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 015 * specific language governing permissions and limitations under the License. 016 */ 017 018package com.nimbusds.jose.jwk.source; 019 020 021import java.io.IOException; 022import java.util.Objects; 023 024import com.nimbusds.jose.proc.SecurityContext; 025 026 027/** 028 * Wraps a {@linkplain JWKSetSource} to provide convenient decoration by means 029 * of subclassing. Implements the Wrapper or Decorator pattern. 030 * 031 * @author Thomas Rørvik Skjølberg 032 * @author Vladimir Dzhuvinov 033 * @version 2022-08-24 034 */ 035public abstract class JWKSetSourceWrapper<C extends SecurityContext> implements JWKSetSource<C> { 036 037 038 /** 039 * The wrapped JWK set source. 040 */ 041 private final JWKSetSource<C> source; 042 043 044 /** 045 * Creates a new JWK set wrapper. 046 * 047 * @param source The JWK set source to wrap. Must not be {@code null}. 048 */ 049 public JWKSetSourceWrapper(final JWKSetSource<C> source) { 050 Objects.requireNonNull(source); 051 this.source = source; 052 } 053 054 055 /** 056 * Returns the wrapped JWK set source. 057 * 058 * @return The wrapped Jwk set source. 059 */ 060 public JWKSetSource<C> getSource() { 061 return source; 062 } 063 064 065 @Override 066 public void close() throws IOException { 067 source.close(); 068 } 069}