IBR-DTN  1.0.0
KeyExchangeEvent.cpp
Go to the documentation of this file.
1 /*
2  * KeyExchangeEvent.cpp
3  *
4  * Copyright (C) 2014 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  * Thomas Schrader <schrader.thomas@gmail.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22 
24 #include "core/EventDispatcher.h"
25 
26 #include <sstream>
27 
28 namespace dtn
29 {
30  namespace security
31  {
32  KeyExchangeEvent::KeyExchangeEvent(const dtn::data::EID &eid, const dtn::security::KeyExchangeData &data)
33  : _eid(eid), _data(data)
34  {
35  switch (_data.getAction())
36  {
40  setLoggable(false);
41  break;
42 
43  default:
44  break;
45  }
46  }
47 
49  {}
50 
52  {
53  return _eid;
54  }
55 
57  {
58  return _data;
59  }
60 
61  const std::string KeyExchangeEvent::getName() const
62  {
64  }
65 
66  std::string KeyExchangeEvent::getMessage() const
67  {
68  switch (_data.getAction())
69  {
71  return "Please enter the password for " + _eid.getString() + " (" + _data.toString() + ")";
72 
74  return "Please compare the hash values for " + _eid.getString() + " (" + _data.toString() + "): " + _data.str();
75 
77  return "A new key was found. Please select a key for " + _eid.getString() + " (" + _data.toString() + ")";
78 
80  return "Key-exchange completed for " + _eid.getString() + " (" + _data.toString() + ")";
81 
83  return "Key-exchange failed for " + _eid.getString() + " (" + _data.toString() + ")";
84 
86  return "Entered password does not match the peer; Session " + _eid.getString() + " (" + _data.toString() + ")";
87 
88  default: {
89  std::stringstream sstm;
90  sstm << "Unknown event for " << _eid.getString() << " (" << _data.toString() + ")";
91  return sstm.str();
92  }
93  }
94  }
95 
97  {
98  // raise the new event
100  }
101 
102  const string KeyExchangeEvent::className = "KeyExchangeEvent";
103  } /* namespace security */
104 } /* namespace dtn */
static void queue(E *evt)
static const std::string className
const dtn::security::KeyExchangeData & getData() const
const std::string getName() const
EID getNode() const
Definition: EID.cpp:528
std::string getString() const
Definition: EID.cpp:374
const dtn::data::EID & getEID() const
static void raise(const dtn::data::EID &eid, const dtn::security::KeyExchangeData &data)