1 /*****************************************************************************\
3 * Name : login_tentacle *
4 * Author : Chris Koeritz *
6 *******************************************************************************
7 * Copyright (c) 2002-$now By Author. This program is free software; you can *
8 * redistribute it and/or modify it under the terms of the GNU General Public *
9 * License as published by the Free Software Foundation; either version 2 of *
10 * the License or (at your option) any later version. This is online at: *
11 * http://www.fsf.org/copyleft/gpl.html *
12 * Please send any updates to: fred@gruntose.com *
13 \*****************************************************************************/
15 #include "entity_registry.h"
16 #include "login_tentacle.h"
17 #include "security_infoton.h"
19 #include <octopus/entity_defs.h>
20 #include <structures/string_hash.h>
21 #include <timely/time_stamp.h>
23 using namespace basis;
24 using namespace octopi;
25 using namespace structures;
26 using namespace timely;
31 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
35 login_tentacle::login_tentacle(entity_registry &security, int dormancy_period)
36 : tentacle_helper<security_infoton>(security_infoton::security_classifier(),
39 _dormancy_period(dormancy_period)
42 login_tentacle::~login_tentacle() {}
44 outcome login_tentacle::reconstitute(const string_array &classifier,
45 byte_array &packed_form, infoton * &reformed)
47 if (classifier != security_infoton::security_classifier())
50 return reconstituter(classifier, packed_form, reformed,
51 (security_infoton *)NULL_POINTER);
54 void login_tentacle::expunge(const octopus_entity &to_remove)
56 _security.zap_entity(to_remove); // trash it and we're done.
59 outcome login_tentacle::consume(infoton &to_chow,
60 const octopus_request_id &item_id, byte_array &transformed)
64 security_infoton *inf = dynamic_cast<security_infoton *>(&to_chow);
66 // if the infoton doesn't cast, then it is not for us. we need to vet
67 // that the entity it came from is known and approved.
68 if (_security.authorized(item_id._entity)) {
69 // this infoton's entity was allowed, so we call it partially processed.
72 // the infoton's entity is not authorized; it needs to be dropped.
77 case security_infoton::LI_REFRESH: // intentional fall through.
78 case security_infoton::LI_LOGIN: {
79 bool success = _security.add_entity(item_id._entity,
81 inf->_success = success? OKAY : DISALLOWED;
84 case security_infoton::LI_LOGOUT: {
85 bool success = _security.zap_entity(item_id._entity);
86 inf->_success = success? OKAY : DISALLOWED;
90 inf->_success = BAD_INPUT;
94 inf->verification().reset(); // we don't need to send that back.
95 if (!store_product(dynamic_cast<infoton *>(inf->clone()), item_id))