~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/authentication.cc

  • Committer: Monty Taylor
  • Date: 2010-04-22 02:46:23 UTC
  • mto: (1497.3.4 enable-dtrace)
  • mto: This revision was merged to the branch mainline in revision 1527.
  • Revision ID: mordred@inaugust.com-20100422024623-4urw8fi8eraci08p
Don't overwrite the pandora_vc_revinfo file if we don't have new
authoratative information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "config.h"
22
22
#include "drizzled/plugin/authentication.h"
23
23
#include "drizzled/error.h"
 
24
#include "drizzled/plugin/registry.h"
24
25
#include "drizzled/gettext.h"
25
26
#include "drizzled/security_context.h"
26
27
 
27
28
#include <vector>
28
29
 
 
30
using namespace std;
 
31
 
29
32
namespace drizzled
30
33
{
31
34
 
42
45
void plugin::Authentication::removePlugin(plugin::Authentication *auth)
43
46
{
44
47
  if (auth != NULL)
45
 
    all_authentication.erase(std::find(all_authentication.begin(),
46
 
                                       all_authentication.end(),
47
 
                                       auth));
 
48
    all_authentication.erase(find(all_authentication.begin(),
 
49
                                  all_authentication.end(),
 
50
                                  auth));
48
51
}
49
52
 
50
 
class AuthenticateBy : public std::unary_function<plugin::Authentication *, bool>
 
53
class AuthenticateBy : public unary_function<plugin::Authentication *, bool>
51
54
{
52
55
  const SecurityContext &sctx;
53
 
  const std::string &password;
 
56
  const string &password;
54
57
public:
55
 
  AuthenticateBy(const SecurityContext &sctx_arg, const std::string &password_arg) :
56
 
    std::unary_function<plugin::Authentication *, bool>(),
 
58
  AuthenticateBy(const SecurityContext &sctx_arg, const string &password_arg) :
 
59
    unary_function<plugin::Authentication *, bool>(),
57
60
    sctx(sctx_arg), password(password_arg) {}
58
61
 
59
62
  inline result_type operator()(argument_type auth)
63
66
};
64
67
 
65
68
bool plugin::Authentication::isAuthenticated(const SecurityContext &sctx,
66
 
                                             const std::string &password)
 
69
                                             const string &password)
67
70
{
68
71
  /* If we never loaded any auth plugins, just return true */
69
72
  if (all_authentication.empty())
70
73
    return true;
71
74
 
72
75
  /* Use find_if instead of foreach so that we can collect return codes */
73
 
  std::vector<plugin::Authentication *>::iterator iter=
74
 
    std::find_if(all_authentication.begin(), all_authentication.end(),
75
 
                 AuthenticateBy(sctx, password));
 
76
  vector<plugin::Authentication *>::iterator iter=
 
77
    find_if(all_authentication.begin(), all_authentication.end(),
 
78
            AuthenticateBy(sctx, password));
76
79
 
77
80
  /* We only require one plugin to return success in order to authenticate.
78
81
   * If iter is == end() here, that means that all of the plugins returned