aboutsummaryrefslogtreecommitdiffstats
path: root/src/medsrv/controller
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2009-09-04 13:46:09 +0200
committerMartin Willi <martin@strongswan.org>2009-09-04 13:46:09 +0200
commit7daf5226b74e14a6e0f1a888b0be26f3d246f9f8 (patch)
tree6436de2e84e7a677ecfb83db4bf44766cc273d9f /src/medsrv/controller
parent7d1b0304467bc668b592ccd6680fd9615efbb5b2 (diff)
downloadstrongswan-7daf5226b74e14a6e0f1a888b0be26f3d246f9f8.tar.bz2
strongswan-7daf5226b74e14a6e0f1a888b0be26f3d246f9f8.tar.xz
removed trailing spaces ([[:space:]]+$)
Diffstat (limited to 'src/medsrv/controller')
-rwxr-xr-xsrc/medsrv/controller/peer_controller.c32
-rwxr-xr-xsrc/medsrv/controller/user_controller.c26
2 files changed, 29 insertions, 29 deletions
diff --git a/src/medsrv/controller/peer_controller.c b/src/medsrv/controller/peer_controller.c
index 06c67901f..e1e4661e0 100755
--- a/src/medsrv/controller/peer_controller.c
+++ b/src/medsrv/controller/peer_controller.c
@@ -42,8 +42,8 @@ struct private_peer_controller_t {
* active user session
*/
user_t *user;
-
- /**
+
+ /**
* underlying database
*/
database_t *db;
@@ -55,19 +55,19 @@ struct private_peer_controller_t {
static void list(private_peer_controller_t *this, request_t *request)
{
enumerator_t *query;
-
+
query = this->db->query(this->db,
"SELECT id, alias, keyid FROM peer WHERE user = ? ORDER BY alias",
DB_UINT, this->user->get_user(this->user),
DB_UINT, DB_TEXT, DB_BLOB);
-
+
if (query)
{
u_int id;
char *alias;
chunk_t keyid;
identification_t *identifier;
-
+
while (query->enumerate(query, &id, &alias, &keyid))
{
request->setf(request, "peers.%d.alias=%s", id, alias);
@@ -89,7 +89,7 @@ static bool verify_alias(private_peer_controller_t *this, request_t *request,
if (!alias || *alias == '\0')
{
request->setf(request, "error=Alias is missing.");
- return FALSE;
+ return FALSE;
}
while (*alias != '\0')
{
@@ -122,7 +122,7 @@ static bool parse_public_key(private_peer_controller_t *this,
{
public_key_t *public;
chunk_t blob, id;
-
+
if (!public_key || *public_key == '\0')
{
request->setf(request, "error=Public key is missing.");
@@ -156,7 +156,7 @@ static bool parse_public_key(private_peer_controller_t *this,
static void add(private_peer_controller_t *this, request_t *request)
{
char *alias = "", *public_key = "";
-
+
if (request->get_query_data(request, "back"))
{
return request->redirect(request, "peer/list");
@@ -164,10 +164,10 @@ static void add(private_peer_controller_t *this, request_t *request)
while (request->get_query_data(request, "add"))
{
chunk_t encoding, keyid;
-
+
alias = request->get_query_data(request, "alias");
public_key = request->get_query_data(request, "public_key");
-
+
if (!verify_alias(this, request, alias))
{
break;
@@ -194,7 +194,7 @@ static void add(private_peer_controller_t *this, request_t *request)
}
request->set(request, "alias", alias);
request->set(request, "public_key", public_key);
-
+
return request->render(request, "templates/peer/add.cs");
}
@@ -209,7 +209,7 @@ char* pem_encode(chunk_t der)
char *pem;
chunk_t base64;
int i = 0;
-
+
base64 = chunk_to_base64(der, NULL);
len = strlen(begin) + base64.len + base64.len/64 + strlen(end) + 2;
pem = malloc(len + 1);
@@ -223,7 +223,7 @@ char* pem_encode(chunk_t der)
}
while (i < base64.len - 2);
strcat(pem, end);
-
+
free(base64.ptr);
return pem;
}
@@ -235,7 +235,7 @@ static void edit(private_peer_controller_t *this, request_t *request, int id)
{
char *alias = "", *public_key = "", *pem;
chunk_t encoding, keyid;
-
+
if (request->get_query_data(request, "back"))
{
return request->redirect(request, "peer/list");
@@ -253,7 +253,7 @@ static void edit(private_peer_controller_t *this, request_t *request, int id)
{
alias = request->get_query_data(request, "alias");
public_key = request->get_query_data(request, "public_key");
-
+
if (!verify_alias(this, request, alias))
{
break;
@@ -333,7 +333,7 @@ static void handle(private_peer_controller_t *this, request_t *request,
{
id = atoi(idstr);
}
-
+
if (streq(action, "list"))
{
return list(this, request);
diff --git a/src/medsrv/controller/user_controller.c b/src/medsrv/controller/user_controller.c
index bc4717e32..0f25799d8 100755
--- a/src/medsrv/controller/user_controller.c
+++ b/src/medsrv/controller/user_controller.c
@@ -37,12 +37,12 @@ struct private_user_controller_t {
* database connection
*/
database_t *db;
-
+
/**
* user session
*/
user_t *user;
-
+
/**
* minimum required password lenght
*/
@@ -56,7 +56,7 @@ static chunk_t hash_password(char *login, char *password)
{
hasher_t *hasher;
chunk_t hash, data;
-
+
hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
if (!hasher)
{
@@ -77,16 +77,16 @@ static void login(private_user_controller_t *this, request_t *request)
if (request->get_query_data(request, "submit"))
{
char *login, *password;
-
+
login = request->get_query_data(request, "login");
password = request->get_query_data(request, "password");
-
+
if (login && password)
{
enumerator_t *query;
u_int id = 0;
chunk_t hash;
-
+
hash = hash_password(login, password);
query = this->db->query(this->db,
"SELECT id FROM user WHERE login = ? AND password = ?",
@@ -126,7 +126,7 @@ static bool verify_login(private_user_controller_t *this, request_t *request,
if (!login || *login == '\0')
{
request->setf(request, "error=Username is missing.");
- return FALSE;
+ return FALSE;
}
while (*login != '\0')
{
@@ -190,13 +190,13 @@ static void add(private_user_controller_t *this, request_t *request)
login = request->get_query_data(request, "new_login");
password = request->get_query_data(request, "new_password");
confirm = request->get_query_data(request, "confirm_password");
-
+
if (!verify_login(this, request, login) ||
!verify_password(this, request, password, confirm))
{
break;
}
-
+
hash = hash_password(login, password);
if (!hash.ptr || this->db->execute(this->db, &id,
"INSERT INTO user (login, password) VALUES (?, ?)",
@@ -222,7 +222,7 @@ static void edit(private_user_controller_t *this, request_t *request)
{
enumerator_t *query;
char *old_login;
-
+
/* lookup old login */
query = this->db->query(this->db, "SELECT login FROM user WHERE id = ?",
DB_INT, this->user->get_user(this->user),
@@ -256,12 +256,12 @@ static void edit(private_user_controller_t *this, request_t *request)
{
char *new_login, *old_pass, *new_pass, *confirm;
chunk_t old_hash, new_hash;
-
+
new_login = request->get_query_data(request, "old_login");
old_pass = request->get_query_data(request, "old_password");
new_pass = request->get_query_data(request, "new_password");
confirm = request->get_query_data(request, "confirm_password");
-
+
if (!verify_login(this, request, new_login) ||
!verify_password(this, request, new_pass, confirm))
{
@@ -270,7 +270,7 @@ static void edit(private_user_controller_t *this, request_t *request)
}
old_hash = hash_password(old_login, old_pass);
new_hash = hash_password(new_login, new_pass);
-
+
if (this->db->execute(this->db, NULL,
"UPDATE user SET login = ?, password = ? "
"WHERE id = ? AND password = ?",