001package com.nimbusds.oauth2.sdk; 002 003 004import java.net.URI; 005 006import com.nimbusds.oauth2.sdk.auth.ClientAuthentication; 007import com.nimbusds.oauth2.sdk.id.ClientID; 008 009 010/** 011 * Abstract request with optional client authentication or client 012 * identification. 013 * 014 * <p>Client authentication methods: 015 * 016 * <ul> 017 * <li>{@link com.nimbusds.oauth2.sdk.auth.ClientSecretBasic client_secret_basic} 018 * <li>{@link com.nimbusds.oauth2.sdk.auth.ClientSecretPost client_secret_post} 019 * <li>{@link com.nimbusds.oauth2.sdk.auth.ClientSecretJWT client_secret_jwt} 020 * <li>{@link com.nimbusds.oauth2.sdk.auth.PrivateKeyJWT private_key_jwt} 021 * </ul> 022 * 023 * <p>Client identification methods: 024 * 025 * <ul> 026 * <li>Top level {@code client_id} parameter. 027 * </ul> 028 */ 029public abstract class AbstractOptionallyIdentifiedRequest extends AbstractOptionallyAuthenticatedRequest { 030 031 032 /** 033 * The client identifier, {@code null} if not specified. 034 */ 035 private final ClientID clientID; 036 037 038 039 /** 040 * Creates a new abstract request with optional client authentication. 041 * 042 * @param uri The URI of the endpoint (HTTP or HTTPS) for which 043 * the request is intended, {@code null} if not 044 * specified (if, for example, the 045 * {@link #toHTTPRequest()} method will not be used). 046 * @param clientAuth The client authentication, {@code null} if none. 047 */ 048 public AbstractOptionallyIdentifiedRequest(final URI uri, 049 final ClientAuthentication clientAuth) { 050 051 super(uri, clientAuth); 052 clientID = null; 053 } 054 055 056 /** 057 * Creates a new abstract request with optional client identification. 058 * 059 * @param uri The URI of the endpoint (HTTP or HTTPS) for which 060 * the request is intended, {@code null} if not 061 * specified (if, for example, the 062 * {@link #toHTTPRequest()} method will not be used). 063 * @param clientID The client identifier, {@code null} if not 064 * specified. 065 */ 066 public AbstractOptionallyIdentifiedRequest(final URI uri, 067 final ClientID clientID) { 068 069 super(uri, null); 070 this.clientID = clientID; 071 } 072 073 074 /** 075 * Gets the client identifier (for a request from a public client or a 076 * request without explicit client authentication). 077 * 078 * @see #getClientAuthentication() 079 * 080 * @return The client identifier, {@code null} if not specified. 081 */ 082 public ClientID getClientID() { 083 084 return clientID; 085 } 086}