~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/authentication.cc

  • Committer: Brian Aker
  • Date: 2011-02-17 10:09:00 UTC
  • mfrom: (2173.2.1 clean-include-usuage)
  • Revision ID: brian@tangent.org-20110217100900-4tpuxxzdl1sj00sh
Merge Monty for headers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include "config.h"
22
 
#include "drizzled/plugin/authentication.h"
23
 
#include "drizzled/error.h"
24
 
#include "drizzled/gettext.h"
25
 
#include "drizzled/security_context.h"
 
21
#include <config.h>
 
22
#include <drizzled/plugin/authentication.h>
 
23
#include <drizzled/error.h>
 
24
#include <drizzled/gettext.h>
 
25
#include <drizzled/identifier.h>
26
26
 
27
27
#include <vector>
28
28
 
36
36
{
37
37
  if (auth != NULL)
38
38
    all_authentication.push_back(auth);
 
39
 
39
40
  return false;
40
41
}
41
42
 
49
50
 
50
51
class AuthenticateBy : public std::unary_function<plugin::Authentication *, bool>
51
52
{
52
 
  const SecurityContext &sctx;
 
53
  const identifier::User &sctx;
53
54
  const std::string &password;
 
55
 
54
56
public:
55
 
  AuthenticateBy(const SecurityContext &sctx_arg, const std::string &password_arg) :
 
57
  AuthenticateBy(const identifier::User &sctx_arg, const std::string &password_arg) :
56
58
    std::unary_function<plugin::Authentication *, bool>(),
57
59
    sctx(sctx_arg), password(password_arg) {}
58
60
 
62
64
  }
63
65
};
64
66
 
65
 
bool plugin::Authentication::isAuthenticated(const SecurityContext &sctx,
 
67
bool plugin::Authentication::isAuthenticated(drizzled::identifier::User::const_reference sctx,
66
68
                                             const std::string &password)
67
69
{
68
70
  /* If we never loaded any auth plugins, just return true */
80
82
   */
81
83
  if (iter == all_authentication.end())
82
84
  {
83
 
    my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
84
 
             sctx.getUser().c_str(),
85
 
             sctx.getIp().c_str(),
86
 
             password.empty() ? ER(ER_NO) : ER(ER_YES));
 
85
    error::access(sctx);
 
86
 
87
87
    return false;
88
88
  }
 
89
 
89
90
  return true;
90
91
}
91
92