encryption_wrapper.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *                                                                             *
00003 *  Name   : encryption_wrapper                                                *
00004 *  Author : Chris Koeritz                                                     *
00005 *                                                                             *
00006 *******************************************************************************
00007 * Copyright (c) 2004-$now By Author.  This program is free software; you can  *
00008 * redistribute it and/or modify it under the terms of the GNU General Public  *
00009 * License as published by the Free Software Foundation; either version 2 of   *
00010 * the License or (at your option) any later version.  This is online at:      *
00011 *     http://www.fsf.org/copyleft/gpl.html                                    *
00012 * Please send any updates to: fred@gruntose.com                               *
00013 \*****************************************************************************/
00014 
00015 #include "encryption_wrapper.h"
00016 
00017 #include <basis/byte_array.h>
00018 #include <basis/mutex.h>
00019 #include <loggers/program_wide_logger.h>
00020 #include <structures/static_memory_gremlin.h>
00021 
00022 using namespace basis;
00023 using namespace loggers;
00024 using namespace structures;
00025 
00026 namespace octopi {
00027 
00028 #undef LOG
00029 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
00030 
00031 encryption_wrapper::encryption_wrapper(const byte_array &wrapped)
00032 : infoton(encryption_classifier()),
00033   _wrapped(wrapped)
00034 {}
00035 
00036 encryption_wrapper::encryption_wrapper(const encryption_wrapper &to_copy)
00037 : root_object(),
00038   infoton(to_copy),
00039   _wrapped(to_copy._wrapped)
00040 {}
00041 
00042 encryption_wrapper::~encryption_wrapper() {}
00043 
00044 clonable *encryption_wrapper::clone() const
00045 { return cloner<encryption_wrapper>(*this); }
00046 
00047 encryption_wrapper &encryption_wrapper::operator =
00048     (const encryption_wrapper &to_copy)
00049 {
00050   if (this == &to_copy) return *this;
00051   _wrapped = to_copy._wrapped;
00052   return *this;
00053 }
00054 
00055 const char *wrap_encryption_classifier[] = { "#octrap" };
00056 
00057 SAFE_STATIC_CONST(string_array, encryption_wrapper::encryption_classifier,
00058     (1, wrap_encryption_classifier))
00059 
00060 int encryption_wrapper::packed_size() const
00061 {
00062   return _wrapped.length() + sizeof(int);  // wrapped array size.
00063 }
00064 
00065 void encryption_wrapper::pack(byte_array &packed_form) const
00066 {
00067   structures::attach(packed_form, _wrapped);
00068 }
00069 
00070 bool encryption_wrapper::unpack(byte_array &packed_form)
00071 {
00072   if (!structures::detach(packed_form, _wrapped)) return false;
00073   return true;
00074 }
00075 
00077 
00078 unwrapping_tentacle::unwrapping_tentacle()
00079 : tentacle_helper<encryption_wrapper>
00080     (encryption_wrapper::encryption_classifier(), false)
00081 {}
00082 
00083 unwrapping_tentacle::~unwrapping_tentacle()
00084 {}
00085 
00086 outcome unwrapping_tentacle::reconstitute(const string_array &classifier,
00087     byte_array &packed_form, infoton * &reformed)
00088 {
00089   if (classifier != encryption_wrapper::encryption_classifier())
00090     return NO_HANDLER;
00091 
00092   return reconstituter(classifier, packed_form, reformed,
00093       (encryption_wrapper *)NIL);
00094 }
00095 
00096 outcome unwrapping_tentacle::consume(infoton &formal(to_chow),
00097     const octopus_request_id &formal(item_id), byte_array &transformed)
00098 {
00099   FUNCDEF("consume");
00100   transformed.reset();
00101   LOG("should never enter this method.");
00102   return common::NOT_IMPLEMENTED;
00103 }
00104 
00105 } //namespace.
00106 
Generated on Sat Jan 28 04:22:50 2012 for hoople2 project by  doxygen 1.6.3