first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / octopi / library / tentacles / login_tentacle.h
1 #ifndef LOGIN_TENTACLE_CLASS
2 #define LOGIN_TENTACLE_CLASS
3
4 /*****************************************************************************\
5 *                                                                             *
6 *  Name   : login_tentacle                                                    *
7 *  Author : Chris Koeritz                                                     *
8 *                                                                             *
9 *******************************************************************************
10 * Copyright (c) 2002-$now By Author.  This program is free software; you can  *
11 * redistribute it and/or modify it under the terms of the GNU General Public  *
12 * License as published by the Free Software Foundation; either version 2 of   *
13 * the License or (at your option) any later version.  This is online at:      *
14 *     http://www.fsf.org/copyleft/gpl.html                                    *
15 * Please send any updates to: fred@gruntose.com                               *
16 \*****************************************************************************/
17
18 #include "security_infoton.h"
19
20 #include <octopus/tentacle_helper.h>
21
22 namespace octopi {
23
24 // forward.
25 class entity_registry;
26 class octopus_request_id;
27
28 //! Provides rudimentary login services.
29 /*!
30   This is a way for entities to become logged into an octopus system,
31   should that be required by the application.
32 */
33
34 class login_tentacle
35 : public tentacle_helper<security_infoton>
36 {
37 public:
38   login_tentacle(entity_registry &security,
39           int dormancy_period = 7 * basis::MINUTE_ms);
40     //!< constructs a login manager based on "security".
41     /*!< this will allow an entity to persist for "dormancy_period"
42     milliseconds without a refresh.  after that time, the entities we haven't
43     heard from are whacked.  the "security" object will provide our login
44     checking. */
45
46   virtual ~login_tentacle();
47
48   DEFINE_CLASS_NAME("login_tentacle");
49
50   virtual basis::outcome reconstitute(const structures::string_array &classifier,
51           basis::byte_array &packed_form, infoton * &reformed);
52     //!< recreates a "reformed" infoton from the packed data.
53     /*!< this uses the "classifier" and packed infoton data in "packed_form".
54     this will only succeed if the classifier's first name is understood here.
55     */
56
57   virtual basis::outcome consume(infoton &to_chow, const octopus_request_id &item_id,
58           basis::byte_array &transformed);
59     //!< the base login_tentacle allows anyone to log in.
60     /*!< this permits any entity that tries to log in to become a verified
61     entity.  derived login_tentacles can force the entity to prove that it's
62     worthy in an application specific manner. */
63
64   virtual void expunge(const octopus_entity &to_remove);
65     //!< trashes the records we were keeping for the entity.
66
67 private:
68   entity_registry &_security;  //!< allows or disallows entity access.
69   int _dormancy_period;  //!< time allowed before an entity is dropped.
70 };
71
72 } //namespace.
73
74 #endif
75