AuthenticationLegacy.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2023 SICK AG, Waldkirch
3 //
4 // SPDX-License-Identifier: Unlicense
5 
6 #include "AuthenticationLegacy.h"
7 #include "CoLaParameterReader.h"
8 #include "CoLaParameterWriter.h"
9 
10 namespace visionary {
11 
13 {
14 }
15 
17 
18 bool AuthenticationLegacy::login(UserLevel userLevel, const std::string& password)
19 {
21  .parameterSInt(static_cast<int8_t>(userLevel))
22  .parameterPasswordMD5(password)
23  .build();
24  CoLaCommand loginResponse = m_VisionaryControl.sendCommand(loginCommand);
25 
26  if (loginResponse.getError() == CoLaError::OK)
27  {
28  return CoLaParameterReader(loginResponse).readBool();
29  }
30  return false;
31 }
32 
34 {
36  CoLaCommand runResponse = m_VisionaryControl.sendCommand(runCommand);
37 
38  if (runResponse.getError() == CoLaError::OK)
39  {
40  return CoLaParameterReader(runResponse).readBool();
41  }
42  return false;
43 }
44 
45 } // namespace visionary
visionary::IAuthentication::UserLevel
UserLevel
Available CoLa user levels.
Definition: IAuthentication.h:15
visionary::CoLaParameterReader
Class for reading data from a CoLaCommand.
Definition: CoLaParameterReader.h:17
visionary::AuthenticationLegacy::login
bool login(UserLevel userLevel, const std::string &password) override
Definition: AuthenticationLegacy.cpp:18
visionary
Definition: MD5.cpp:44
visionary::CoLaCommand::getError
CoLaError::Enum getError() const
Get error.
Definition: CoLaCommand.cpp:159
visionary::CoLaParameterWriter
Builder for constructing CoLaCommands.
Definition: CoLaParameterWriter.h:19
visionary::CoLaCommand
Definition: CoLaCommand.h:17
visionary::CoLaError::OK
@ OK
No error.
Definition: CoLaError.h:19
visionary::AuthenticationLegacy::AuthenticationLegacy
AuthenticationLegacy(VisionaryControl &vctrl)
Definition: AuthenticationLegacy.cpp:12
CoLaParameterWriter.h
visionary::AuthenticationLegacy::~AuthenticationLegacy
~AuthenticationLegacy() override
visionary::AuthenticationLegacy::logout
bool logout() override
Definition: AuthenticationLegacy.cpp:33
visionary::CoLaCommandType::METHOD_INVOCATION
@ METHOD_INVOCATION
Definition: CoLaCommandType.h:20
visionary::CoLaParameterWriter::parameterSInt
CoLaParameterWriter & parameterSInt(const int8_t sInt)
Add a signed short (8-bit, range [-128, 127]).
Definition: CoLaParameterWriter.cpp:24
visionary::CoLaParameterReader::readBool
bool readBool()
Read a boolean and advance the position by 1 byte. Throws an std::out_of_range exception if CoLaComma...
Definition: CoLaParameterReader.cpp:94
visionary::VisionaryControl::sendCommand
CoLaCommand sendCommand(const CoLaCommand &command)
Send a CoLaBCommand to the device and waits for the result.
Definition: VisionaryControl.cpp:201
visionary::AuthenticationLegacy::m_VisionaryControl
VisionaryControl & m_VisionaryControl
Definition: AuthenticationLegacy.h:21
CoLaParameterReader.h
visionary::CoLaParameterWriter::parameterPasswordMD5
CoLaParameterWriter & parameterPasswordMD5(const std::string &str)
Add the given password as a UDInt, using MD5 hashing.
Definition: CoLaParameterWriter.cpp:96
AuthenticationLegacy.h
visionary::VisionaryControl
Definition: VisionaryControl.h:19
visionary::CoLaParameterWriter::build
const CoLaCommand build()
Definition: CoLaParameterWriter.cpp:181


sick_visionary_ros
Author(s): SICK AG TechSupport 3D Snapshot
autogenerated on Thu Feb 8 2024 03:36:38