]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: implement to_str() over auth appliers.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Tue, 19 Apr 2016 17:50:41 +0000 (19:50 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Thu, 2 Jun 2016 13:37:05 +0000 (15:37 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_auth.cc
src/rgw/rgw_auth.h
src/rgw/rgw_auth_decoimpl.h

index 793e998186fbee39d3a1e8bd398ba15c289d2f44..d5d37ffb4e15dbb1148d3d65a9ff75b78df6d1a4 100644 (file)
@@ -53,6 +53,16 @@ rgw_auth_transform_old_authinfo(req_state * const s)
     int get_perm_mask() const {
       return perm_mask;
     }
+
+    std::string to_str() const {
+      std::stringstream ss;
+
+      ss << "RGWDummyIdentityApplier(auth_id=" << id
+         << ", perm_mask=" << perm_mask
+         << ", is_admin=" << is_admin << ")";
+
+      return ss.str();
+    }
   };
 
   return std::unique_ptr<RGWIdentityApplier>(
@@ -127,6 +137,18 @@ bool RGWRemoteAuthApplier::is_owner_of(const rgw_user& uid) const
   return info.acct_user == uid;
 }
 
+std::string RGWRemoteAuthApplier::to_str() const
+{
+  std::stringstream ss;
+
+  ss << "RGWRemoteAuthApplier(acct_user=" << info.acct_user
+     << ", acct_name=" << info.acct_name
+     << ", perm_mask=" << info.perm_mask
+     << ", is_admin=" << info.is_admin << ")";
+
+  return ss.str();
+}
+
 void RGWRemoteAuthApplier::create_account(const rgw_user acct_user,
                                           RGWUserInfo& user_info) const      /* out */
 {
@@ -206,6 +228,19 @@ bool RGWLocalAuthApplier::is_owner_of(const rgw_user& uid) const
   return uid == user_info.user_id;
 }
 
+std::string RGWLocalAuthApplier::to_str() const
+{
+  std::stringstream ss;
+
+  ss << "RGWLocalAuthApplier(acct_user=" << user_info.user_id
+     << ", acct_name=" << user_info.display_name
+     << ", subuser=" << subuser
+     << ", perm_mask=" << get_perm_mask()
+     << ", is_admin=" << user_info.admin << ")";
+
+  return ss.str();
+}
+
 uint32_t RGWLocalAuthApplier::get_perm_mask(const std::string& subuser_name,
                                             const RGWUserInfo &uinfo) const
 {
index 60765d471f60f0052db90ddbce4bb060056bcd8e..f4f7ae6d5d999767b75de81b843a1a09a970a2ea 100644 (file)
@@ -49,11 +49,13 @@ public:
      * the anonymous identity. */
     return is_owner_of(rgw_user(RGW_USER_ANON_ID));
   }
+
+  virtual std::string to_str() const = 0;
 };
 
-inline ostream& operator<<(ostream& out, const RGWIdentityApplier &id) {
-//  return out << id.to_str();
-  return out;
+inline std::ostream& operator<<(std::ostream& out,
+                                const RGWIdentityApplier &id) {
+  return out << id.to_str();
 }
 
 std::unique_ptr<RGWIdentityApplier>
@@ -157,6 +159,7 @@ public:
   virtual bool is_admin_of(const rgw_user& uid) const override;
   virtual bool is_owner_of(const rgw_user& uid) const override;
   virtual int get_perm_mask() const { return info.perm_mask; }
+  virtual std::string to_str() const override;
   virtual void load_acct_info(RGWUserInfo& user_info) const override; /* out */
 
   struct Factory {
@@ -201,6 +204,7 @@ public:
   virtual int get_perm_mask() const override {
     return get_perm_mask(subuser, user_info);
   }
+  virtual std::string to_str() const override;
   virtual void load_acct_info(RGWUserInfo& user_info) const override; /* out */
 
   struct Factory {
index fa734b12f2c402289653b6f4275c322d225febb6..07081746cc4e53eb2205c96f0d11e2d530e01137 100644 (file)
@@ -37,6 +37,10 @@ public:
     return decoratee.get_perm_mask();
   }
 
+  virtual std::string to_str() const override {
+    return decoratee.to_str();
+  }
+
   virtual void load_acct_info(RGWUserInfo& user_info) const override {  /* out */
     return decoratee.load_acct_info(user_info);
   }
@@ -75,6 +79,10 @@ public:
     return decoratee->get_perm_mask();
   }
 
+  virtual std::string to_str() const override {
+    return decoratee->to_str();
+  }
+
   virtual void load_acct_info(RGWUserInfo& user_info) const override {  /* out */
     return decoratee->load_acct_info(user_info);
   }
@@ -102,6 +110,7 @@ public:
       acct_user_override(acct_user_override) {
   }
 
+  virtual std::string to_str() const override;
   virtual void load_acct_info(RGWUserInfo& user_info) const override;   /* out */
 };
 
@@ -109,6 +118,13 @@ public:
 template <typename T>
 const rgw_user RGWThirdPartyAccountAuthApplier<T>::UNKNOWN_ACCT;
 
+template <typename T>
+std::string RGWThirdPartyAccountAuthApplier<T>::to_str() const
+{
+  return "RGWThirdPartyAccountAuthApplier(" + acct_user_override.to_str() + ")"
+         " -> " + RGWDecoratingAuthApplier<T>::to_str();
+}
+
 template <typename T>
 void RGWThirdPartyAccountAuthApplier<T>::load_acct_info(RGWUserInfo& user_info) const
 {