|
53 | 53 | import javax.servlet.http.HttpServletResponse; |
54 | 54 | import javax.servlet.http.HttpSession; |
55 | 55 |
|
| 56 | +import org.apache.commons.codec.binary.Base64; |
| 57 | +import org.apache.http.ConnectionClosedException; |
| 58 | +import org.apache.http.HttpException; |
| 59 | +import org.apache.http.HttpRequest; |
| 60 | +import org.apache.http.HttpResponse; |
| 61 | +import org.apache.http.HttpServerConnection; |
| 62 | +import org.apache.http.HttpStatus; |
| 63 | +import org.apache.http.NameValuePair; |
| 64 | +import org.apache.http.client.utils.URLEncodedUtils; |
| 65 | +import org.apache.http.entity.BasicHttpEntity; |
| 66 | +import org.apache.http.impl.DefaultHttpResponseFactory; |
| 67 | +import org.apache.http.impl.DefaultHttpServerConnection; |
| 68 | +import org.apache.http.impl.NoConnectionReuseStrategy; |
| 69 | +import org.apache.http.impl.SocketHttpServerConnection; |
| 70 | +import org.apache.http.params.BasicHttpParams; |
| 71 | +import org.apache.http.params.CoreConnectionPNames; |
| 72 | +import org.apache.http.params.CoreProtocolPNames; |
| 73 | +import org.apache.http.params.HttpParams; |
| 74 | +import org.apache.http.protocol.BasicHttpContext; |
| 75 | +import org.apache.http.protocol.BasicHttpProcessor; |
| 76 | +import org.apache.http.protocol.HttpContext; |
| 77 | +import org.apache.http.protocol.HttpRequestHandler; |
| 78 | +import org.apache.http.protocol.HttpRequestHandlerRegistry; |
| 79 | +import org.apache.http.protocol.HttpService; |
| 80 | +import org.apache.http.protocol.ResponseConnControl; |
| 81 | +import org.apache.http.protocol.ResponseContent; |
| 82 | +import org.apache.http.protocol.ResponseDate; |
| 83 | +import org.apache.http.protocol.ResponseServer; |
| 84 | +import org.apache.log4j.Logger; |
| 85 | +import org.springframework.stereotype.Component; |
| 86 | + |
56 | 87 | import org.apache.cloudstack.acl.APIChecker; |
57 | 88 | import org.apache.cloudstack.api.APICommand; |
58 | 89 | import org.apache.cloudstack.api.ApiErrorCode; |
|
90 | 121 | import org.apache.cloudstack.framework.jobs.AsyncJobManager; |
91 | 122 | import org.apache.cloudstack.framework.jobs.impl.AsyncJobVO; |
92 | 123 | import org.apache.cloudstack.managed.context.ManagedContextRunnable; |
93 | | -import org.apache.commons.codec.binary.Base64; |
94 | | -import org.apache.http.ConnectionClosedException; |
95 | | -import org.apache.http.HttpException; |
96 | | -import org.apache.http.HttpRequest; |
97 | | -import org.apache.http.HttpResponse; |
98 | | -import org.apache.http.HttpServerConnection; |
99 | | -import org.apache.http.HttpStatus; |
100 | | -import org.apache.http.NameValuePair; |
101 | | -import org.apache.http.client.utils.URLEncodedUtils; |
102 | | -import org.apache.http.entity.BasicHttpEntity; |
103 | | -import org.apache.http.impl.DefaultHttpResponseFactory; |
104 | | -import org.apache.http.impl.DefaultHttpServerConnection; |
105 | | -import org.apache.http.impl.NoConnectionReuseStrategy; |
106 | | -import org.apache.http.impl.SocketHttpServerConnection; |
107 | | -import org.apache.http.params.BasicHttpParams; |
108 | | -import org.apache.http.params.CoreConnectionPNames; |
109 | | -import org.apache.http.params.CoreProtocolPNames; |
110 | | -import org.apache.http.params.HttpParams; |
111 | | -import org.apache.http.protocol.BasicHttpContext; |
112 | | -import org.apache.http.protocol.BasicHttpProcessor; |
113 | | -import org.apache.http.protocol.HttpContext; |
114 | | -import org.apache.http.protocol.HttpRequestHandler; |
115 | | -import org.apache.http.protocol.HttpRequestHandlerRegistry; |
116 | | -import org.apache.http.protocol.HttpService; |
117 | | -import org.apache.http.protocol.ResponseConnControl; |
118 | | -import org.apache.http.protocol.ResponseContent; |
119 | | -import org.apache.http.protocol.ResponseDate; |
120 | | -import org.apache.http.protocol.ResponseServer; |
121 | | -import org.apache.log4j.Logger; |
122 | | -import org.springframework.stereotype.Component; |
123 | 124 |
|
124 | 125 | import com.cloud.api.response.ApiResponseSerializer; |
125 | 126 | import com.cloud.configuration.Config; |
@@ -625,14 +626,12 @@ public boolean verifyRequest(Map<String, Object[]> requestParameters, Long userI |
625 | 626 | if (userId != null) { |
626 | 627 | User user = ApiDBUtils.findUserById(userId); |
627 | 628 |
|
628 | | - try{ |
| 629 | + try { |
629 | 630 | checkCommandAvailable(user, commandName); |
630 | | - } |
631 | | - catch (RequestLimitException ex){ |
| 631 | + } catch (RequestLimitException ex) { |
632 | 632 | s_logger.debug(ex.getMessage()); |
633 | 633 | throw new ServerApiException(ApiErrorCode.API_LIMIT_EXCEED, ex.getMessage()); |
634 | | - } |
635 | | - catch (PermissionDeniedException ex){ |
| 634 | + } catch (PermissionDeniedException ex) { |
636 | 635 | s_logger.debug("The given command:" + commandName + " does not exist or it is not available for user with id:" + userId); |
637 | 636 | throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "The given command does not exist or it is not available for user"); |
638 | 637 | } |
@@ -730,12 +729,15 @@ else if ("signatureversion".equalsIgnoreCase(paramName)) { |
730 | 729 | return false; |
731 | 730 | } |
732 | 731 |
|
733 | | - try{ |
| 732 | + try { |
734 | 733 | checkCommandAvailable(user, commandName); |
735 | | - } |
736 | | - catch (PermissionDeniedException ex){ |
| 734 | + } catch (RequestLimitException ex) { |
| 735 | + s_logger.debug(ex.getMessage()); |
| 736 | + throw new ServerApiException(ApiErrorCode.API_LIMIT_EXCEED, ex.getMessage()); |
| 737 | + } catch (PermissionDeniedException ex) { |
737 | 738 | s_logger.debug("The given command:" + commandName + " does not exist or it is not available for user"); |
738 | | - throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "The given command:" + commandName + " does not exist or it is not available for user with id:" + userId); |
| 739 | + throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "The given command:" + commandName + " does not exist or it is not available for user with id:" |
| 740 | + + userId); |
739 | 741 | } |
740 | 742 |
|
741 | 743 | // verify secret key exists |
|
0 commit comments