00001 #ifndef LOGIN_TENTACLE_IMPLEMENTATION_FILE
00002 #define LOGIN_TENTACLE_IMPLEMENTATION_FILE
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "entity_registry.h"
00019 #include "login_tentacle.h"
00020 #include "security_infoton.h"
00021
00022 #include <basis/log_base.h>
00023 #include <data_struct/string_hash.h>
00024 #include <mechanisms/time_stamp.h>
00025 #include <octopus/entity_defs.h>
00026
00027 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger(), s)
00028
00030
00031 login_tentacle::login_tentacle(entity_registry &security,
00032 int dormancy_period)
00033 : tentacle_helper<security_infoton>(security_infoton::security_classifier(),
00034 false),
00035 _security(security),
00036 _dormancy_period(dormancy_period)
00037 {}
00038
00039 login_tentacle::~login_tentacle() {}
00040
00041 outcome login_tentacle::reconstitute(const string_array &classifier,
00042 byte_array &packed_form, infoton * &reformed)
00043 {
00044 if (classifier != security_infoton::security_classifier())
00045 return NO_HANDLER;
00046
00047 return reconstituter(classifier, packed_form, reformed,
00048 (security_infoton *)NIL);
00049 }
00050
00051 void login_tentacle::expunge(const octopus_entity &to_remove)
00052 {
00053 _security.zap_entity(to_remove);
00054 }
00055
00056 outcome login_tentacle::consume(infoton &to_chow,
00057 const octopus_request_id &item_id, byte_array &transformed)
00058 {
00059 FUNCDEF("consume");
00060 transformed.reset();
00061 security_infoton *inf = dynamic_cast<security_infoton *>(&to_chow);
00062 if (!inf) {
00063
00064
00065 if (_security.authorized(item_id._entity)) {
00066
00067 return PARTIAL;
00068 }
00069
00070 return DISALLOWED;
00071 }
00072
00073 switch (inf->_mode) {
00074 case security_infoton::LI_REFRESH:
00075 case security_infoton::LI_LOGIN: {
00076 bool success = _security.add_entity(item_id._entity,
00077 inf->verification());
00078 inf->_success = success? OKAY : DISALLOWED;
00079 break;
00080 }
00081 case security_infoton::LI_LOGOUT: {
00082 bool success = _security.zap_entity(item_id._entity);
00083 inf->_success = success? OKAY : DISALLOWED;
00084 break;
00085 }
00086 default: {
00087 inf->_success = BAD_INPUT;
00088 break;
00089 }
00090 }
00091 inf->verification().reset();
00092 if (!store_product((infoton *)inf->clone(), item_id))
00093 return NO_SPACE;
00094 return OKAY;
00095 }
00096
00097
00098 #endif //LOGIN_TENTACLE_IMPLEMENTATION_FILE
00099