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 java.net.URI;
022
023import com.nimbusds.oauth2.sdk.auth.ClientAuthentication;
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 uri        The URI of the endpoint (HTTP or HTTPS) for which
053         *                   the request is intended, {@code null} if not
054         *                   specified (if, for example, the
055         *                   {@link #toHTTPRequest()} method will not be used).
056         * @param clientAuth The client authentication, {@code null} if none.
057         */
058        public AbstractOptionallyAuthenticatedRequest(final URI uri,
059                                                      final ClientAuthentication clientAuth) {
060
061                super(uri);
062
063                this.clientAuth = clientAuth;
064        }
065
066
067        /**
068         * Returns the client authentication.
069         *
070         * @return The client authentication, {@code null} if none.
071         */
072        public ClientAuthentication getClientAuthentication() {
073
074                return clientAuth;
075        }
076}