001package com.nimbusds.oauth2.sdk;
002
003
004import java.net.URI;
005
006import com.nimbusds.oauth2.sdk.auth.ClientAuthentication;
007
008
009/**
010 * Optionally authenticated requests.
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 optionally authenticted request.
032         *
033         * @param uri The URI of the endpoint (HTTP or HTTPS) for which the
034         *            request is intended, {@code null} if not specified (if,
035         *            for example, the {@link #toHTTPRequest()} method will not
036         *            be used).
037         */
038        public AbstractOptionallyAuthenticatedRequest(final URI uri,
039                                                      final ClientAuthentication clientAuth) {
040
041                super(uri);
042
043                this.clientAuth = clientAuth;
044        }
045
046
047        /**
048         * Returns the client authentication.
049         *
050         * @return The client authentication, {@code null} if none.
051         */
052        public ClientAuthentication getClientAuthentication() {
053
054                return clientAuth;
055        }
056}