001package com.nimbusds.oauth2.sdk.jose.jwk;
002
003
004import java.util.Collections;
005import java.util.List;
006
007import com.nimbusds.jose.jwk.JWK;
008import com.nimbusds.jose.jwk.JWKSelector;
009import com.nimbusds.jose.jwk.JWKSet;
010import com.nimbusds.oauth2.sdk.id.Identifier;
011import net.jcip.annotations.Immutable;
012
013
014/**
015 * Immutable JSON Web Key (JWK) set. Intended for a JWK set specified by value.
016 */
017@Immutable
018@Deprecated
019public class ImmutableJWKSet extends AbstractJWKSource {
020
021
022        /**
023         * The JWK set.
024         */
025        private final JWKSet jwkSet;
026
027
028        /**
029         * Creates a new immutable JWK set.
030         *
031         * @param id     The JWK set owner identifier. Typically the OAuth 2.0
032         *               server issuer ID, or client ID. Must not be
033         *               {@code null}.
034         * @param jwkSet The JWK set. Must not be {@code null}.
035         */
036        public ImmutableJWKSet(final Identifier id, final JWKSet jwkSet) {
037                super(id);
038                if (jwkSet == null) {
039                        throw new IllegalArgumentException("The JWK set must not be null");
040                }
041                this.jwkSet = jwkSet;
042        }
043
044
045        /**
046         * Returns the JWK set.
047         *
048         * @return The JWK set.
049         */
050        public JWKSet getJWKSet() {
051                return jwkSet;
052        }
053
054
055        @Override
056        public List<JWK> get(final Identifier id, final JWKSelector jwkSelector) {
057                if (! getOwner().equals(id)) {
058                        return Collections.emptyList();
059                }
060                return jwkSelector.select(jwkSet);
061        }
062}