41 using namespace basis;
51 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s))
59 class 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); }
88 class 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)) {
108 if (to_chow.
classifier() != simp_classifier())
return NO_HANDLER;
128 virtual int execute();
131 int 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.
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 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.
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.
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.
bool unpack(basis::byte_array &packed_form, set< contents > &to_unpack)
provides a way to unpack any set that stores packable objects.
void pack(basis::byte_array &packed_form, const set< contents > &to_pack)
provides a way to pack any set that stores packable objects.
int packed_size(const byte_array &packed_form)
Reports the size required to pack a byte array into a byte array.
Useful support functions for unit testing, especially within hoople.
#define SAFE_STATIC_CONST(type, func_name, parms)
this version returns a constant object instead.