~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/authentication.cc

  • Committer: Andrew Hutchings
  • Date: 2011-02-01 10:23:22 UTC
  • mto: (2136.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2137.
  • Revision ID: andrew@linuxjedi.co.uk-20110201102322-oxztcyrjzg3c7yta
Fix counters cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
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/identifier.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
 
64
64
  }
65
65
};
66
66
 
67
 
bool plugin::Authentication::isAuthenticated(const drizzled::identifier::User& sctx,
 
67
bool plugin::Authentication::isAuthenticated(drizzled::identifier::User::const_shared_ptr sctx,
68
68
                                             const std::string &password)
69
69
{
 
70
  /* If we never loaded any auth plugins, just return true */
 
71
  if (all_authentication.empty())
 
72
    return true;
 
73
 
70
74
  /* Use find_if instead of foreach so that we can collect return codes */
71
75
  std::vector<plugin::Authentication *>::iterator iter=
72
76
    std::find_if(all_authentication.begin(), all_authentication.end(),
73
 
                 AuthenticateBy(sctx, password));
 
77
                 AuthenticateBy(*sctx, password));
74
78
 
75
79
  /* We only require one plugin to return success in order to authenticate.
76
80
   * If iter is == end() here, that means that all of the plugins returned
78
82
   */
79
83
  if (iter == all_authentication.end())
80
84
  {
81
 
    error::access(sctx);
 
85
    my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
 
86
             sctx->username().c_str(),
 
87
             sctx->address().c_str(),
 
88
             password.empty() ? ER(ER_NO) : ER(ER_YES));
82
89
 
83
90
    return false;
84
91
  }