Skip to content

Commit

Permalink
[MNT-24542] fix class cast exception
Browse files Browse the repository at this point in the history
  • Loading branch information
code4uuuu committed Dec 16, 2024
1 parent f731c97 commit 2de85e6
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

import com.nimbusds.oauth2.sdk.ParseException;
import com.nimbusds.oauth2.sdk.token.BearerAccessToken;
import com.nimbusds.openid.connect.sdk.UserInfoErrorResponse;
import com.nimbusds.openid.connect.sdk.UserInfoRequest;
import com.nimbusds.openid.connect.sdk.UserInfoResponse;
import com.nimbusds.openid.connect.sdk.UserInfoSuccessResponse;
Expand Down Expand Up @@ -143,7 +144,18 @@ public Optional<OIDCUserInfo> getUserInfo(String tokenParameter, String principa
.flatMap(httpResponse -> {
try
{
return Optional.of(UserInfoResponse.parse(httpResponse));
UserInfoResponse userInfoResponse = UserInfoResponse.parse(httpResponse);
if (userInfoResponse instanceof UserInfoErrorResponse)
{
UserInfoErrorResponse userInfoErrorResponse = (UserInfoErrorResponse) userInfoResponse;
String errorMessage = userInfoErrorResponse.getErrorObject().getDescription();
LOGGER.warn("User Info Request failed: " + errorMessage);
throw new UserInfoException(errorMessage);
}
else
{
return Optional.of(userInfoResponse);
}
}
catch (ParseException e)
{
Expand Down

0 comments on commit 2de85e6

Please sign in to comment.