~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/authentication.cc

Merged in latest plugin-slot-reorg.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
 
21
21
#include "drizzled/server_includes.h"
22
 
#include "drizzled/service/authentication.h"
 
22
#include "drizzled/plugin/authentication.h"
23
23
#include "drizzled/errmsg_print.h"
24
24
#include "drizzled/plugin/registry.h"
25
 
#include "drizzled/plugin/authentication.h"
26
25
#include "drizzled/gettext.h"
27
26
 
28
27
#include <vector>
29
28
 
30
 
using namespace drizzled;
31
29
using namespace std;
32
30
 
33
 
 
34
 
void service::Authentication::add(plugin::Authentication *auth)
 
31
namespace drizzled
 
32
{
 
33
 
 
34
std::vector<plugin::Authentication *> all_authentication;
 
35
bool are_plugins_loaded= false;
 
36
 
 
37
 
 
38
void plugin::Authentication::add(plugin::Authentication *auth)
35
39
{
36
40
  if (auth != NULL)
37
41
    all_authentication.push_back(auth);
38
42
}
39
43
 
40
 
void service::Authentication::remove(plugin::Authentication *auth)
 
44
void plugin::Authentication::remove(plugin::Authentication *auth)
41
45
{
42
46
  if (auth != NULL)
43
47
    all_authentication.erase(find(all_authentication.begin(),
45
49
                                  auth));
46
50
}
47
51
 
48
 
namespace drizzled
49
 
{
50
 
namespace service
51
 
{
52
 
namespace auth_priv
53
 
{
54
 
 
55
52
class AuthenticateBy : public unary_function<plugin::Authentication *, bool>
56
53
{
57
54
  Session *session;
66
63
    return auth->authenticate(session, password);
67
64
  }
68
65
};
69
 
} /* namespace auth_priv */
70
 
} /* namespace service */
71
 
} /* namespace drizzled */
72
66
 
73
 
bool service::Authentication::authenticate(Session *session, const char *password)
 
67
bool plugin::Authentication::isAuthenticated(Session *session,
 
68
                                             const char *password)
74
69
{
75
70
  /* If we never loaded any auth plugins, just return true */
76
71
  if (are_plugins_loaded != true)
79
74
  /* Use find_if instead of foreach so that we can collect return codes */
80
75
  vector<plugin::Authentication *>::iterator iter=
81
76
    find_if(all_authentication.begin(), all_authentication.end(),
82
 
            service::auth_priv::AuthenticateBy(session, password));
 
77
            AuthenticateBy(session, password));
83
78
  /* If iter is == end() here, that means that all of the plugins returned
84
79
   * false, which in this case means they all succeeded. Since we want to 
85
80
   * return false on success, we return the value of the two being != 
87
82
  return iter != all_authentication.end();
88
83
}
89
84
 
 
85
} /* namespace drizzled */