use of io.cdap.cdap.common.FeatureDisabledException in project cdap by caskdata.
the class AuthorizationClient method doExecuteRequest.
private HttpResponse doExecuteRequest(HttpRequest request, int... additionalAllowedErrorCodes) throws AccessException {
try {
int[] allowedErrorCodes = new int[additionalAllowedErrorCodes.length + 2];
System.arraycopy(additionalAllowedErrorCodes, 0, allowedErrorCodes, 0, additionalAllowedErrorCodes.length);
allowedErrorCodes[additionalAllowedErrorCodes.length] = HttpURLConnection.HTTP_NOT_IMPLEMENTED;
HttpResponse response = restClient.execute(request, config.getAccessToken(), allowedErrorCodes);
if (HttpURLConnection.HTTP_NOT_IMPLEMENTED == response.getResponseCode()) {
FeatureDisabledException.Feature feature = FeatureDisabledException.Feature.AUTHORIZATION;
String enableConfig = Constants.Security.Authorization.ENABLED;
if (response.getResponseBodyAsString().toLowerCase().contains("authentication")) {
feature = FeatureDisabledException.Feature.AUTHENTICATION;
enableConfig = Constants.Security.ENABLED;
}
throw new FeatureDisabledException(feature, FeatureDisabledException.CDAP_SITE, enableConfig, "true");
}
return response;
} catch (IOException e) {
throw new AccessIOException(e);
}
}
Aggregations