~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/authentication.cc

Refactor

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(drizzled::identifier::User::const_shared_ptr sctx,
 
67
bool plugin::Authentication::isAuthenticated(const drizzled::identifier::User& 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
 
 
74
70
  /* Use find_if instead of foreach so that we can collect return codes */
75
71
  std::vector<plugin::Authentication *>::iterator iter=
76
72
    std::find_if(all_authentication.begin(), all_authentication.end(),
77
 
                 AuthenticateBy(*sctx, password));
 
73
                 AuthenticateBy(sctx, password));
78
74
 
79
75
  /* We only require one plugin to return success in order to authenticate.
80
76
   * If iter is == end() here, that means that all of the plugins returned
82
78
   */
83
79
  if (iter == all_authentication.end())
84
80
  {
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));
 
81
    error::access(sctx);
89
82
 
90
83
    return false;
91
84
  }