driver_authenticator.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2015 Aldebaran
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef DRIVER_AUTHENTICATOR_HPP
19 #define DRIVER_AUTHENTICATOR_HPP
20 
21 #include <qi/messaging/authprovider.hpp>
22 
23 namespace naoqi {
24 
25 class DriverAuthenticator : public qi::ClientAuthenticator {
26 public:
27  static const std::string user_key;
28  static const std::string pass_key;
29 
31  const std::string& user,
32  const std::string& pass) : _u(user), _p(pass) {}
33 
34  qi::CapabilityMap initialAuthData() {
35  qi::CapabilityMap result;
36  result[DriverAuthenticator::user_key] = qi::AnyValue::from(_u);
37  result[DriverAuthenticator::pass_key] = qi::AnyValue::from(_p);
38  return result;
39  }
40 
41  qi::CapabilityMap _processAuth(const qi::CapabilityMap&) {
42  return qi::CapabilityMap();
43  }
44 private:
45  std::string _u;
46  std::string _p;
47 };
48 
49 const std::string DriverAuthenticator::user_key = "user";
50 const std::string DriverAuthenticator::pass_key = "token";
51 
52 class DriverAuthenticatorFactory : public qi::ClientAuthenticatorFactory {
53 public:
54  std::string user;
55  std::string pass;
56 
57  qi::ClientAuthenticatorPtr newAuthenticator() {
58  return boost::make_shared<DriverAuthenticator>(user, pass);
59  }
60 };
61 
62 }
63 
64 #endif // DRIVER_AUTHENTICATOR
qi::CapabilityMap _processAuth(const qi::CapabilityMap &)
qi::ClientAuthenticatorPtr newAuthenticator()
DriverAuthenticator(const std::string &user, const std::string &pass)
qi::CapabilityMap initialAuthData()
static const std::string user_key
static const std::string pass_key


naoqi_driver
Author(s): Karsten Knese
autogenerated on Sat Jul 1 2023 02:53:24