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.List;
022
023import com.nimbusds.jose.jwk.JWK;
024import com.nimbusds.jose.jwk.JWKSelector;
025import com.nimbusds.jose.jwk.JWKSet;
026import com.nimbusds.jose.jwk.OctetSequenceKey;
027import com.nimbusds.oauth2.sdk.auth.Secret;
028import com.nimbusds.oauth2.sdk.id.ClientID;
029import com.nimbusds.oauth2.sdk.id.Identifier;
030import net.jcip.annotations.Immutable;
031
032
033/**
034 * Immutable client secret.
035 */
036@Immutable
037@Deprecated
038public final class ImmutableClientSecret extends ImmutableJWKSet {
039
040
041        /**
042         * Creates a new immutable client secret.
043         *
044         * @param id     The client identifier. Must not be {@code null}.
045         * @param secret The client secret. Must not be {@code null}.
046         */
047        public ImmutableClientSecret(final ClientID id, final Secret secret) {
048
049                this(id, new OctetSequenceKey.Builder(secret.getValueBytes()).build());
050        }
051
052
053        /**
054         * Creates a new immutable client secret.
055         *
056         * @param id     The client identifier. Must not be {@code null}.
057         * @param secret The client secret. Must not be {@code null}.
058         */
059        public ImmutableClientSecret(final ClientID id, final OctetSequenceKey secret) {
060                super(id, new JWKSet(secret));
061        }
062
063
064        /**
065         * Returns the client secret.
066         *
067         * @return The client secret.
068         */
069        public OctetSequenceKey getClientSecret() {
070
071                return (OctetSequenceKey) getJWKSet().getKeys().get(0);
072        }
073
074
075        @Override
076        public List<JWK> get(final Identifier id, final JWKSelector jwkSelector) {
077                // Owner not checked, we have a shared secret
078                return jwkSelector.select(getJWKSet());
079        }
080}