first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / octopi / library / tentacles / security_infoton.h
1 #ifndef SECURITY_INFOTON_CLASS
2 #define SECURITY_INFOTON_CLASS
3
4 /*****************************************************************************\
5 *                                                                             *
6 *  Name   : security_infoton                                                  *
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 <octopus/infoton.h>
19
20 namespace octopi {
21
22 //! Encapsulates security activities (login, logout, refresh).
23
24 class security_infoton : public infoton
25 {
26 public:
27   enum login_modes {
28     LI_LOGIN,   //!< the requester wants to log in as a new entity.
29     LI_LOGOUT,  //!< the requester surrenders its login.
30     LI_REFRESH  //!< the requester is still alive and wants to keep its login.
31   };
32
33   login_modes _mode; //!< what kind of request is being made here?
34   basis::outcome _success;  //!< did the request succeed?
35
36   security_infoton();
37   security_infoton(login_modes mode, const basis::outcome &success,
38           const basis::byte_array &verification);
39   security_infoton(const security_infoton &to_copy);
40
41   virtual ~security_infoton();
42
43   DEFINE_CLASS_NAME("security_infoton");
44
45   security_infoton &operator =(const security_infoton &to_copy);
46
47   // observes or modifies the verification token.
48   const basis::byte_array &verification() const;
49   basis::byte_array &verification();
50
51   static const structures::string_array &security_classifier();
52     //!< returns the classifier for this type of infoton.
53
54   virtual void pack(basis::byte_array &packed_form) const;
55   virtual bool unpack(basis::byte_array &packed_form);
56
57   virtual clonable *clone() const;
58
59   virtual int packed_size() const;
60
61   virtual void text_form(basis::base_string &fill) const {
62     fill.assign(basis::astring(class_name())
63         + basis::a_sprintf(": mode %d, outcome=%d", _mode, _success.value()));
64   }
65
66 private:
67   basis::byte_array *_verification;  //!< anything needed for upper-level verification.
68 };
69
70 } //namespace.
71
72 #endif
73