@@ -4341,14 +4341,19 @@ private Response handleApiBasedAuthenticationResponse(OAuthMessage oAuthMessage,
4341
4341
ObjectMapper objectMapper = new ObjectMapper ();
4342
4342
objectMapper .setSerializationInclusion (JsonInclude .Include .NON_EMPTY );
4343
4343
String jsonString = objectMapper .writeValueAsString (authResponse );
4344
+ oAuthMessage .getRequest ().setAttribute (IS_API_BASED_AUTH_HANDLED , true );
4344
4345
return Response .ok ().entity (jsonString ).build ();
4345
4346
4346
4347
} else {
4347
- String location = oauthResponse .getMetadata ().get ("Location" ).get (0 ).toString ();
4348
- if (StringUtils .isNotBlank (location )) {
4349
- Map <String , String > queryParams = getQueryParamsFromUrl (location );
4350
- String jsonPayload = new Gson ().toJson (queryParams );
4351
- return Response .status (HttpServletResponse .SC_OK ).entity (jsonPayload ).build ();
4348
+ List <Object > locationHeader = oauthResponse .getMetadata ().get ("Location" );
4349
+ if (CollectionUtils .isNotEmpty (locationHeader )) {
4350
+ String location = locationHeader .get (0 ).toString ();
4351
+ if (StringUtils .isNotBlank (location )) {
4352
+ Map <String , String > queryParams = getQueryParamsFromUrl (location );
4353
+ String jsonPayload = new Gson ().toJson (queryParams );
4354
+ oAuthMessage .getRequest ().setAttribute (IS_API_BASED_AUTH_HANDLED , true );
4355
+ return Response .status (HttpServletResponse .SC_OK ).entity (jsonPayload ).build ();
4356
+ }
4352
4357
}
4353
4358
}
4354
4359
} catch (AuthServiceException | JsonProcessingException | UnsupportedEncodingException | URISyntaxException e ) {
@@ -4357,6 +4362,7 @@ private Response handleApiBasedAuthenticationResponse(OAuthMessage oAuthMessage,
4357
4362
params .put (OAuthConstants .OAUTH_ERROR , OAuth2ErrorCodes .SERVER_ERROR );
4358
4363
params .put (OAuthConstants .OAUTH_ERROR_DESCRIPTION , "Server error occurred while performing authorization." );
4359
4364
String jsonString = new Gson ().toJson (params );
4365
+ oAuthMessage .getRequest ().setAttribute (IS_API_BASED_AUTH_HANDLED , true );
4360
4366
return Response .status (HttpServletResponse .SC_INTERNAL_SERVER_ERROR ).entity (jsonString ).build ();
4361
4367
}
4362
4368
0 commit comments