-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
validate CSMS-URL: opt. schema must fit with security-profile; charge…
…point-ID deprecated in URL (#201) Signed-off-by: Dominik K <[email protected]>
- Loading branch information
Showing
19 changed files
with
321 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[*.json] | ||
indent_style = space | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,6 +174,7 @@ | |
"required": [ | ||
"CertificateEntries", | ||
"OrganizationName", | ||
"SecurityProfile" | ||
"SecurityProfile", | ||
"Identity" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest | ||
#ifndef OCPP_WEBSOCKET_URI_HPP | ||
#define OCPP_WEBSOCKET_URI_HPP | ||
|
||
#include <string> | ||
#include <string_view> | ||
#include <websocketpp/uri.hpp> | ||
|
||
namespace ocpp { | ||
|
||
class Uri { | ||
public: | ||
Uri(){}; | ||
|
||
// clang-format off | ||
/// \brief parse_and_validate parses the \p uri and checks | ||
/// 1. the general validity of it and | ||
/// 2. if optional scheme fits to given \p security_profile | ||
/// | ||
/// \param uri The whole URI with optional scheme and \p chargepoint_id as last segment (as backward-compatibility). | ||
/// \param chargepoint_id The identifier unique to the CSMS. | ||
/// \param security_profile The security-profile. | ||
/// \returns Uri | ||
/// \throws std::invalid_argument for several checks | ||
// clang-format on | ||
static Uri parse_and_validate(std::string uri, std::string chargepoint_id, int security_profile); | ||
|
||
/// \brief set_secure defines if the connection is done via TLS | ||
/// | ||
/// \param secure true: connect via TLS; false: connect as plaintext | ||
void set_secure(bool secure) { | ||
this->secure = secure; | ||
} | ||
|
||
std::string get_hostname() { | ||
return this->host; | ||
} | ||
std::string get_chargepoint_id() { | ||
return this->chargepoint_id; | ||
} | ||
|
||
std::string string() { | ||
auto uri = get_websocketpp_uri(); | ||
return uri.str(); | ||
} | ||
|
||
websocketpp::uri get_websocketpp_uri() { // FIXME: wrap needed `websocketpp:uri` functionality inside `Uri` | ||
return websocketpp::uri(this->secure, this->host, this->port, | ||
this->path_without_chargepoint_id /* is normalized with ending slash */ + | ||
this->chargepoint_id); | ||
} | ||
|
||
private: | ||
Uri(bool secure, const std::string& host, uint16_t port, const std::string& path_without_chargepoint_id, | ||
const std::string& chargepoint_id) : | ||
secure(secure), | ||
host(host), | ||
port(port), | ||
path_without_chargepoint_id(path_without_chargepoint_id), | ||
chargepoint_id(chargepoint_id) { | ||
} | ||
|
||
bool secure; | ||
std::string host; | ||
uint16_t port; | ||
std::string path_without_chargepoint_id; | ||
std::string chargepoint_id; | ||
}; | ||
|
||
} // namespace ocpp | ||
|
||
#endif // OCPP_WEBSOCKET_URI_HPP */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.