libqi-api  release-2.5.3-2016-11-18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
authprovider.hpp
Go to the documentation of this file.
1 #pragma once
2 /*
3 ** Copyright (C) 2014 Aldebaran Robotics
4 ** See COPYING for the license
5 */
6 
7 #ifndef _QI_MESSAGING_AUTHPROVIDER_HPP_
8 #define _QI_MESSAGING_AUTHPROVIDER_HPP_
9 
10 #include <string>
11 #include <map>
12 #include <stdexcept>
13 
14 #include <boost/shared_ptr.hpp>
15 
16 #include <qi/api.hpp>
17 #include <qi/anyvalue.hpp>
18 
19 namespace qi
20 {
21 using CapabilityMap = std::map<std::string, AnyValue>;
22 
24 {
25 public:
26  static const std::string State_Key;
27  enum State
28  {
29  State_Error = 1,
32  };
33  static const std::string Error_Reason_Key;
34  static const std::string UserAuthPrefix;
35 
36  virtual ~AuthProvider()
37  {
38  }
39  CapabilityMap processAuth(const CapabilityMap& authData);
40 
41 protected:
42  /*
43  * Processes an authentication messages, then returns a map of values.
44  * The returned map MUST include an element at index `State_Key`,
45  * containing:
46  * - `State_Error` if the authentication attempt is unsuccessful; if a
47  * value exists at index `Error_Reason_Key` it will be sent to the client.
48  * - `State_Cont` if the authentication attempt needs further processing;
49  * the rest of the map will be sent to the client.
50  * - `State_Done` if the authentication succeeded. The rest of the map will
51  * be left unused.
52  * If this token is missing or yields an unknown value the server will QI_ASSERT()
53  * and terminate the client's connection.
54  */
55  virtual CapabilityMap _processAuth(const CapabilityMap& authData) = 0;
56 };
57 
58 using AuthProviderPtr = boost::shared_ptr<AuthProvider>;
59 }
60 
61 #endif
#define QI_API
Definition: api.hpp:33
virtual ~AuthProvider()
dll import/export and compiler message
static const std::string State_Key
boost::shared_ptr< AuthProvider > AuthProviderPtr
std::map< std::string, AnyValue > CapabilityMap
static const std::string Error_Reason_Key
static const std::string UserAuthPrefix