SetSecurityPreferenceResult.cc 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2009-2017 Alibaba Cloud All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <alibabacloud/ram/model/SetSecurityPreferenceResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Ram;
  19. using namespace AlibabaCloud::Ram::Model;
  20. SetSecurityPreferenceResult::SetSecurityPreferenceResult() :
  21. ServiceResult()
  22. {}
  23. SetSecurityPreferenceResult::SetSecurityPreferenceResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. SetSecurityPreferenceResult::~SetSecurityPreferenceResult()
  29. {}
  30. void SetSecurityPreferenceResult::parse(const std::string &payload)
  31. {
  32. Json::Reader reader;
  33. Json::Value value;
  34. reader.parse(payload, value);
  35. setRequestId(value["RequestId"].asString());
  36. auto securityPreferenceNode = value["SecurityPreference"];
  37. auto loginProfilePreferenceNode = securityPreferenceNode["LoginProfilePreference"];
  38. if(!loginProfilePreferenceNode["EnableSaveMFATicket"].isNull())
  39. securityPreference_.loginProfilePreference.enableSaveMFATicket = loginProfilePreferenceNode["EnableSaveMFATicket"].asString() == "true";
  40. if(!loginProfilePreferenceNode["AllowUserToChangePassword"].isNull())
  41. securityPreference_.loginProfilePreference.allowUserToChangePassword = loginProfilePreferenceNode["AllowUserToChangePassword"].asString() == "true";
  42. if(!loginProfilePreferenceNode["LoginSessionDuration"].isNull())
  43. securityPreference_.loginProfilePreference.loginSessionDuration = std::stoi(loginProfilePreferenceNode["LoginSessionDuration"].asString());
  44. if(!loginProfilePreferenceNode["LoginNetworkMasks"].isNull())
  45. securityPreference_.loginProfilePreference.loginNetworkMasks = loginProfilePreferenceNode["LoginNetworkMasks"].asString();
  46. auto accessKeyPreferenceNode = securityPreferenceNode["AccessKeyPreference"];
  47. if(!accessKeyPreferenceNode["AllowUserToManageAccessKeys"].isNull())
  48. securityPreference_.accessKeyPreference.allowUserToManageAccessKeys = accessKeyPreferenceNode["AllowUserToManageAccessKeys"].asString() == "true";
  49. auto publicKeyPreferenceNode = securityPreferenceNode["PublicKeyPreference"];
  50. if(!publicKeyPreferenceNode["AllowUserToManagePublicKeys"].isNull())
  51. securityPreference_.publicKeyPreference.allowUserToManagePublicKeys = publicKeyPreferenceNode["AllowUserToManagePublicKeys"].asString() == "true";
  52. auto mFAPreferenceNode = securityPreferenceNode["MFAPreference"];
  53. if(!mFAPreferenceNode["AllowUserToManageMFADevices"].isNull())
  54. securityPreference_.mFAPreference.allowUserToManageMFADevices = mFAPreferenceNode["AllowUserToManageMFADevices"].asString() == "true";
  55. }
  56. SetSecurityPreferenceResult::SecurityPreference SetSecurityPreferenceResult::getSecurityPreference()const
  57. {
  58. return securityPreference_;
  59. }