1 /*****************************************************************************\
3 * Name : identity_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 "identity_tentacle.h"
16 #include "identity_infoton.h"
19 #include <structures/string_hash.h>
20 #include <timely/time_stamp.h>
22 using namespace basis;
23 using namespace structures;
24 using namespace timely;
29 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
31 //#define DEBUG_IDENTITY_TENTACLE
32 // uncomment for debugging version.
36 identity_tentacle::identity_tentacle(octopus &parent)
37 : tentacle_helper<identity_infoton>(identity_infoton::identity_classifier(),
42 identity_tentacle::~identity_tentacle() {}
44 outcome identity_tentacle::reconstitute(const string_array &classifier,
45 byte_array &packed_form, infoton * &reformed)
47 if (classifier != identity_infoton::identity_classifier())
50 return reconstituter(classifier, packed_form, reformed,
51 (identity_infoton *)NULL_POINTER);
54 outcome identity_tentacle::consume(infoton &to_chow,
55 const octopus_request_id &item_id, byte_array &transformed)
57 #ifdef DEBUG_IDENTITY_TENTACLE
61 identity_infoton *inf = dynamic_cast<identity_infoton *>(&to_chow);
63 // if the infoton doesn't cast, then it is not for us. we need to vet
64 // that the identity looks pretty much okay.
67 // that would imply that all users of octopi have correctly identified
68 // themselves. this is not currently the case. we need a way to
69 // automate that step for a user of an octopus?
73 // this infoton's entity was allowed, so we call it partially processed.
76 #ifdef DEBUG_IDENTITY_TENTACLE
77 LOG(astring("denying infoton ") + item_id.mangled_form());
79 // the infoton's identity is invalid; it needs to be dropped.
83 #ifdef DEBUG_IDENTITY_TENTACLE
84 LOG(astring("old name, storing under: ") + item_id.mangled_form());
87 // this is definitely for an identity request now.
88 inf->_new_name = _parent.issue_identity();
90 #ifdef DEBUG_IDENTITY_TENTACLE
91 LOG(astring("new name: ") + inf->_new_name.mangled_form());
94 if (!store_product(dynamic_cast<infoton *>(inf->clone()), item_id))