48 changed files with 165 additions and 686 deletions
-
12include/application/application.h
-
4include/auth/auth.h
-
9include/auth/interface/auth.h
-
6include/user.h
-
33include/utils/hash.h
-
72include/uuid.h
-
12src/Makefile.am
-
8src/application/application.c
-
13src/application/controller/_get_user_from_args.c
-
5src/application/controller/_update_user_from_args.c
-
5src/application/controller/_validate_email.c
-
8src/application/controller/signup/create.c
-
8src/application/controller/user/create.c
-
6src/application/controller/user/read.c
-
8src/application/controller/user/update.c
-
15src/application/create_user.c
-
7src/application/get_user.c
-
12src/application/login.c
-
8src/application/update_password.c
-
13src/application/update_user.c
-
6src/asset/asset.c
-
6src/auth/auth.c
-
3src/auth/create.c
-
3src/auth/interface/auth.c
-
6src/auth/ldap.c
-
7src/auth/storage/storage.c
-
7src/config/value.c
-
5src/hash/delete.c
-
5src/hash/get.c
-
3src/hash/get_first.c
-
7src/hash/value.c
-
7src/http/cookie.c
-
7src/http/header.c
-
5src/http/writer/write.c
-
7src/session/session.c
-
3src/storage/storage.c
-
12src/taskrambler.c
-
15src/user/user.c
-
55src/utils/hash.c
-
12src/uuid/Makefile.am
-
54src/uuid/_format3or5.c
-
34src/uuid/compare.c
-
38src/uuid/parse.c
-
34src/uuid/unparse.c
-
60src/uuid/uuid.c
-
38src/uuid/version1.c
-
71src/uuid/version3.c
-
71src/uuid/version5.c
@ -1,33 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* Functions to handle varios signals send to the application. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __UTILS_HASH_H__ |
|||
#define __UTILS_HASH_H__ |
|||
|
|||
#include <sys/types.h> |
|||
|
|||
unsigned long sdbm(const unsigned char *, size_t); |
|||
|
|||
#endif // __UTILS_HASH_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,72 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* ways to create uuid variant 5. For uuid of variant 1 I use |
|||
* the implementation delivered with the core utils. |
|||
* But this is wrapped in here, so that the rest of the code |
|||
* can use only this implementation...this additionally has the |
|||
* advantage that we can implement version 1 here too for systems |
|||
* where the coreutils implementation is not available. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __UUID_H__ |
|||
#define __UUID_H__ |
|||
|
|||
#include <stdint.h> |
|||
#include <sys/types.h> |
|||
#include <uuid/uuid.h> |
|||
|
|||
#include "trbase.h" |
|||
|
|||
|
|||
typedef char UuidString[37]; |
|||
|
|||
TR_CLASS(Uuid) { |
|||
union { |
|||
uuid_t value; |
|||
struct { |
|||
uint32_t time_low; |
|||
uint16_t time_mid; |
|||
uint16_t time_hi_version; |
|||
uint8_t clk_seq_hi_res; |
|||
uint8_t clk_seq_low; |
|||
unsigned char node[6]; |
|||
} elements; |
|||
} uuid; |
|||
}; |
|||
|
|||
extern Uuid uuidZero; |
|||
|
|||
/* |
|||
* generator functions...these are not really part of the object |
|||
* but generate a uuid object. |
|||
*/ |
|||
Uuid uuidVersion1(); |
|||
Uuid uuidVersion3(const unsigned char *, size_t, Uuid); |
|||
Uuid uuidVersion5(const unsigned char *, size_t, Uuid); |
|||
|
|||
void uuidUnparse(Uuid, UuidString); |
|||
Uuid uuidParse(const UuidString); |
|||
|
|||
int uuidCompare(Uuid, Uuid); |
|||
|
|||
#endif // __UUID_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,55 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* \author Unknown (find out) |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#include <ctype.h> |
|||
#include <sys/types.h> |
|||
|
|||
#include <openssl/rand.h> |
|||
|
|||
#include "utils/hash.h" |
|||
|
|||
/** |
|||
* SDBM hashing algorithm: |
|||
* |
|||
* this algorithm was created for sdbm (a public-domain reimplementation of |
|||
* ndbm) database library. it was found to do well in scrambling bits, |
|||
* causing better distribution of the keys and fewer splits. it also happens |
|||
* to be a good general hashing function with good distribution. the actual |
|||
* function is hash(i) = hash(i - 1) * 65599 + str[i]; what is included below |
|||
* is the faster version used in gawk. [there is even a faster, duff-device |
|||
* version] the magic constant 65599 was picked out of thin air while |
|||
* experimenting with different constants, and turns out to be a prime. this |
|||
* is one of the algorithms used in berkeley db (see sleepycat) and elsewhere. |
|||
*/ |
|||
unsigned long |
|||
sdbm(const unsigned char * str, size_t len) |
|||
{ |
|||
unsigned long hash = 0; |
|||
|
|||
for(; 0 < len; str++, len--) |
|||
hash = tolower(*str) + (hash << 6) + (hash << 16) - hash; |
|||
|
|||
return hash; |
|||
} |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,12 +0,0 @@ |
|||
ACLOCAL_AMFLAGS = -I m4 |
|||
AUTOMAKE_OPTIONS = subdir-objects |
|||
|
|||
UUID = uuid.c version1.c version3.c version5.c _format3or5.c \
|
|||
parse.c unparse.c compare.c |
|||
|
|||
AM_CFLAGS += -I../../include/ |
|||
|
|||
noinst_LTLIBRARIES = libuuid.la |
|||
|
|||
libuuid_la_SOURCES = $(UUID) |
|||
libuuid_la_CFLAGS = $(AM_CFLAGS) |
|||
@ -1,54 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2013 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
// for memcpy |
|||
#include <string.h> |
|||
|
|||
// for ntohl and similar |
|||
#include <arpa/inet.h> |
|||
|
|||
// for already available uuid functionality |
|||
#include <uuid/uuid.h> |
|||
|
|||
#include "uuid.h" |
|||
|
|||
void |
|||
_uuidFormat3or5(Uuid uuid, unsigned char hash[16], int version) |
|||
{ |
|||
/* convert UUID to local byte order */ |
|||
memcpy((uuid->uuid).value, hash, 16); |
|||
|
|||
(uuid->uuid).elements.time_low = |
|||
ntohl((uuid->uuid).elements.time_low); |
|||
(uuid->uuid).elements.time_mid = |
|||
ntohs((uuid->uuid).elements.time_mid); |
|||
(uuid->uuid).elements.time_hi_version = |
|||
ntohs((uuid->uuid).elements.time_hi_version); |
|||
|
|||
/* put in the variant and version bits */ |
|||
(uuid->uuid).elements.time_hi_version &= 0x0FFF; |
|||
(uuid->uuid).elements.time_hi_version |= (version << 12); |
|||
(uuid->uuid).elements.clk_seq_hi_res &= 0x3F; |
|||
(uuid->uuid).elements.clk_seq_hi_res |= 0x80; |
|||
} |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,34 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2013 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
// for already available uuid functionality |
|||
#include <uuid/uuid.h> |
|||
|
|||
#include "uuid.h" |
|||
|
|||
int |
|||
uuidCompare(Uuid uuid1, Uuid uuid2) |
|||
{ |
|||
return uuid_compare((uuid1->uuid).value, (uuid2->uuid).value); |
|||
} |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,38 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2013 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
// for already available uuid functionality |
|||
#include <uuid/uuid.h> |
|||
|
|||
#include "trbase.h" |
|||
#include "uuid.h" |
|||
|
|||
Uuid |
|||
uuidParse(const UuidString uuid_str) |
|||
{ |
|||
Uuid uuid = TR_new(Uuid); |
|||
uuid_parse(uuid_str, (uuid->uuid).value); |
|||
|
|||
return uuid; |
|||
} |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,34 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2013 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
// for already available uuid functionality |
|||
#include <uuid/uuid.h> |
|||
|
|||
#include "uuid.h" |
|||
|
|||
void |
|||
uuidUnparse(Uuid uuid, UuidString uuid_str) |
|||
{ |
|||
uuid_unparse((uuid->uuid).value, uuid_str); |
|||
} |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,60 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2013 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#include <stdarg.h> |
|||
#include <string.h> |
|||
|
|||
#include "trbase.h" |
|||
#include "uuid.h" |
|||
|
|||
|
|||
static |
|||
int |
|||
uuidCtor(void * _this, va_list * params) |
|||
{ |
|||
return 0; |
|||
} |
|||
|
|||
static |
|||
void |
|||
uuidDtor(void * _this) |
|||
{ |
|||
} |
|||
|
|||
static |
|||
void |
|||
uuidClone(void * _this, void * _base) |
|||
{ |
|||
Uuid this = _this; |
|||
Uuid base = _base; |
|||
|
|||
memcpy((this->uuid).value, (base->uuid).value, 16); |
|||
} |
|||
|
|||
TR_INIT_IFACE(TR_Class, uuidCtor, uuidDtor, uuidClone); |
|||
TR_CREATE_CLASS(Uuid, NULL, TR_IF(TR_Class)); |
|||
|
|||
TR_INSTANCE(Uuid, uuidZero) { |
|||
.uuid.value = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} |
|||
}}; |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,38 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2013 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
// for already available uuid functionality |
|||
#include <uuid/uuid.h> |
|||
|
|||
#include "trbase.h" |
|||
#include "uuid.h" |
|||
|
|||
Uuid |
|||
uuidVersion1() |
|||
{ |
|||
Uuid uuid = TR_new(Uuid); |
|||
uuid_generate((uuid->uuid).value); |
|||
|
|||
return uuid; |
|||
} |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,71 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2013 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
// for size_t |
|||
#include <sys/types.h> |
|||
|
|||
// for md5 generation |
|||
#include <openssl/md5.h> |
|||
|
|||
// for htonl and similar |
|||
#include <arpa/inet.h> |
|||
|
|||
// for already available uuid functionality |
|||
#include "trbase.h" |
|||
#include "uuid.h" |
|||
|
|||
void _uuidFormat3or5(Uuid uuid, unsigned char hash[16], int version); |
|||
|
|||
Uuid |
|||
uuidVersion3(const unsigned char * name, size_t nname, Uuid nsid) |
|||
{ |
|||
MD5_CTX ctx; |
|||
unsigned char hash[16]; |
|||
Uuid net_nsid = TR_clone(nsid); |
|||
Uuid uuid = TR_new(Uuid); |
|||
|
|||
/* |
|||
* put the namespace id into network byte order. |
|||
*/ |
|||
(net_nsid->uuid).elements.time_low = |
|||
htonl((net_nsid->uuid).elements.time_low); |
|||
(net_nsid->uuid).elements.time_mid = |
|||
htons((net_nsid->uuid).elements.time_mid); |
|||
(net_nsid->uuid).elements.time_hi_version = |
|||
htons((net_nsid->uuid).elements.time_hi_version); |
|||
|
|||
/* |
|||
* generate the MD5 |
|||
*/ |
|||
MD5_Init(&ctx); |
|||
MD5_Update(&ctx, (net_nsid->uuid).value, 16); |
|||
MD5_Update(&ctx, name, nname); |
|||
MD5_Final(hash, &ctx); |
|||
|
|||
TR_delete(net_nsid); |
|||
|
|||
_uuidFormat3or5(uuid, hash, 3); |
|||
|
|||
return uuid; |
|||
} |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,71 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2013 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
// for size_t |
|||
#include <sys/types.h> |
|||
|
|||
// for sha1 generation |
|||
#include <openssl/sha.h> |
|||
|
|||
// for htonl and similar |
|||
#include <arpa/inet.h> |
|||
|
|||
// for already available uuid functionality |
|||
#include "trbase.h" |
|||
#include "uuid.h" |
|||
|
|||
void _uuidFormat3or5(Uuid uuid, unsigned char hash[16], int version); |
|||
|
|||
Uuid |
|||
uuidVersion5(const unsigned char * name, size_t nname, Uuid nsid) |
|||
{ |
|||
SHA_CTX ctx; |
|||
unsigned char hash[20]; |
|||
Uuid net_nsid = TR_clone(nsid); |
|||
Uuid uuid = TR_new(Uuid); |
|||
|
|||
/* |
|||
* put the namespace id into network byte order. |
|||
*/ |
|||
(net_nsid->uuid).elements.time_low = |
|||
htonl((net_nsid->uuid).elements.time_low); |
|||
(net_nsid->uuid).elements.time_mid = |
|||
htons((net_nsid->uuid).elements.time_mid); |
|||
(net_nsid->uuid).elements.time_hi_version = |
|||
htons((net_nsid->uuid).elements.time_hi_version); |
|||
|
|||
/* |
|||
* generate the MD5 |
|||
*/ |
|||
SHA1_Init(&ctx); |
|||
SHA1_Update(&ctx, (net_nsid->uuid).value, 16); |
|||
SHA1_Update(&ctx, name, nname); |
|||
SHA1_Final(hash, &ctx); |
|||
|
|||
TR_delete(net_nsid); |
|||
|
|||
_uuidFormat3or5(uuid, hash, 5); |
|||
|
|||
return uuid; |
|||
} |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue