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;
019
020
021import com.nimbusds.oauth2.sdk.auth.ClientAuthentication;
022
023import java.net.URI;
024import java.util.Objects;
025
026
027/**
028 * Abstract request with client authentication.
029 *
030 * <p>Client authentication methods:
031 *
032 * <ul>
033 *     <li>{@link com.nimbusds.oauth2.sdk.auth.ClientSecretBasic client_secret_basic}
034 *     <li>{@link com.nimbusds.oauth2.sdk.auth.ClientSecretPost client_secret_post}
035 *     <li>{@link com.nimbusds.oauth2.sdk.auth.ClientSecretJWT client_secret_jwt}
036 *     <li>{@link com.nimbusds.oauth2.sdk.auth.PrivateKeyJWT private_key_jwt}
037 *     <li>{@link com.nimbusds.oauth2.sdk.auth.SelfSignedTLSClientAuthentication self_signed_tls_client_auth}
038 *     <li>{@link com.nimbusds.oauth2.sdk.auth.PKITLSClientAuthentication tls_client_auth}
039 * </ul>
040 */
041public abstract class AbstractAuthenticatedRequest extends AbstractRequest {
042        
043
044        /**
045         * The client authentication.
046         */
047        private final ClientAuthentication clientAuth;
048
049
050        /**
051         * Creates a new abstract request with client authentication.
052         *
053         * @param endpoint   The URI of the endpoint. May be {@code null} if
054         *                   the {@link #toHTTPRequest} method is not going to
055         *                   be used.
056         * @param clientAuth The client authentication. Must not be
057         *                   {@code null}.
058         */
059        protected AbstractAuthenticatedRequest(final URI endpoint,
060                                               final ClientAuthentication clientAuth) {
061
062                super(endpoint);
063                this.clientAuth = Objects.requireNonNull(clientAuth);
064        }
065
066
067        /**
068         * Returns the client authentication.
069         *
070         * @return The client authentication.
071         */
072        public ClientAuthentication getClientAuthentication() {
073                return clientAuth;
074        }
075}