CE-608: updated check for jsonObject when processing API GET request to consider the object being jsonObject.isNull(), added ability to use CUSTOM authorization in an API util override

This commit is contained in:
Tim Chamberlain
2023-08-14 19:37:00 -05:00
parent f2e674ded4
commit d4e18d8f55
2 changed files with 18 additions and 1 deletions

View File

@ -519,7 +519,7 @@ public class BaseAPIActionUtil
{
String wrapperObjectName = getBackendDetails(table).getTableWrapperObjectName();
jsonObject = JsonUtils.toJSONObject(resultString);
if(jsonObject.has(wrapperObjectName))
if(jsonObject.has(wrapperObjectName) && !jsonObject.isNull(wrapperObjectName))
{
Object o = jsonObject.get(wrapperObjectName);
if(o instanceof JSONArray jsonArray)
@ -750,6 +750,10 @@ public class BaseAPIActionUtil
throw (new QException("Error setting authorization query parameter", e));
}
}
case CUSTOM ->
{
handleCustomAuthorization(request);
}
default -> throw new IllegalArgumentException("Unexpected authorization type: " + backendMetaData.getAuthorizationType());
}
}
@ -1398,4 +1402,16 @@ public class BaseAPIActionUtil
///////////////////////////////////////////////////////////////////////////////////////////////////
return (7 * 1024);
}
/*******************************************************************************
**
*******************************************************************************/
protected void handleCustomAuthorization(HttpRequestBase request) throws QException
{
///////////////////////////////////////////////////////////////////////
// nothing to do at this layer, meant to be overridden by subclasses //
///////////////////////////////////////////////////////////////////////
}
}

View File

@ -31,6 +31,7 @@ public enum AuthorizationType
API_TOKEN,
BASIC_AUTH_API_KEY,
BASIC_AUTH_USERNAME_PASSWORD,
CUSTOM,
OAUTH2,
API_KEY_QUERY_PARAM,
}