libqi-api  2.4.3.28
 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  typedef std::map<std::string, AnyValue> CapabilityMap;
22 
24  {
25  public:
26  static const std::string State_Key;
27  enum State {
28  State_Error = 1,
31  };
32  static const std::string Error_Reason_Key;
33  static const std::string UserAuthPrefix;
34 
35  virtual ~AuthProvider() {}
36  CapabilityMap processAuth(const CapabilityMap& authData);
37  protected:
38  /*
39  * Processes an authentication messages, then returns a map of values.
40  * The returned map MUST include an element at index `State_Token`,
41  * containing:
42  * - `State_Error` if the authentication attempt is unsuccessful; if a
43  * value exists at index `Error_Reason_Key` it will be sent to the client.
44  * - `State_Cont` if the authentication attempt needs further processing;
45  * the rest of the map will be sent to the client.
46  * - `State_Done` if the authentication succeeded. The rest of the map will
47  * be left unused.
48  * If this token is missing or yields an unknown value the server will assert()
49  * and terminate the client's connection.
50  */
51  virtual CapabilityMap _processAuth(const CapabilityMap& authData) = 0;
52  };
53 
54  typedef boost::shared_ptr<AuthProvider> AuthProviderPtr;
55 }
56 
57 #endif
#define QI_API
Definition: api.hpp:34
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