001package com.nimbusds.openid.connect.provider.spi.par;
002
003
004import com.nimbusds.oauth2.sdk.ErrorObject;
005import com.nimbusds.oauth2.sdk.OAuth2Error;
006
007
008/**
009 * Invalid Pushed Authorisation Request (PAR) exception.
010 */
011public class InvalidPushedAuthorizationRequestException extends Exception {
012        
013        
014        /**
015         * The error object.
016         */
017        private final ErrorObject errorObject;
018        
019        
020        /**
021         * Creates a new invalid Pushed Authorisation Request (PAR) exception.
022         * The HTTP status is set to 400 and error code in the JSON object is
023         * set to {@link OAuth2Error#INVALID_REQUEST invalid_request}.
024         *
025         * @param message The exception message, will be logged. Should not be
026         *                {@code null}.
027         */
028        public InvalidPushedAuthorizationRequestException(final String message) {
029                this(message, OAuth2Error.INVALID_REQUEST);
030        }
031        
032        
033        /**
034         * Creates a new invalid OAuth 2.0 authorisation / OpenID
035         * authentication request exception.
036         *
037         * @param message     The exception message, will be logged. Should not
038         *                    be {@code null}.
039         * @param errorObject The error object, with HTTP status, error code
040         *                    and optional error description and error URI.
041         *                    Must not be {@code null}.
042         */
043        public InvalidPushedAuthorizationRequestException(final String message,
044                                                          final ErrorObject errorObject) {
045                super(message);
046                if (errorObject == null) {
047                        throw new IllegalArgumentException("The error object must not be null");
048                }
049                this.errorObject = errorObject;
050        }
051        
052        
053        /**
054         * Returns the error object.
055         *
056         * @return The error object with HTTP status, error code and optional
057         *         error description and error URI.
058         */
059        public ErrorObject getErrorObject() {
060                return errorObject;
061        }
062}