void CryptoKey::print(ostream &out) const
{
- char foo[secret.length() * 2];
- int r = ceph_armor(foo, secret.c_str(), secret.c_str() + secret.length());
- foo[r] = 0;
- out << foo;
+ string a;
+ encode_base64(a);
+ out << a;
}
void CryptoKey::to_str(string& s)
secret.c_str(); // make sure it's a single buffer!
}
+ int get_type() const { return type; }
utime_t get_created() const { return created; }
void print(ostream& out) const;
int set_secret(int type, bufferptr& s);
bufferptr& get_secret() { return secret; }
- void encode_base64(string& s) {
+ void encode_base64(string& s) const {
bufferlist bl;
encode(bl);
bufferlist e;
static inline ostream& operator<<(ostream& out, const CryptoKey& k)
{
k.print(out);
- return out << " (" << k.get_created() << ")";
+ return out;
}
p != keys.end();
++p) {
out << p->first << std::endl;
+ out << "\t key: " << p->second.key << std::endl;
out << "\tauid: " << p->second.auid << std::endl;
- out << "\tkey: " << p->second.key << std::endl;
for (map<string, bufferlist>::iterator q = p->second.caps.begin();
q != p->second.caps.end();
if (print_key) {
CryptoKey key;
if (keyring.get_secret(ename, key)) {
- string a;
- key.encode_base64(a);
- cout << a << std::endl;
+ cout << key << std::endl;
} else {
cerr << "entity " << ename << " not found" << std::endl;
}