Commit b5ec86fe authored by ale's avatar ale

replace "using namespace" with explicit imports

parent 772698cb
......@@ -39,7 +39,9 @@
extern "C" module AP_MODULE_DECLARE_DATA sso_module;
using namespace std;
using std::map;
using std::string;
using std::ostringstream;
typedef struct {
const char *login_server;
......
......@@ -38,24 +38,27 @@
struct request_rec;
using std::string;
using std::map;
using std::vector;
namespace modsso {
using namespace std;
typedef map<string, string> params_t;
// sso_utils.cc
void debug(const string& s);
string url_decode(const string& str);
string url_encode(const string& str);
string base64_decode(const string& str);
params_t parse_query_string(const string& str);
void make_cookie_value(string& cookie_value, const string& name,
const string& session_id, const string& path,
int cookie_lifespan);
void set_cookie(request_rec *r, const std::string& cookie_name,
const std::string& value, const std::string& path);
void del_cookie(request_rec *r, const std::string& cookie_name);
vector<string> explode(string s, string e);
}
typedef map<string, string> params_t;
// sso_utils.cc
void debug(const string& s);
string url_decode(const string& str);
string url_encode(const string& str);
string base64_decode(const string& str);
params_t parse_query_string(const string& str);
void make_cookie_value(string& cookie_value, const string& name,
const string& session_id, const string& path,
int cookie_lifespan);
void set_cookie(request_rec *r, const string& cookie_name,
const string& value, const string& path);
void del_cookie(request_rec *r, const string& cookie_name);
vector<string> explode(string s, string e);
} // namespace
......@@ -37,7 +37,7 @@
namespace modsso {
using namespace std;
using std::string;
void debug(const string& s) {
#ifdef DEBUG
......
#include <iostream>
#include <stdlib.h>
#include "../mod_sso.h"
#include <gtest/gtest.h>
#include <string>
#include "../mod_sso.h"
using namespace std;
using std::string;
namespace {
......
......@@ -25,8 +25,6 @@
#include <string.h>
#include "pam_sso.h"
using namespace std;
static const char *kPasswordPrompt = "Password: ";
static void parse_config(pam_sso_config *cfg, int argc, const char **argv)
......
......@@ -25,13 +25,15 @@
*/
#include <iostream>
#include <string>
#include "sso/base64.h"
using std::string;
namespace sso {
static const std::string base64_chars =
static const string base64_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
......@@ -41,14 +43,14 @@ static inline bool is_base64(unsigned char c) {
return (isalnum(c) || (c == '+') || (c == '/'));
}
std::string base64_encode(const std::string& bytes_to_encode) {
std::string ret;
string base64_encode(const string& bytes_to_encode) {
string ret;
int i = 0;
int j = 0;
unsigned char char_array_3[3];
unsigned char char_array_4[4];
for (std::string::const_iterator c = bytes_to_encode.begin();
for (string::const_iterator c = bytes_to_encode.begin();
c != bytes_to_encode.end();
c++) {
char_array_3[i++] = *c;
......@@ -83,13 +85,13 @@ std::string base64_encode(const std::string& bytes_to_encode) {
return ret;
}
std::string base64_decode(const std::string& encoded_string) {
string base64_decode(const string& encoded_string) {
int in_len = encoded_string.size();
int i = 0;
int j = 0;
int in_ = 0;
unsigned char char_array_4[4], char_array_3[3];
std::string ret;
string ret;
while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
char_array_4[i++] = encoded_string[in_]; in_++;
......
......@@ -25,14 +25,12 @@
#include <time.h>
#include <crypto_sign.h>
#include <sstream>
#include <string>
#include "sso/base64.h"
#include "sso/sso.h"
using namespace std;
using namespace sso;
using std::string;
namespace sso {
......
......@@ -31,7 +31,9 @@
#include "sso/sso.h"
using namespace std;
using std::ifstream;
using std::stringstream;
using std::string;
namespace sso {
......
......@@ -32,7 +32,13 @@
#include "sso/sso.h"
using namespace std;
using std::string;
using std::ifstream;
using std::ofstream;
using std::stringstream;
using std::cerr;
using std::cout;
using std::endl;
static void write_to_file(const char *path, const string& contents) {
ofstream out(path, ofstream::out);
......
......@@ -33,9 +33,12 @@
#include <algorithm>
#include <iterator>
namespace sso {
using std::string;
using std::insert_iterator;
using std::inserter;
using std::ostringstream;
using namespace std;
namespace sso {
template<class T>
T string_split(const string& str, char delim) {
......
......@@ -3,7 +3,7 @@
#include <string>
#include "test_common.h"
using namespace std;
using std::string;
namespace {
......
......@@ -3,7 +3,8 @@
#include "base64.h"
#include "sso.h"
using namespace std;
using std::string;
using std::vector;
namespace {
......
......@@ -4,7 +4,8 @@
#include <gtest/gtest.h>
#include "sso.h"
using namespace std;
using std::ofstream;
using std::string;
namespace {
......
......@@ -29,7 +29,9 @@
#include <vector>
#include <gtest/gtest.h>
using namespace std;
using std::string;
using std::vector;
using std::set;
namespace {
......
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <sys/stat.h>
......@@ -7,7 +6,7 @@
#include "sso.h"
#include "test_common.h"
using namespace std;
using std::string;
namespace {
......
......@@ -4,7 +4,8 @@
#include "sso.h"
#include "test_common.h"
using namespace std;
using std::string;
using std::ostringstream;
namespace {
......
......@@ -38,7 +38,9 @@
#define GROUPS_SEP ','
using namespace std;
using std::string;
using std::ostringstream;
using std::vector;
namespace sso {
......@@ -50,7 +52,7 @@ string Ticket::serialize() {
<< service_ << TICKET_SEP
<< domain_ << TICKET_SEP
<< expires_ << TICKET_SEP
<< sso::string_join<groups_t>(groups_.begin(), groups_.end(), GROUPS_SEP);
<< string_join<groups_t>(groups_.begin(), groups_.end(), GROUPS_SEP);
return obuf.str();
}
......@@ -58,16 +60,16 @@ string Ticket::serialize() {
Ticket::Ticket(const string& ticket_string) throw(sso::sso_error)
{
vector<string> parts(
sso::string_split<vector<string> >(ticket_string, TICKET_SEP));
string_split<vector<string> >(ticket_string, TICKET_SEP));
if (parts.size() != 6)
throw sso::sso_error("wrong format");
throw sso_error("wrong format");
if (parts[0] != TICKET_VERSION)
throw sso::sso_error("unsupported ticket version");
throw sso_error("unsupported ticket version");
user_ = parts[1];
service_ = parts[2];
domain_ = parts[3];
expires_ = strtol(parts[4].c_str(), NULL, 0);
groups_ = sso::string_split<groups_t>(parts[5], GROUPS_SEP);
groups_ = string_split<groups_t>(parts[5], GROUPS_SEP);
}
} // namespace sso
......@@ -28,7 +28,6 @@
#include <time.h>
#include <exception>
#include <set>
#include <string>
......
......@@ -22,8 +22,6 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include <iostream>
#include <sstream>
#include <string>
#include <time.h>
......@@ -32,8 +30,9 @@
#include "sso/base64.h"
#include "sso/sso.h"
using namespace std;
using namespace sso;
using std::string;
using std::set_intersection;
using std::insert_iterator;
#define ALLOWED_TIME_SKEW 30
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment