~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to src/auth/KeyRing.h

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-07-16 09:56:24 UTC
  • mfrom: (0.3.11)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: package-import@ubuntu.com-20120716095624-azr2w4hbhei1rxmx
Tags: upstream-0.48
ImportĀ upstreamĀ versionĀ 0.48

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
class md_config_t;
24
24
 
25
 
class KeyRing {
 
25
class KeyRing : public KeyStore {
26
26
  map<EntityName, EntityAuth> keys;
27
27
 
28
28
  int set_modifier(const char *type, const char *val, EntityName& name, map<string, bufferlist>& caps);
54
54
    secret = k->second.key;
55
55
    return true;
56
56
  }
 
57
  bool get_service_secret(uint32_t service_id, uint64_t secret_id,
 
58
                          CryptoKey& secret) const {
 
59
    return false;
 
60
  }
 
61
  bool get_caps(const EntityName& name,
 
62
                const std::string& type, AuthCapsInfo& caps) const {
 
63
    map<EntityName, EntityAuth>::const_iterator k = keys.find(name);
 
64
    if (k == keys.end())
 
65
      return false;
 
66
    map<string,bufferlist>::const_iterator i = k->second.caps.find(type);
 
67
    if (i != k->second.caps.end()) {
 
68
      caps.caps = i->second;
 
69
    }
 
70
    return true;
 
71
  }
57
72
 
58
73
  // modifiers
59
74
  void add(const EntityName& name, EntityAuth &a) {
60
75
    keys[name] = a;
61
76
  }
 
77
  void add(const EntityName& name, CryptoKey &k) {
 
78
    EntityAuth a;
 
79
    a.key = k;
 
80
    keys[name] = a;
 
81
  }
 
82
  void remove(const EntityName& name) {
 
83
    keys.erase(name);
 
84
  }
62
85
  void set_caps(EntityName& name, map<string, bufferlist>& caps) {
63
86
    keys[name].caps = caps;
64
87
  }
71
94
  void import(CephContext *cct, KeyRing& other);
72
95
 
73
96
  // encoders
74
 
  void encode(bufferlist& bl) const {
75
 
    __u8 struct_v = 1;
76
 
    ::encode(struct_v, bl);
77
 
    ::encode(keys, bl);
78
 
  }
79
97
  void decode(bufferlist::iterator& bl);
80
98
 
81
99
  void encode_plaintext(bufferlist& bl);
82
100
};
83
 
WRITE_CLASS_ENCODER(KeyRing)
 
101
 
 
102
// don't use WRITE_CLASS_ENCODER macro because we don't have an encode
 
103
// macro.  don't juse encode_plaintext in that case because it is not
 
104
// wrappable; it assumes it gets the entire bufferlist.
 
105
static inline void decode(KeyRing& kr, bufferlist::iterator& p) {
 
106
  kr.decode(p);
 
107
}
84
108
 
85
109
#endif