|
36 | 36 | import java.util.Iterator; |
37 | 37 | import java.util.List; |
38 | 38 | import java.util.Map; |
39 | | -import java.util.Properties; |
40 | 39 | import java.util.Set; |
41 | 40 | import java.util.TimeZone; |
42 | 41 | import java.util.concurrent.ExecutorService; |
@@ -243,6 +242,11 @@ public void handle(HttpRequest request, HttpResponse response, HttpContext conte |
243 | 242 | parameterMap.put(/* name */paramValue[0], /* value */new String[] { paramValue[1] }); |
244 | 243 | } |
245 | 244 | } |
| 245 | + |
| 246 | + // Check responseType, if not among valid types, fallback to XML |
| 247 | + if (!(responseType.equals(BaseCmd.RESPONSE_TYPE_JSON) || responseType.equals(BaseCmd.RESPONSE_TYPE_XML))) |
| 248 | + responseType = BaseCmd.RESPONSE_TYPE_XML; |
| 249 | + |
246 | 250 | try { |
247 | 251 | // always trust commands from API port, user context will always be UID_SYSTEM/ACCOUNT_ID_SYSTEM |
248 | 252 | UserContext.registerContext(_systemUser.getId(), _systemAccount, null, true); |
@@ -769,18 +773,17 @@ public boolean verifyUser(Long userId) { |
769 | 773 | } |
770 | 774 |
|
771 | 775 | private boolean isCommandAvailable(User user, String commandName) { |
772 | | - for(APIAccessChecker apichecker : _apiAccessCheckers) { |
773 | | - // Break on the first adapter that validates |
774 | | - // FIXME: In case of multiple adapters, this may not be the best way of validation. See CLOUDSTACK-618 |
775 | | - if (apichecker.canAccessAPI(user, commandName)) |
776 | | - return true; |
| 776 | + for (APIAccessChecker apiChecker : _apiAccessCheckers) { |
| 777 | + // Fail the checking if any checker fails to verify |
| 778 | + if (!apiChecker.canAccessAPI(user, commandName)) |
| 779 | + return false; |
777 | 780 | } |
778 | | - return false; |
| 781 | + return true; |
779 | 782 | } |
780 | 783 |
|
781 | 784 | private String getCmdClassName(String cmdName) { |
782 | 785 | String cmdClassName = null; |
783 | | - for(APIAccessChecker apiChecker : _apiAccessCheckers){ |
| 786 | + for (APIAccessChecker apiChecker : _apiAccessCheckers){ |
784 | 787 | cmdClassName = apiChecker.getApiCommands().getProperty(cmdName); |
785 | 788 | // Break on the first non-null value |
786 | 789 | if (cmdClassName != null) |
|
0 commit comments