001package com.nimbusds.oauth2.sdk;
002
003
004import com.nimbusds.oauth2.sdk.http.HTTPResponse;
005
006
007/**
008 * Standard OAuth 2.0 authorisation and token endpoint errors.
009 *
010 * <p>The set HTTP status code is ignored for authorisation errors passed by
011 * HTTP redirection. Errors that are only used by at the authorisation endpoint
012 * are supplied with a matching HTTP status code in case they are used in a
013 * different context.
014 */
015public final class OAuth2Error {
016
017
018        // Common OAuth 2.0 authorisation errors
019        
020        /**
021         * The request is missing a required parameter, includes an invalid 
022         * parameter, or is otherwise malformed.
023         */
024        public static final ErrorObject INVALID_REQUEST = 
025                new ErrorObject("invalid_request", "Invalid request", HTTPResponse.SC_BAD_REQUEST);
026        
027        
028        /**
029         * The client is not authorised to request an authorisation code using 
030         * this method.
031         */
032        public static final ErrorObject UNAUTHORIZED_CLIENT =
033                new ErrorObject("unauthorized_client", "Unauthorized client", HTTPResponse.SC_BAD_REQUEST);
034        
035        
036        /**
037         * The resource owner or authorisation server denied the request.
038         */
039        public static final ErrorObject ACCESS_DENIED =
040                new ErrorObject("access_denied", "Access denied by resource owner or authorization server", HTTPResponse.SC_FORBIDDEN);
041        
042        
043        /**
044         * The authorisation server does not support obtaining an authorisation 
045         * code using this method.
046         */
047        public static final ErrorObject UNSUPPORTED_RESPONSE_TYPE =
048                new ErrorObject("unsupported_response_type", "Unsupported response type", HTTPResponse.SC_BAD_REQUEST);
049        
050        
051        /**
052         * The requested scope is invalid, unknown, or malformed.
053         */
054        public static final ErrorObject INVALID_SCOPE =
055                new ErrorObject("invalid_scope", "Invalid, unknown or malformed scope", HTTPResponse.SC_BAD_REQUEST);
056        
057        
058        /**
059         * The authorisation server encountered an unexpected condition which 
060         * prevented it from fulfilling the request.
061         */
062        public static final ErrorObject SERVER_ERROR =
063                new ErrorObject("server_error", "Unexpected server error", HTTPResponse.SC_SERVER_ERROR);
064        
065        
066        /**
067         * The authorisation server is currently unable to handle the request 
068         * due to a temporary overloading or maintenance of the server.
069         */
070        public static final ErrorObject TEMPORARILY_UNAVAILABLE =
071                new ErrorObject("temporarily_unavailable", "The authorization server is temporarily unavailable", HTTPResponse.SC_SERVICE_UNAVAILABLE);
072        
073        
074        // Token, Base OAuth 2.0 authorisation errors, section 5.2
075        
076        /**
077         * Client authentication failed (e.g. unknown client, no client 
078         * authentication included, or unsupported authentication method).
079         */
080        public static final ErrorObject INVALID_CLIENT =
081                new ErrorObject("invalid_client", "Client authentication failed", HTTPResponse.SC_UNAUTHORIZED);
082        
083        
084        /**
085         * The provided authorisation grant (e.g. authorisation code, resource 
086         * owner credentials) or refresh token is invalid, expired, revoked, 
087         * does not match the redirection URI used in the authorization request,
088         * or was issued to another client.
089         */
090        public static final ErrorObject INVALID_GRANT =
091                new ErrorObject("invalid_grant", "Invalid grant", HTTPResponse.SC_BAD_REQUEST);
092        
093        
094        /**
095         * The authorisation grant type is not supported by the authorisation 
096         * server.
097         */
098        public static final ErrorObject UNSUPPORTED_GRANT_TYPE =
099                new ErrorObject("unsupported_grant_type", "Unsupported grant type", HTTPResponse.SC_BAD_REQUEST);
100
101        
102        /**
103         * Prevents public instantiation.
104         */
105        private OAuth2Error() { }
106}