auth: AuthSupported -> AuthMethodList

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2012-05-22 09:36:54 -07:00
parent 4a0a7e2f4e
commit ec6ecc196e
11 changed files with 29 additions and 28 deletions

View File

@ -1025,7 +1025,7 @@ libcommon_files = \
./ceph_ver.c \
auth/AuthAuthorizeHandler.cc \
auth/AuthClientHandler.cc \
auth/AuthSupported.cc \
auth/AuthMethodList.cc \
auth/cephx/CephxAuthorizeHandler.cc \
auth/cephx/CephxClientHandler.cc \
auth/cephx/CephxProtocol.cc \
@ -1227,7 +1227,7 @@ noinst_HEADERS = \
auth/none/AuthNoneServiceHandler.h\
auth/none/AuthNoneProtocol.h\
auth/Auth.h\
auth/AuthSupported.h\
auth/AuthMethodList.h\
auth/AuthClientHandler.h\
auth/AuthServiceHandler.h\
auth/AuthAuthorizeHandler.h\

View File

@ -16,7 +16,7 @@
#include "AuthAuthorizeHandler.h"
#include "cephx/CephxAuthorizeHandler.h"
#include "none/AuthNoneAuthorizeHandler.h"
#include "AuthSupported.h"
#include "AuthMethodList.h"
#include "common/Mutex.h"
AuthAuthorizeHandler *AuthAuthorizeHandlerRegistry::get_handler(int protocol)

View File

@ -16,7 +16,7 @@
#define CEPH_AUTHAUTHORIZEHANDLER_H
#include "Auth.h"
#include "AuthSupported.h"
#include "AuthMethodList.h"
#include "include/types.h"
class CephContext;
@ -35,11 +35,11 @@ class AuthAuthorizeHandlerRegistry {
Mutex m_lock;
map<int,AuthAuthorizeHandler*> m_authorizers;
CephContext *cct;
AuthSupported supported;
AuthMethodList supported;
public:
AuthAuthorizeHandlerRegistry(CephContext *cct_)
: m_lock("AuthAuthorizeHandlerRegistry::m_lock"), cct(cct_), supported(cct_)
AuthAuthorizeHandlerRegistry(CephContext *cct_, std::string methods)
: m_lock("AuthAuthorizeHandlerRegistry::m_lock"), cct(cct_), supported(cct_, methods)
{}
~AuthAuthorizeHandlerRegistry();

View File

@ -17,14 +17,13 @@
#include "common/debug.h"
#include "include/str_list.h"
#include "AuthSupported.h"
#include "AuthMethodList.h"
const static int dout_subsys = ceph_subsys_auth;
AuthSupported::AuthSupported(CephContext *cct)
AuthMethodList::AuthMethodList(CephContext *cct, string str)
{
string str = cct->_conf->auth_supported;
list<string> sup_list;
get_str_list(str, sup_list);
for (list<string>::iterator iter = sup_list.begin(); iter != sup_list.end(); ++iter) {
@ -38,12 +37,12 @@ AuthSupported::AuthSupported(CephContext *cct)
}
}
bool AuthSupported::is_supported_auth(int auth_type)
bool AuthMethodList::is_supported_auth(int auth_type)
{
return std:find(auth_supported.begin(), auth_supported.end(), auth_type) != auth_supported.end();
return std::find(auth_supported.begin(), auth_supported.end(), auth_type) != auth_supported.end();
}
int AuthSupported::pick(const std::set<__u32>& supported)
int AuthMethodList::pick(const std::set<__u32>& supported)
{
for (set<__u32>::const_reverse_iterator p = supported.rbegin(); p != supported.rend(); ++p)
if (is_supported_auth(*p))

View File

@ -12,18 +12,20 @@
*
*/
#ifndef CEPH_AUTHSUPPORTED_H
#define CEPH_AUTHSUPPORTED_H
#ifndef CEPH_AUTHMETHODLIST_H
#define CEPH_AUTHMETHODLIST_H
#include "include/inttypes.h"
#include <list>
#include <set>
#include <string>
class CephContext;
class AuthSupported {
class AuthMethodList {
std::list<__u32> auth_supported;
public:
AuthSupported(CephContext *cct);
AuthMethodList(CephContext *cct, std::string str);
bool is_supported_auth(int auth_type);
int pick(const std::set<__u32>& supported);

View File

@ -15,7 +15,7 @@
#include "AuthServiceHandler.h"
#include "cephx/CephxServiceHandler.h"
#include "none/AuthNoneServiceHandler.h"
#include "AuthSupported.h"
#include "AuthMethodList.h"
#include "common/config.h"
#define dout_subsys ceph_subsys_auth

View File

@ -17,7 +17,7 @@
#include <memory>
#include <sstream>
#include "auth/AuthSupported.h"
#include "auth/AuthMethodList.h"
#include "auth/Crypto.h"
#include "auth/KeyRing.h"
#include "common/ConfUtils.h"
@ -40,7 +40,7 @@ int KeyRing::from_ceph_context(CephContext *cct, KeyRing **pkeyring)
bool found_key = false;
auto_ptr < KeyRing > keyring(new KeyRing());
AuthSupported supported(cct);
AuthMethodList supported(cct, cct->_conf->auth_supported);
if (!supported.is_supported_auth(CEPH_AUTH_CEPHX)) {
ldout(cct, 2) << "CephX auth is not supported." << dendl;

View File

@ -32,7 +32,7 @@
#include "auth/Auth.h"
#include "auth/KeyRing.h"
#include "auth/AuthSupported.h"
#include "auth/AuthMethodList.h"
#include "include/str_list.h"
#include "include/addr_parsing.h"
@ -276,7 +276,7 @@ int MonClient::init()
// seed rng so we choose a different monitor each time
srand(getpid());
auth_supported = new AuthSupported(cct);
auth_supported = new AuthMethodList(cct, cct->_conf->auth_supported);
ldout(cct, 10) << "auth_supported " << auth_supported->get_supported_set() << dendl;
initialized = true;

View File

@ -38,7 +38,7 @@ class MMonSubscribeAck;
class MAuthReply;
class MAuthRotating;
class LogClient;
class AuthSupported;
class AuthMethodList;
enum MonClientState {
MC_STATE_NONE,
@ -72,7 +72,7 @@ private:
void send_log();
AuthSupported *auth_supported;
AuthMethodList *auth_supported;
bool ms_dispatch(Message *m);
bool ms_handle_reset(Connection *con);

View File

@ -65,7 +65,7 @@
#include "osd/OSDMap.h"
#include "auth/AuthSupported.h"
#include "auth/AuthMethodList.h"
#include "auth/KeyRing.h"
#include "common/config.h"
@ -101,7 +101,7 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorStore *s, Messenger *m, Mo
monmap(map),
clog(cct_, messenger, monmap, LogClient::FLAG_MON),
key_server(cct, &keyring),
auth_supported(cct),
auth_supported(cct, cct->_conf->auth_supported),
store(s),
state(STATE_PROBING),

View File

@ -38,7 +38,7 @@
#include "common/LogClient.h"
#include "auth/cephx/CephxKeyServer.h"
#include "auth/AuthSupported.h"
#include "auth/AuthMethodList.h"
#include "auth/KeyRing.h"
#include "perfglue/heap_profiler.h"
@ -121,7 +121,7 @@ public:
KeyRing keyring;
KeyServer key_server;
AuthSupported auth_supported;
AuthMethodList auth_supported;
CompatSet features;