libmoost
/home/mhx/git/github/libmoost/include/moost/nagios/detail/nsca_encpass.hpp
Go to the documentation of this file.
00001 /* vim:set ts=3 sw=3 sts=3 et: */
00028 #ifndef MOOST_NAGIOS_NSCA_CLIENT_NSCA_ENCPASS_HPP__
00029 #define MOOST_NAGIOS_NSCA_CLIENT_NSCA_ENCPASS_HPP__
00030 
00031 #include <string>
00032 #include <stdexcept>
00033 #include <iostream>
00034 
00035 #include <boost/lexical_cast.hpp>
00036 #include <boost/shared_ptr.hpp>
00037 #include <boost/function.hpp>
00038 #include <boost/regex.hpp>
00039 
00040 #include "nsca_common.hpp"
00041 
00042 namespace moost { namespace nagios {
00043 
00044 
00045    struct nsca_encpass
00046    {
00047       nsca_encpass(std::string const & passwd = std::string())
00048          : passwd(validate_encryption_password(passwd))
00049       {
00050       }
00051 
00052       static std::string validate_encryption_password(
00053             std::string const & password)
00054       {
00055          if(password.size() > nsca_const::MAX_PASSWORD_LENGTH)
00056          {
00057             throw std::invalid_argument(
00058                   "Password is too long for NSCA to handle");
00059          }
00060 
00061          return password;
00062       }
00063 
00064       operator std::string const & () const
00065       {
00066          return passwd;
00067       }
00068 
00069       std::string passwd;
00070    };
00071 
00072 }}
00073 
00074 #endif