001package com.nimbusds.oauth2.sdk; 002 003 004import java.net.URI; 005 006import com.nimbusds.oauth2.sdk.auth.ClientAuthentication; 007 008 009/** 010 * Abstract request with optional client authentication. 011 * 012 * <p>Client authentication methods: 013 * 014 * <ul> 015 * <li>{@link com.nimbusds.oauth2.sdk.auth.ClientSecretBasic client_secret_basic} 016 * <li>{@link com.nimbusds.oauth2.sdk.auth.ClientSecretPost client_secret_post} 017 * <li>{@link com.nimbusds.oauth2.sdk.auth.ClientSecretJWT client_secret_jwt} 018 * <li>{@link com.nimbusds.oauth2.sdk.auth.PrivateKeyJWT private_key_jwt} 019 * </ul> 020 */ 021public abstract class AbstractOptionallyAuthenticatedRequest extends AbstractRequest { 022 023 024 /** 025 * The client authentication, {@code null} if none. 026 */ 027 private final ClientAuthentication clientAuth; 028 029 030 /** 031 * Creates a new abstract request with optional client authentication. 032 * 033 * @param uri The URI of the endpoint (HTTP or HTTPS) for which 034 * the request is intended, {@code null} if not 035 * specified (if, for example, the 036 * {@link #toHTTPRequest()} method will not be used). 037 * @param clientAuth The client authentication, {@code null} if none. 038 */ 039 public AbstractOptionallyAuthenticatedRequest(final URI uri, 040 final ClientAuthentication clientAuth) { 041 042 super(uri); 043 044 this.clientAuth = clientAuth; 045 } 046 047 048 /** 049 * Returns the client authentication. 050 * 051 * @return The client authentication, {@code null} if none. 052 */ 053 public ClientAuthentication getClientAuthentication() { 054 055 return clientAuth; 056 } 057}