51#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s))
59class simple_infoton :
public infoton
64 simple_infoton() :
infoton(simp_classifier()) {}
71 futzle.
pack(packed_form);
74 if (!futzle.
unpack(packed_form))
return false;
78 virtual clonable *
clone()
const {
return new simple_infoton(*
this); }
88class simple_tentacle :
public tentacle
91 simple_tentacle() :
tentacle(simp_classifier(), true) {}
96 if (classifier != simp_classifier())
return NO_HANDLER;
97 reformed =
new simple_infoton;
98 if (!reformed->
unpack(packed_form)) {
131int test_octopus_security::execute()
135 simple_tentacle *tenty = new simple_tentacle;
136 logos.add_tentacle(tenty);
151 simple_infoton testose;
152 simple_infoton *testose_copy = new simple_infoton(testose);
155 outcome ret = logos.evaluate(testose_copy, req1);
158 astring("the operation failed with an error ")
166 testose_copy = new simple_infoton(testose);
167 ret = logos.evaluate(testose_copy, req2);
170 astring("the operation didn't fail when it should have."));
171 else if (ret !=
tentacle::DISALLOWED)
173 astring("the operation didn't provide the proper
outcome, it gave: ")
177 guardian->zap_entity(jimbo);
180 testose_copy = new simple_infoton(testose);
181 ret = logos.evaluate(testose_copy, req1);
184 astring("the operation didn't fail when it should have."));
185 else if (ret !=
tentacle::DISALLOWED)
187 astring("the operation didn't provide the proper
outcome, it gave: ")
194 testose_copy = new simple_infoton(testose);
195 ret = logos.evaluate(testose_copy, req2);
198 astring("the operation failed with an error ")
201 LOG(
astring(class_name()) + ":: security works for those functions tested.");
The application_shell is a base object for console programs.
virtual int execute()=0
< retrieves the command line from the /proc hierarchy on linux.
void reset(int number=0, const contents *initial_contents=NULL_POINTER)
Resizes this array and sets the contents from an array of contents.
Provides a dynamically resizable ASCII character string.
void pack(byte_array &target) const
stores this string in the "target". it can later be unpacked again.
int length() const
Returns the current length of the string.
bool unpack(byte_array &source)
retrieves a string (packed with pack()) from "source" into this string.
Defines the base class for all string processing objects in hoople.
virtual base_string & concatenate_string(const base_string &s)=0
Modifies "this" by concatenating "s" onto it.
A very common template for a dynamic array of bytes.
A clonable object knows how to make copy of itself.
Outcomes describe the state of completion for an operation.
Defines installation-specific locations in the file system.
An infoton is an individual request parcel with accompanying information.
virtual basis::astring text_form() const
local version just makes text_form() more functional.
virtual int packed_size() const =0
reports how large the infoton will be when packed.
virtual bool unpack(basis::byte_array &packed_form)=0
restores an infoton from a packed form.
const structures::string_array & classifier() const
this array of strings is the "name" for this infoton.
virtual clonable * clone() const =0
must be provided to allow creation of a copy of this object.
virtual void pack(basis::byte_array &packed_form) const =0
stuffs the data in the infoton into the "packed_form".
Provides rudimentary login services.
Provides a way of identifying users of an octopus object.
Identifies requests made on an octopus by users.
Octopus is a design pattern for generalized request processing systems.
Provides a basic implementation of an entity_registry for octopus.
Manages a service within an octopus by processing certain infotons.
virtual basis::outcome consume(infoton &to_chow, const octopus_request_id &item_id, basis::byte_array &transformed)=0
this is the main function that processes infotons for this tentacle.
virtual basis::outcome reconstitute(const structures::string_array &classifier, basis::byte_array &packed_form, infoton *&reformed)=0
regenerates an infoton from its packed form.
virtual void expunge(const octopus_entity &to_remove)=0
called to remove traces of the entity "to_remove".
@ NO_HANDLER
no handler for that type of infoton.
An array of strings with some additional helpful methods.
#define deadly_error(c, f, i)
#define formal(parameter)
This macro just eats what it's passed; it marks unused formal parameters.
#define NULL_POINTER
The value representing a pointer to nothing.
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Provides macros that implement the 'main' program of an application.
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
void WHACK(contents *&ptr)
deletion with clearing of the pointer.
const int MEGABYTE
Number of bytes in a megabyte.
A logger that sends to the console screen using the standard output device.
An extension to floating point primitives providing approximate equality.
Provides access to the operating system's socket methods.
A dynamic container class that holds any kind of object via pointers.
Useful support functions for unit testing, especially within hoople.
#define SAFE_STATIC_CONST(type, func_name, parms)
this version returns a constant object instead.