|
1 | 1 | /* |
2 | | - * Copyright 2002-2018 the original author or authors. |
| 2 | + * Copyright 2002-2025 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -73,29 +73,28 @@ private Map<String, String> createParameters(AuthenticationException authExcepti |
73 | 73 | if (this.realmName != null) { |
74 | 74 | parameters.put("realm", this.realmName); |
75 | 75 | } |
76 | | - if (authException instanceof OAuth2AuthenticationException) { |
77 | | - OAuth2Error error = ((OAuth2AuthenticationException) authException).getError(); |
| 76 | + if (authException instanceof OAuth2AuthenticationException oAuth2AuthenticationException) { |
| 77 | + OAuth2Error error = oAuth2AuthenticationException.getError(); |
78 | 78 | parameters.put("error", error.getErrorCode()); |
79 | 79 | if (StringUtils.hasText(error.getDescription())) { |
80 | 80 | parameters.put("error_description", error.getDescription()); |
81 | 81 | } |
82 | 82 | if (StringUtils.hasText(error.getUri())) { |
83 | 83 | parameters.put("error_uri", error.getUri()); |
84 | 84 | } |
85 | | - if (error instanceof BearerTokenError bearerTokenError) { |
86 | | - if (StringUtils.hasText(bearerTokenError.getScope())) { |
87 | | - parameters.put("scope", bearerTokenError.getScope()); |
88 | | - } |
| 85 | + if (error instanceof BearerTokenError bearerTokenError |
| 86 | + && StringUtils.hasText(bearerTokenError.getScope())) { |
| 87 | + parameters.put("scope", bearerTokenError.getScope()); |
89 | 88 | } |
90 | 89 | } |
91 | 90 | return parameters; |
92 | 91 | } |
93 | 92 |
|
94 | 93 | private HttpStatus getStatus(AuthenticationException authException) { |
95 | | - if (authException instanceof OAuth2AuthenticationException) { |
96 | | - OAuth2Error error = ((OAuth2AuthenticationException) authException).getError(); |
97 | | - if (error instanceof BearerTokenError) { |
98 | | - return ((BearerTokenError) error).getHttpStatus(); |
| 94 | + if (authException instanceof OAuth2AuthenticationException oAuth2AuthenticationException) { |
| 95 | + OAuth2Error error = oAuth2AuthenticationException.getError(); |
| 96 | + if (error instanceof BearerTokenError bearerTokenError) { |
| 97 | + return bearerTokenError.getHttpStatus(); |
99 | 98 | } |
100 | 99 | } |
101 | 100 | return HttpStatus.UNAUTHORIZED; |
|
0 commit comments