Skip to content

Commit

Permalink
auth: Update Auth.h to work without using namespace
Browse files Browse the repository at this point in the history
Signed-off-by: Adam C. Emerson <[email protected]>
  • Loading branch information
adamemerson committed Mar 29, 2019
1 parent 510bbe2 commit 3a57bea
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions src/auth/Auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ class Cond;

struct EntityAuth {
CryptoKey key;
map<string, bufferlist> caps;
std::map<std::string, ceph::buffer::list> caps;

void encode(bufferlist& bl) const {
void encode(ceph::buffer::list& bl) const {
__u8 struct_v = 2;
using ceph::encode;
encode(struct_v, bl);
encode((uint64_t)CEPH_AUTH_UID_DEFAULT, bl);
encode(key, bl);
encode(caps, bl);
}
void decode(bufferlist::const_iterator& bl) {
void decode(ceph::buffer::list::const_iterator& bl) {
using ceph::decode;
__u8 struct_v;
decode(struct_v, bl);
Expand All @@ -58,25 +58,25 @@ struct EntityAuth {
};
WRITE_CLASS_ENCODER(EntityAuth)

static inline ostream& operator<<(ostream& out, const EntityAuth& a) {
inline std::ostream& operator<<(std::ostream& out, const EntityAuth& a) {
return out << "auth(key=" << a.key << ")";
}

struct AuthCapsInfo {
bool allow_all;
bufferlist caps;
ceph::buffer::list caps;

AuthCapsInfo() : allow_all(false) {}

void encode(bufferlist& bl) const {
void encode(ceph::buffer::list& bl) const {
using ceph::encode;
__u8 struct_v = 1;
encode(struct_v, bl);
__u8 a = (__u8)allow_all;
encode(a, bl);
encode(caps, bl);
}
void decode(bufferlist::const_iterator& bl) {
void decode(ceph::buffer::list::const_iterator& bl) {
using ceph::decode;
__u8 struct_v;
decode(struct_v, bl);
Expand Down Expand Up @@ -110,7 +110,7 @@ struct AuthTicket {
renew_after += ttl / 2.0;
}

void encode(bufferlist& bl) const {
void encode(ceph::buffer::list& bl) const {
using ceph::encode;
__u8 struct_v = 2;
encode(struct_v, bl);
Expand All @@ -122,7 +122,7 @@ struct AuthTicket {
encode(caps, bl);
encode(flags, bl);
}
void decode(bufferlist::const_iterator& bl) {
void decode(ceph::buffer::list::const_iterator& bl) {
using ceph::decode;
__u8 struct_v;
decode(struct_v, bl);
Expand All @@ -146,14 +146,15 @@ WRITE_CLASS_ENCODER(AuthTicket)
*/
struct AuthAuthorizer {
__u32 protocol;
bufferlist bl;
ceph::buffer::list bl;
CryptoKey session_key;

explicit AuthAuthorizer(__u32 p) : protocol(p) {}
virtual ~AuthAuthorizer() {}
virtual bool verify_reply(bufferlist::const_iterator& reply,
virtual bool verify_reply(ceph::buffer::list::const_iterator& reply,
std::string *connection_secret) = 0;
virtual bool add_challenge(CephContext *cct, const bufferlist& challenge) = 0;
virtual bool add_challenge(CephContext *cct,
const ceph::buffer::list& challenge) = 0;
};

struct AuthAuthorizerChallenge {
Expand Down Expand Up @@ -203,14 +204,14 @@ struct ExpiringCryptoKey {
CryptoKey key;
utime_t expiration;

void encode(bufferlist& bl) const {
void encode(ceph::buffer::list& bl) const {
using ceph::encode;
__u8 struct_v = 1;
encode(struct_v, bl);
encode(key, bl);
encode(expiration, bl);
}
void decode(bufferlist::const_iterator& bl) {
void decode(ceph::buffer::list::const_iterator& bl) {
using ceph::decode;
__u8 struct_v;
decode(struct_v, bl);
Expand All @@ -220,25 +221,25 @@ struct ExpiringCryptoKey {
};
WRITE_CLASS_ENCODER(ExpiringCryptoKey)

static inline ostream& operator<<(ostream& out, const ExpiringCryptoKey& c)
inline std::ostream& operator<<(std::ostream& out, const ExpiringCryptoKey& c)
{
return out << c.key << " expires " << c.expiration;
}

struct RotatingSecrets {
map<uint64_t, ExpiringCryptoKey> secrets;
std::map<uint64_t, ExpiringCryptoKey> secrets;
version_t max_ver;

RotatingSecrets() : max_ver(0) {}
void encode(bufferlist& bl) const {

void encode(ceph::buffer::list& bl) const {
using ceph::encode;
__u8 struct_v = 1;
encode(struct_v, bl);
encode(secrets, bl);
encode(max_ver, bl);
}
void decode(bufferlist::const_iterator& bl) {
void decode(ceph::buffer::list::const_iterator& bl) {
using ceph::decode;
__u8 struct_v;
decode(struct_v, bl);
Expand All @@ -264,12 +265,12 @@ struct RotatingSecrets {
return secrets.begin()->second;
}
ExpiringCryptoKey& current() {
map<uint64_t, ExpiringCryptoKey>::iterator p = secrets.begin();
auto p = secrets.begin();
++p;
return p->second;
}
const ExpiringCryptoKey& current() const {
map<uint64_t, ExpiringCryptoKey>::const_iterator p = secrets.begin();
auto p = secrets.begin();
++p;
return p->second;
}
Expand Down

0 comments on commit 3a57bea

Please sign in to comment.