~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/auth_http/auth_http.cc

doc modifications

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) 2009 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2009 Sun Microsystems
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
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
 
20
#include "config.h"
21
21
 
22
22
#include <curl/curl.h>
23
23
 
25
25
#include <cassert>
26
26
#include <boost/program_options.hpp>
27
27
#include <drizzled/module/option_map.h>
28
 
#include <drizzled/identifier.h>
29
 
#include <drizzled/plugin/authentication.h>
30
 
#include <drizzled/gettext.h>
 
28
#include "drizzled/security_context.h"
 
29
#include "drizzled/plugin/authentication.h"
 
30
#include "drizzled/gettext.h"
31
31
namespace po= boost::program_options;
32
32
using namespace drizzled;
33
33
using namespace std;
73
73
    curl_global_cleanup();
74
74
  }
75
75
 
76
 
  virtual bool authenticate(const identifier::User &sctx, const string &password)
 
76
  virtual bool authenticate(const SecurityContext &sctx, const string &password)
77
77
  {
78
78
    long http_response_code;
79
79
 
80
 
    assert(sctx.username().c_str());
 
80
    assert(sctx.getUser().c_str());
81
81
 
82
82
    // set the parameters: url, username, password
83
83
    rv= curl_easy_setopt(curl_handle, CURLOPT_URL, auth_url.c_str());
84
84
#if defined(HAVE_CURLOPT_USERNAME)
85
85
 
86
86
    rv= curl_easy_setopt(curl_handle, CURLOPT_USERNAME,
87
 
                         sctx.username().c_str());
 
87
                         sctx.getUser().c_str());
88
88
    rv= curl_easy_setopt(curl_handle, CURLOPT_PASSWORD, password.c_str());
89
89
 
90
90
#else
91
91
 
92
 
    string userpwd(sctx.username());
 
92
    string userpwd(sctx.getUser());
93
93
    userpwd.append(":");
94
94
    userpwd.append(password);
95
95
    rv= curl_easy_setopt(curl_handle, CURLOPT_USERPWD, userpwd.c_str());
131
131
  const string auth_url(vm["url"].as<string>());
132
132
  if (auth_url.size() == 0)
133
133
  {
134
 
    errmsg_printf(error::ERROR,
 
134
    errmsg_printf(ERRMSG_LVL_ERROR,
135
135
                  _("auth_http plugin loaded but required option url not "
136
136
                    "specified. Against which URL are you intending on "
137
137
                    "authenticating?\n"));