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