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
naoqi::DriverAuthenticator::initialAuthData
qi::CapabilityMap initialAuthData()
Definition: driver_authenticator.hpp:34
naoqi::DriverAuthenticatorFactory
Definition: driver_authenticator.hpp:52
naoqi::DriverAuthenticator::user_key
static const std::string user_key
Definition: driver_authenticator.hpp:27
naoqi
Definition: converter.hpp:29
naoqi::DriverAuthenticator::pass_key
static const std::string pass_key
Definition: driver_authenticator.hpp:28
naoqi::DriverAuthenticatorFactory::newAuthenticator
qi::ClientAuthenticatorPtr newAuthenticator()
Definition: driver_authenticator.hpp:57
naoqi::DriverAuthenticator
Definition: driver_authenticator.hpp:25
naoqi::DriverAuthenticator::_u
std::string _u
Definition: driver_authenticator.hpp:45
naoqi::DriverAuthenticatorFactory::user
std::string user
Definition: driver_authenticator.hpp:54
naoqi::DriverAuthenticatorFactory::pass
std::string pass
Definition: driver_authenticator.hpp:55
naoqi::DriverAuthenticator::_p
std::string _p
Definition: driver_authenticator.hpp:46
naoqi::DriverAuthenticator::_processAuth
qi::CapabilityMap _processAuth(const qi::CapabilityMap &)
Definition: driver_authenticator.hpp:41
naoqi::DriverAuthenticator::DriverAuthenticator
DriverAuthenticator(const std::string &user, const std::string &pass)
Definition: driver_authenticator.hpp:30


naoqi_driver
Author(s): Karsten Knese
autogenerated on Sat Feb 3 2024 03:50:06