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 * </ul>
037 */
038public abstract class AbstractOptionallyAuthenticatedRequest extends AbstractRequest {
039        
040
041        /**
042         * The client authentication, {@code null} if none.
043         */
044        private final ClientAuthentication clientAuth;
045
046
047        /**
048         * Creates a new abstract request with optional client authentication.
049         *
050         * @param uri        The URI of the endpoint (HTTP or HTTPS) for which
051         *                   the request is intended, {@code null} if not
052         *                   specified (if, for example, the
053         *                   {@link #toHTTPRequest()} method will not be used).
054         * @param clientAuth The client authentication, {@code null} if none.
055         */
056        public AbstractOptionallyAuthenticatedRequest(final URI uri,
057                                                      final ClientAuthentication clientAuth) {
058
059                super(uri);
060
061                this.clientAuth = clientAuth;
062        }
063
064
065        /**
066         * Returns the client authentication.
067         *
068         * @return The client authentication, {@code null} if none.
069         */
070        public ClientAuthentication getClientAuthentication() {
071
072                return clientAuth;
073        }
074}