Jeff Thompson | c057343 | 2013-09-19 17:41:36 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2013 Regents of the University of California. |
| 4 | * @author: Yingdi Yu <yingdi@cs.ucla.edu> |
| 5 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
| 6 | * See COPYING for copyright and distribution information. |
| 7 | */ |
| 8 | |
| 9 | #ifndef NDN_SECURITY_EXCEPTION_HPP |
Jeff Thompson | e589c3f | 2013-10-12 17:30:50 -0700 | [diff] [blame^] | 10 | #define NDN_SECURITY_EXCEPTION_HPP |
Jeff Thompson | c057343 | 2013-09-19 17:41:36 -0700 | [diff] [blame] | 11 | |
| 12 | #include <exception> |
| 13 | #include <string> |
| 14 | |
| 15 | namespace ndn { |
| 16 | |
| 17 | class SecurityException : public std::exception { |
| 18 | public: |
| 19 | SecurityException(const std::string& errorMessage) throw(); |
| 20 | |
| 21 | virtual ~SecurityException() throw(); |
| 22 | |
Jeff Thompson | 69dd03e | 2013-09-20 10:15:56 -0700 | [diff] [blame] | 23 | std::string Msg() { return errorMessage_; } |
| 24 | |
Jeff Thompson | f0a01c3 | 2013-09-23 15:58:06 -0700 | [diff] [blame] | 25 | virtual const char* what() const throw() { return errorMessage_.c_str(); } |
Jeff Thompson | c057343 | 2013-09-19 17:41:36 -0700 | [diff] [blame] | 26 | |
| 27 | private: |
| 28 | const std::string errorMessage_; |
| 29 | }; |
| 30 | |
| 31 | class UnrecognizedKeyFormatException : public SecurityException { |
| 32 | public: |
| 33 | UnrecognizedKeyFormatException(const std::string& errorMessage) |
| 34 | : SecurityException(errorMessage) |
| 35 | { |
| 36 | } |
| 37 | }; |
| 38 | |
| 39 | class UnrecognizedDigestAlgorithmException : public SecurityException { |
| 40 | public: |
| 41 | UnrecognizedDigestAlgorithmException(const std::string& errorMessage) |
| 42 | : SecurityException(errorMessage) |
| 43 | { |
| 44 | } |
| 45 | }; |
| 46 | |
| 47 | } |
| 48 | |
| 49 | #endif |