From fe30ac6ca333da8d85b4f4fefa3d51473cf3eee8 Mon Sep 17 00:00:00 2001 From: Christophe Courtaut Date: Tue, 9 Jul 2013 23:32:33 +0200 Subject: [PATCH] rgw: Use JSONFormatter to use keystone API Signed-off-by: Christophe Courtaut --- src/rgw/rgw_swift.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/rgw/rgw_swift.cc b/src/rgw/rgw_swift.cc index 00af259a856..89b86fdfe8f 100644 --- a/src/rgw/rgw_swift.cc +++ b/src/rgw/rgw_swift.cc @@ -252,15 +252,17 @@ int RGWSwift::get_keystone_admin_token(std::string& token) KeystoneToken t; bufferlist token_bl; RGWGetKeystoneAdminToken token_req(cct, &token_bl); - std::ostringstream os; - os << "{ \"auth\":{ \"passwordCredentials\":{ \"username\":\""; - os << cct->_conf->rgw_keystone_admin_user; - os << "\", \"password\":\""; - os << cct->_conf->rgw_keystone_admin_password; - os << "\"}, \"tenantName\":\""; - os << cct->_conf->rgw_keystone_admin_tenant; - os << "\"}}"; - token_req.set_post_data(os.str()); + JSONFormatter jf; + jf.open_object_section("auth"); + jf.open_object_section("passwordCredentials"); + encode_json("username", cct->_conf->rgw_keystone_admin_user, &jf); + encode_json("password", cct->_conf->rgw_keystone_admin_password, &jf); + jf.close_section(); + encode_json("tenantName", cct->_conf->rgw_keystone_admin_tenant, &jf); + jf.close_section(); + std::stringstream ss; + jf.flush(ss); + token_req.set_post_data(ss.str()); int ret = token_req.process(token_url.c_str()); if (ret < 0) return ret; -- 2.47.3