001/* 002 * oauth2-oidc-sdk 003 * 004 * Copyright 2012-2016, Connect2id Ltd and contributors. 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.oauth2.sdk.jose.jwk; 019 020 021import java.util.Collections; 022import java.util.List; 023 024import com.nimbusds.jose.jwk.JWK; 025import com.nimbusds.jose.jwk.JWKSelector; 026import com.nimbusds.jose.jwk.JWKSet; 027import com.nimbusds.oauth2.sdk.id.Identifier; 028import net.jcip.annotations.Immutable; 029 030 031/** 032 * Immutable JSON Web Key (JWK) set. Intended for a JWK set specified by value. 033 */ 034@Immutable 035@Deprecated 036public class ImmutableJWKSet extends AbstractJWKSource { 037 038 039 /** 040 * The JWK set. 041 */ 042 private final JWKSet jwkSet; 043 044 045 /** 046 * Creates a new immutable JWK set. 047 * 048 * @param id The JWK set owner identifier. Typically the OAuth 2.0 049 * server issuer ID, or client ID. Must not be 050 * {@code null}. 051 * @param jwkSet The JWK set. Must not be {@code null}. 052 */ 053 public ImmutableJWKSet(final Identifier id, final JWKSet jwkSet) { 054 super(id); 055 if (jwkSet == null) { 056 throw new IllegalArgumentException("The JWK set must not be null"); 057 } 058 this.jwkSet = jwkSet; 059 } 060 061 062 /** 063 * Returns the JWK set. 064 * 065 * @return The JWK set. 066 */ 067 public JWKSet getJWKSet() { 068 return jwkSet; 069 } 070 071 072 @Override 073 public List<JWK> get(final Identifier id, final JWKSelector jwkSelector) { 074 if (! getOwner().equals(id)) { 075 return Collections.emptyList(); 076 } 077 return jwkSelector.select(jwkSet); 078 } 079}