Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use pattern matching
Browse files Browse the repository at this point in the history
Signed-off-by: Tran Ngoc Nhan <[email protected]>
ngocnhan-tran1996 committed Jan 29, 2025
1 parent b529e98 commit 8373336
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -73,8 +73,8 @@ private Map<String, String> createParameters(AuthenticationException authExcepti
if (this.realmName != null) {
parameters.put("realm", this.realmName);
}
if (authException instanceof OAuth2AuthenticationException) {
OAuth2Error error = ((OAuth2AuthenticationException) authException).getError();
if (authException instanceof OAuth2AuthenticationException oAuth2AuthenticationException) {
OAuth2Error error = oAuth2AuthenticationException.getError();
parameters.put("error", error.getErrorCode());
if (StringUtils.hasText(error.getDescription())) {
parameters.put("error_description", error.getDescription());
@@ -92,10 +92,10 @@ private Map<String, String> createParameters(AuthenticationException authExcepti
}

private HttpStatus getStatus(AuthenticationException authException) {
if (authException instanceof OAuth2AuthenticationException) {
OAuth2Error error = ((OAuth2AuthenticationException) authException).getError();
if (error instanceof BearerTokenError) {
return ((BearerTokenError) error).getHttpStatus();
if (authException instanceof OAuth2AuthenticationException oAuth2AuthenticationException) {
OAuth2Error error = oAuth2AuthenticationException.getError();
if (error instanceof BearerTokenError bearerTokenError) {
return bearerTokenError.getHttpStatus();
}
}
return HttpStatus.UNAUTHORIZED;

0 comments on commit 8373336

Please sign in to comment.