|
| 1 | +/* |
| 2 | + * Copyright 2002-2020 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.springframework.security.oauth2.server.resource; |
| 18 | + |
| 19 | +import org.springframework.security.oauth2.core.OAuth2AuthenticationException; |
| 20 | + |
| 21 | +import static org.springframework.security.oauth2.server.resource.BearerTokenErrors.invalidToken; |
| 22 | + |
| 23 | +/** |
| 24 | + * An {@link OAuth2AuthenticationException} that indicates an invalid bearer token. |
| 25 | + * |
| 26 | + * @author Josh Cummings |
| 27 | + * @since 5.3 |
| 28 | + */ |
| 29 | +public class InvalidBearerTokenException extends OAuth2AuthenticationException { |
| 30 | + |
| 31 | + /** |
| 32 | + * Construct an instance of {@link InvalidBearerTokenException} given the provided |
| 33 | + * description. |
| 34 | + * |
| 35 | + * The description will be wrapped into an {@link org.springframework.security.oauth2.core.OAuth2Error} |
| 36 | + * instance as the {@code error_description}. |
| 37 | + * |
| 38 | + * @param description the description |
| 39 | + */ |
| 40 | + public InvalidBearerTokenException(String description) { |
| 41 | + super(invalidToken(description)); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Construct an instance of {@link InvalidBearerTokenException} given the provided |
| 46 | + * description and cause |
| 47 | + * |
| 48 | + * The description will be wrapped into an {@link org.springframework.security.oauth2.core.OAuth2Error} |
| 49 | + * instance as the {@code error_description}. |
| 50 | + * |
| 51 | + * @param description the description |
| 52 | + * @param cause the causing exception |
| 53 | + */ |
| 54 | + public InvalidBearerTokenException(String description, Throwable cause) { |
| 55 | + super(invalidToken(description), cause); |
| 56 | + } |
| 57 | +} |
0 commit comments