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.auth;
019
020
021import com.nimbusds.oauth2.sdk.id.ClientID;
022
023
024/**
025 * Base abstract class for plain secret based client authentication at the
026 * Token endpoint.
027 *
028 * <p>Related specifications:
029 *
030 * <ul>
031 *     <li>OAuth 2.0 (RFC 6749), sections 2.3.1 and 3.2.1.
032 *     <li>OpenID Connect Core 1.0, section 9.
033 * </ul>
034 */
035public abstract class PlainClientSecret extends ClientAuthentication {
036
037
038        /**
039         * The client secret.
040         */
041        private final Secret secret;
042
043
044        /**
045         * Creates a new plain secret based client authentication.
046         *
047         * @param method   The client authentication method. Must not be
048         *                 {@code null}.
049         * @param clientID The client identifier. Must not be {@code null}.
050         * @param secret   The client secret. Must not be {@code null}.
051         */
052        protected PlainClientSecret(final ClientAuthenticationMethod method,
053                                    final ClientID clientID,
054                                    final Secret secret) {
055
056                super(method, clientID);
057
058                if (secret == null) {
059                        throw new IllegalArgumentException("The client secret must not be null");
060                }
061
062                this.secret = secret;
063        }
064
065
066        /**
067         * Gets the client secret.
068         *
069         * @return The client secret.
070         */
071        public Secret getClientSecret() {
072
073                return secret;
074        }
075}