libqi-api  2.8.7.4
 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 
35  static const std::string UserAuthPrefix;
36  static const std::string QiAuthPrefix;
37 
38  virtual ~AuthProvider()
39  {
40  }
41  CapabilityMap processAuth(const CapabilityMap& authData);
42 
43 protected:
44  /*
45  * Processes an authentication messages, then returns a map of values.
46  * The returned map MUST include an element at index `State_Key`,
47  * containing:
48  * - `State_Error` if the authentication attempt is unsuccessful; if a
49  * value exists at index `Error_Reason_Key` it will be sent to the client.
50  * - `State_Cont` if the authentication attempt needs further processing;
51  * the rest of the map will be sent to the client.
52  * - `State_Done` if the authentication succeeded. The rest of the map will
53  * be left unused.
54  * If this token is missing or yields an unknown value the server will QI_ASSERT()
55  * and terminate the client's connection.
56  */
57  virtual CapabilityMap _processAuth(const CapabilityMap& authData) = 0;
58 };
59 
60 using AuthProviderPtr = boost::shared_ptr<AuthProvider>;
61 }
62 
63 #endif
static const std::string QiAuthPrefix
#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