001package com.nimbusds.oauth2.sdk.auth.verifier;
002
003
004import com.nimbusds.oauth2.sdk.ErrorObject;
005import com.nimbusds.oauth2.sdk.OAuth2Error;
006
007
008/**
009 * Invalid client exception. Selected static instances are provided to speed up
010 * exception processing.
011 */
012public class InvalidClientException extends Exception {
013        
014
015        /**
016         * Bad {@code client_id}.
017         */
018        public static final InvalidClientException BAD_ID = new InvalidClientException("Bad client ID");
019
020
021        /**
022         * The client is not registered for the requested authentication
023         * method.
024         */
025        public static final InvalidClientException NOT_REGISTERED_FOR_AUTH_METHOD = new InvalidClientException("The client is not registered for the requested authentication method");
026
027
028        /**
029         * The client has no registered {@code client_secret}.
030         */
031        public static final InvalidClientException NO_REGISTERED_SECRET = new InvalidClientException("The client has no registered secret");
032
033
034        /**
035         * The client has no registered JWK set.
036         */
037        public static final InvalidClientException NO_REGISTERED_JWK_SET = new InvalidClientException("The client has no registered JWK set");
038
039
040        /**
041         * Expired {@code client_secret}.
042         */
043        public static final InvalidClientException EXPIRED_SECRET = new InvalidClientException("Expired client secret");
044
045
046        /**
047         * Bad {@code client_secret}.
048         */
049        public static final InvalidClientException BAD_SECRET = new InvalidClientException("Bad client secret");
050
051
052        /**
053         * Bad JWT claims (e.g. expired JWT).
054         */
055        public static final InvalidClientException BAD_JWT_CLAIMS = new InvalidClientException("Bad / expired JWT claims");
056
057
058        /**
059         * Bad JWT HMAC.
060         */
061        public static final InvalidClientException BAD_JWT_HMAC = new InvalidClientException("Bad JWT HMAC");
062
063
064        /**
065         * No matching public JWKs for JWT signature verification found.
066         */
067        public static final InvalidClientException NO_MATCHING_JWK = new InvalidClientException("No matching JWKs found");
068
069
070        /**
071         * Bad JWT signature.
072         */
073        public static final InvalidClientException BAD_JWT_SIGNATURE = new InvalidClientException("Bad JWT signature");
074
075
076        /**
077         * Creates a new invalid client exception.
078         *
079         * @param message The message.
080         */
081        public InvalidClientException(final String message) {
082                super(message);
083        }
084
085
086        /**
087         * Returns an OAuth 2.0 error object representation.
088         *
089         * @return {@link OAuth2Error#INVALID_CLIENT}.
090         */
091        public ErrorObject toErrorObject() {
092                return OAuth2Error.INVALID_CLIENT;
093        }
094}