]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: change naming of utility functions in rgw_keystone.cc. 7630/head
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Fri, 26 Feb 2016 21:17:09 +0000 (22:17 +0100)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Fri, 26 Feb 2016 21:20:03 +0000 (22:20 +0100)
Slightly improve code formatting and const-correctness as well.

Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_keystone.cc
src/rgw/rgw_keystone.h
src/rgw/rgw_swift.cc

index 7d7860506952c2c3de2c11072de1606208e8fa41..fb2075a265ba9d073169069e04e426efeb174308 100644 (file)
@@ -16,7 +16,7 @@
 
 #define dout_subsys ceph_subsys_rgw
 
-int open_cms_envelope(CephContext *cct, string& src, string& dst)
+int rgw_open_cms_envelope(CephContext * const cct, string& src, string& dst)
 {
 #define BEGIN_CMS "-----BEGIN CMS-----"
 #define END_CMS "-----END CMS-----"
@@ -52,7 +52,9 @@ int open_cms_envelope(CephContext *cct, string& src, string& dst)
   return 0;
 }
 
-int decode_b64_cms(CephContext *cct, const string& signed_b64, bufferlist& bl)
+int rgw_decode_b64_cms(CephContext * const cct,
+                       const string& signed_b64,
+                       bufferlist& bl)
 {
   bufferptr signed_ber(signed_b64.size() * 2);
   char *dest = signed_ber.c_str();
@@ -60,13 +62,17 @@ int decode_b64_cms(CephContext *cct, const string& signed_b64, bufferlist& bl)
   size_t len = signed_b64.size();
   char buf[len + 1];
   buf[len] = '\0';
+
   for (size_t i = 0; i < len; i++, src++) {
-    if (*src != '-')
+    if (*src != '-') {
       buf[i] = *src;
-    else
+    } else {
       buf[i] = '/';
+    }
   }
-  int ret = ceph_unarmor(dest, dest + signed_ber.length(), buf, buf + signed_b64.size());
+
+  int ret = ceph_unarmor(dest, dest + signed_ber.length(), buf,
+                         buf + signed_b64.size());
   if (ret < 0) {
     ldout(cct, 0) << "ceph_unarmor() failed, ret=" << ret << dendl;
     return ret;
@@ -86,14 +92,14 @@ int decode_b64_cms(CephContext *cct, const string& signed_b64, bufferlist& bl)
 
 #define PKI_ANS1_PREFIX "MII"
 
-bool is_pki_token(const string& token)
+bool rgw_is_pki_token(const string& token)
 {
   return token.compare(0, sizeof(PKI_ANS1_PREFIX) - 1, PKI_ANS1_PREFIX) == 0;
 }
 
-void get_token_id(const string& token, string& token_id)
+void rgw_get_token_id(const string& token, string& token_id)
 {
-  if (!is_pki_token(token)) {
+  if (!rgw_is_pki_token(token)) {
     token_id = token;
     return;
   }
@@ -104,20 +110,23 @@ void get_token_id(const string& token, string& token_id)
   hash.Update((const byte *)token.c_str(), token.size());
   hash.Final(m);
 
-
   char calc_md5[CEPH_CRYPTO_MD5_DIGESTSIZE * 2 + 1];
   buf_to_hex(m, CEPH_CRYPTO_MD5_DIGESTSIZE, calc_md5);
   token_id = calc_md5;
 }
 
-bool decode_pki_token(CephContext *cct, const string& token, bufferlist& bl)
+bool rgw_decode_pki_token(CephContext * const cct,
+                          const string& token,
+                          bufferlist& bl)
 {
-  if (!is_pki_token(token))
+  if (!rgw_is_pki_token(token)) {
     return false;
+  }
 
-  int ret = decode_b64_cms(cct, token, bl);
-  if (ret < 0)
+  int ret = rgw_decode_b64_cms(cct, token, bl);
+  if (ret < 0) {
     return false;
+  }
 
   ldout(cct, 20) << "successfully decoded pki token" << dendl;
 
@@ -259,7 +268,7 @@ void RGWKeystoneTokenCache::add_admin(const KeystoneToken& token)
 {
   Mutex::Locker l(lock);
 
-  get_token_id(token.token.id, admin_token_id);
+  rgw_get_token_id(token.token.id, admin_token_id);
   add(admin_token_id, token);
 }
 
index 40a75ee744ebe5bf2f3e94ea0bce3b9f5302d179..ffbae9008b7624b327dfcb90917626c844751b7d 100644 (file)
@@ -6,11 +6,15 @@
 
 #include "rgw_common.h"
 
-int open_cms_envelope(CephContext *cct, string& src, string& dst);
-int decode_b64_cms(CephContext *cct, const string& signed_b64, bufferlist& bl);
-bool is_pki_token(const string& token);
-void get_token_id(const string& token, string& token_id);
-bool decode_pki_token(CephContext *cct, const string& token, bufferlist& bl);
+int rgw_open_cms_envelope(CephContext *cct, string& src, string& dst);
+int rgw_decode_b64_cms(CephContext *cct,
+                       const string& signed_b64,
+                       bufferlist& bl);
+bool rgw_is_pki_token(const string& token);
+void rgw_get_token_id(const string& token, string& token_id);
+bool rgw_decode_pki_token(CephContext *cct,
+                          const string& token,
+                          bufferlist& bl);
 
 enum class KeystoneApiVersion {
   VER_2,
index aa916ed722b3d78a8c9903e5ade6b848a194e30e..627fb3eb587d0cff274b7d4258516897684a64e7 100644 (file)
@@ -323,14 +323,14 @@ int RGWSwift::check_revoked()
   ldout(cct, 10) << "signed=" << signed_str << dendl;
 
   string signed_b64;
-  ret = open_cms_envelope(cct, signed_str, signed_b64);
+  ret = rgw_open_cms_envelope(cct, signed_str, signed_b64);
   if (ret < 0)
     return ret;
 
   ldout(cct, 10) << "content=" << signed_b64 << dendl;
   
   bufferlist json;
-  ret = decode_b64_cms(cct, signed_b64, json);
+  ret = rgw_decode_b64_cms(cct, signed_b64, json);
   if (ret < 0) {
     return ret;
   }
@@ -430,7 +430,7 @@ int RGWSwift::validate_keystone_token(RGWRados *store, const string& token, stru
   KeystoneToken t;
 
   string token_id;
-  get_token_id(token, token_id);
+  rgw_get_token_id(token, token_id);
 
   ldout(cct, 20) << "token_id=" << token_id << dendl;
 
@@ -450,7 +450,7 @@ int RGWSwift::validate_keystone_token(RGWRados *store, const string& token, stru
   bufferlist bl;
 
   /* check if that's a self signed token that we can decode */
-  if (!decode_pki_token(cct, token, bl)) {
+  if (!rgw_decode_pki_token(cct, token, bl)) {
 
     /* can't decode, just go to the keystone server for validation */