001package com.nimbusds.openid.connect.provider.spi.clientauth;
002
003
004import java.net.URI;
005
006import com.nimbusds.oauth2.sdk.ErrorObject;
007import com.nimbusds.oauth2.sdk.auth.verifier.InvalidClientException;
008
009
010/**
011 * {@linkplain InvalidClientException} with {@code error_description} and
012 * {@code error_uri} details exposed in the {@code HTTP 401 Unauthorized} error
013 * response.
014 */
015public class ExposedInvalidClientException extends InvalidClientException {
016        
017        
018        /**
019         * The error description.
020         */
021        private final String errorDescription;
022        
023        
024        /**
025         * The error URI.
026         */
027        private final URI errorURI;
028        
029        
030        /**
031         * Creates a new exposed invalid client exception.
032         *
033         * @param message          The exception message (will be logged by the
034         *                         Connect2id server and not exposed in the
035         *                         HTTP 401 Unauthorized error response),
036         *                         {@code null} if not specified.
037         * @param errorDescription The {@code error_description} to return in
038         *                         the HTTP 401 Unauthorized response,
039         *                         {@code null} if not specified.
040         */
041        public ExposedInvalidClientException(final String message, final String errorDescription) {
042                this(message, errorDescription, null);
043        }
044        
045        
046        /**
047         * Creates a new exposed invalid client exception.
048         *
049         * @param message          The exception message (will be logged by the
050         *                         Connect2id server and not exposed in the
051         *                         HTTP 401 Unauthorized error response),
052         *                         {@code null} if not specified.
053         * @param errorDescription The {@code error_description} to return in
054         *                         the HTTP 401 Unauthorized response,
055         *                         {@code null} if not specified.
056         * @param errorURI         The {@code error_uri} to return in the HTTP
057         *                         401 Unauthorized response, {@code null} if
058         *                         not specified.
059         */
060        public ExposedInvalidClientException(final String message, final String errorDescription, final URI errorURI) {
061                super(message);
062                this.errorDescription = errorDescription;
063                this.errorURI = errorURI;
064        }
065        
066        
067        @Override
068        public ErrorObject getErrorObject() {
069                return super.getErrorObject().setDescription(errorDescription).setURI(errorURI);
070        }
071}