New sessionid object.

This commit is contained in:
Brad Arant 2025-05-22 09:25:55 -07:00
parent 2f30b3f8c4
commit 0cb8a08a73
2 changed files with 5 additions and 12 deletions

View File

@ -1,11 +1,12 @@
#include "SessionId.h" #include "SessionId.h"
#include <openssl/ssl.h>
namespace jet { namespace jet {
SessionId::SessionId() { SessionId::SessionId() {
unsigned char hashit[64]; unsigned char hashit[64];
unsigned char hash[SHA_DIGEST_LENGTH]; unsigned char hash[SHA_DIGEST_LENGTH];
setBufferSize(64); setSize(64);
sprintf((char *)hashit, "JETSESSION%ld", time(0)); sprintf((char *)hashit, "JETSESSION%ld", time(0));
SHA1(hashit, strlen((char *)hashit), hash); SHA1(hashit, strlen((char *)hashit), hash);
sprintf(getData(), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", sprintf(getData(), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",

View File

@ -1,9 +1,9 @@
#include "__jet.h" #include "__jet.h"
#include "Exception.h" #include "Exception.h"
#include "Global.h" #include "Global.h"
#include "SessionId.h"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <openssl/ssl.h>
namespace jet { namespace jet {
@ -20,16 +20,8 @@ namespace jet {
// if last activity time is expired then ignore. // if last activity time is expired then ignore.
// follow sessiontimeoutredirecturl. // follow sessiontimeoutredirecturl.
// else // else
unsigned char hashit[64]; SessionId sessionId;
unsigned char hash[SHA_DIGEST_LENGTH]; global.headers["Set-Cookie"] << "session=" << sessionId;
char hashname[64];
sprintf((char *)hashit, "JETSESSION%ld", time(0));
SHA1(hashit, strlen((char *)hashit), hash);
sprintf(hashname, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
hash[0], hash[1], hash[2], hash[3], hash[4], hash[5], hash[6], hash[7], hash[8], hash[9],
hash[10], hash[11], hash[12], hash[13], hash[14], hash[15], hash[16], hash[17], hash[18], hash[19]);
coreutils::ZString sessionCookie(hashname);
global.headers["Set-Cookie"] << "session=" << sessionCookie;
if(keywordDefined("sessiontimeout")) { if(keywordDefined("sessiontimeout")) {
time_t timeout = time(0) + keywords["sessiontimeout"].asInteger(); time_t timeout = time(0) + keywords["sessiontimeout"].asInteger();
} }