GetVerifyTokenResult.cc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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/cloudauth/model/GetVerifyTokenResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Cloudauth;
  19. using namespace AlibabaCloud::Cloudauth::Model;
  20. GetVerifyTokenResult::GetVerifyTokenResult() :
  21. ServiceResult()
  22. {}
  23. GetVerifyTokenResult::GetVerifyTokenResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetVerifyTokenResult::~GetVerifyTokenResult()
  29. {}
  30. void GetVerifyTokenResult::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 dataNode = value["Data"];
  37. if(!dataNode["CloudauthPageUrl"].isNull())
  38. data_.cloudauthPageUrl = dataNode["CloudauthPageUrl"].asString();
  39. auto verifyTokenNode = dataNode["VerifyToken"];
  40. if(!verifyTokenNode["Token"].isNull())
  41. data_.verifyToken.token = verifyTokenNode["Token"].asString();
  42. if(!verifyTokenNode["DurationSeconds"].isNull())
  43. data_.verifyToken.durationSeconds = std::stoi(verifyTokenNode["DurationSeconds"].asString());
  44. auto stsTokenNode = dataNode["StsToken"];
  45. if(!stsTokenNode["AccessKeyId"].isNull())
  46. data_.stsToken.accessKeyId = stsTokenNode["AccessKeyId"].asString();
  47. if(!stsTokenNode["AccessKeySecret"].isNull())
  48. data_.stsToken.accessKeySecret = stsTokenNode["AccessKeySecret"].asString();
  49. if(!stsTokenNode["Expiration"].isNull())
  50. data_.stsToken.expiration = stsTokenNode["Expiration"].asString();
  51. if(!stsTokenNode["EndPoint"].isNull())
  52. data_.stsToken.endPoint = stsTokenNode["EndPoint"].asString();
  53. if(!stsTokenNode["BucketName"].isNull())
  54. data_.stsToken.bucketName = stsTokenNode["BucketName"].asString();
  55. if(!stsTokenNode["Path"].isNull())
  56. data_.stsToken.path = stsTokenNode["Path"].asString();
  57. if(!stsTokenNode["Token"].isNull())
  58. data_.stsToken.token = stsTokenNode["Token"].asString();
  59. if(!value["Success"].isNull())
  60. success_ = value["Success"].asString() == "true";
  61. if(!value["Code"].isNull())
  62. code_ = value["Code"].asString();
  63. if(!value["Message"].isNull())
  64. message_ = value["Message"].asString();
  65. }
  66. std::string GetVerifyTokenResult::getMessage()const
  67. {
  68. return message_;
  69. }
  70. GetVerifyTokenResult::Data GetVerifyTokenResult::getData()const
  71. {
  72. return data_;
  73. }
  74. std::string GetVerifyTokenResult::getCode()const
  75. {
  76. return code_;
  77. }
  78. bool GetVerifyTokenResult::getSuccess()const
  79. {
  80. return success_;
  81. }