Add extracted tools: CitrineOS, OpenOCPP, ShapeShifter

- CitrineOS core extracted (CSMS OCPP 2.0.1)
- OpenOCPP extracted (firmware OCPP 1.6J/2.0.1)
- ShapeShifter library installed (pip install -e)
- ShapeShifter specification extracted
- EVerest extracted

TODO updated with progress
This commit is contained in:
Eric F
2026-06-08 00:38:27 -04:00
parent 468cfeaa50
commit d398a6ced2
7326 changed files with 1177561 additions and 7 deletions

View File

@@ -0,0 +1,124 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2020 - 2022 Pionix GmbH and Contributors to EVerest
#include "auth_token_validatorImpl.hpp"
#include <conversions.hpp>
#include <everest/conversions/ocpp/ocpp_conversions.hpp>
#include <ocpp/common/types.hpp>
#include <ocpp/v16/ocpp_enums.hpp>
#include <ocpp/v2/ocpp_types.hpp>
namespace module {
namespace auth_validator {
void auth_token_validatorImpl::init() {
}
void auth_token_validatorImpl::ready() {
}
types::authorization::ValidationResult
auth_token_validatorImpl::handle_validate_token(types::authorization::ProvidedIdToken& provided_token) {
if (this->mod->charge_point == nullptr) {
EVLOG_warning << "ChargePoint not initialized, cannot handle validate token command";
types::authorization::ValidationResult result;
result.authorization_status = types::authorization::AuthorizationStatus::Unknown;
return result;
}
if (provided_token.authorization_type == types::authorization::AuthorizationType::PlugAndCharge) {
return validate_pnc_request(provided_token);
} else {
return validate_standard_request(provided_token);
}
};
types::authorization::ValidationResult
auth_token_validatorImpl::validate_pnc_request(const types::authorization::ProvidedIdToken& provided_token) {
types::authorization::ValidationResult validation_result;
try {
// preparing payload for data_transfer_pnc_authorize
std::optional<std::vector<ocpp::v2::OCSPRequestData>> iso15118_certificate_hash_data_opt;
if (provided_token.iso15118CertificateHashData.has_value()) {
std::vector<ocpp::v2::OCSPRequestData> iso15118_certificate_hash_data;
for (const auto& certificate_hash_data : provided_token.iso15118CertificateHashData.value()) {
ocpp::v2::OCSPRequestData v2_certificate_hash_data;
v2_certificate_hash_data.hashAlgorithm =
conversions::to_ocpp_hash_algorithm_enum(certificate_hash_data.hashAlgorithm);
v2_certificate_hash_data.issuerKeyHash = certificate_hash_data.issuerKeyHash;
v2_certificate_hash_data.issuerNameHash = certificate_hash_data.issuerNameHash;
v2_certificate_hash_data.responderURL = certificate_hash_data.responderURL;
v2_certificate_hash_data.serialNumber = certificate_hash_data.serialNumber;
iso15118_certificate_hash_data.push_back(v2_certificate_hash_data);
}
iso15118_certificate_hash_data_opt.emplace(iso15118_certificate_hash_data);
}
// this is the actual OCPP request via DataTransfer.req to CSMS according to
// PnC1.6 whitepaper
const auto authorize_response = mod->charge_point->data_transfer_pnc_authorize(
provided_token.id_token.value, provided_token.certificate, iso15118_certificate_hash_data_opt);
validation_result.authorization_status =
conversions::to_everest_authorization_status(authorize_response.idTokenInfo.status);
validation_result.evse_ids = authorize_response.idTokenInfo.evseId;
if (authorize_response.certificateStatus.has_value()) {
validation_result.certificate_status.emplace(
conversions::to_everest_certificate_status(authorize_response.certificateStatus.value()));
}
if (authorize_response.idTokenInfo.cacheExpiryDateTime.has_value()) {
validation_result.expiry_time.emplace(
authorize_response.idTokenInfo.cacheExpiryDateTime.value().to_rfc3339());
}
if (authorize_response.idTokenInfo.groupIdToken.has_value()) {
validation_result.parent_id_token = {authorize_response.idTokenInfo.groupIdToken.value().idToken.get(),
types::authorization::IdTokenType::Central};
}
} catch (const ocpp::StringConversionException& e) {
EVLOG_warning << "Error converting id token to validate: " << e.what();
validation_result.authorization_status = types::authorization::AuthorizationStatus::Unknown;
} catch (const std::exception& e) {
EVLOG_warning << "Unknown error during validation of id token: " << e.what();
validation_result.authorization_status = types::authorization::AuthorizationStatus::Unknown;
}
return validation_result;
}
types::authorization::ValidationResult
auth_token_validatorImpl::validate_standard_request(const types::authorization::ProvidedIdToken& provided_token) {
types::authorization::ValidationResult result;
try {
const auto enhanced_id_tag_info =
mod->charge_point->authorize_id_token(ocpp::CiString<20>(provided_token.id_token.value));
const auto id_tag_info = enhanced_id_tag_info.id_tag_info;
result.authorization_status = conversions::to_everest_authorization_status(id_tag_info.status);
if (id_tag_info.expiryDate) {
result.expiry_time = id_tag_info.expiryDate->to_rfc3339();
}
if (id_tag_info.parentIdTag) {
result.parent_id_token = {
id_tag_info.parentIdTag->get(),
types::authorization::IdTokenType::Central}; // For OCPP1.6 no IdTokenType is given,
// so we assume it is a central token
}
if (enhanced_id_tag_info.tariff_message.has_value()) {
// this can be used as the TT field of the OCMF.
const auto& tariff_message = enhanced_id_tag_info.tariff_message.value();
for (const auto& message : tariff_message.message) {
result.tariff_messages.push_back(ocpp_conversions::to_everest_display_message_content(message));
}
}
} catch (const ocpp::StringConversionException& e) {
EVLOG_warning << "Error converting id token to validate: " << e.what();
result.authorization_status = types::authorization::AuthorizationStatus::Unknown;
} catch (const std::exception& e) {
EVLOG_warning << "Unknown error during validation of id token: " << e.what();
result.authorization_status = types::authorization::AuthorizationStatus::Unknown;
}
return result;
};
} // namespace auth_validator
} // namespace module

View File

@@ -0,0 +1,66 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest
#ifndef AUTH_VALIDATOR_AUTH_TOKEN_VALIDATOR_IMPL_HPP
#define AUTH_VALIDATOR_AUTH_TOKEN_VALIDATOR_IMPL_HPP
//
// AUTO GENERATED - MARKED REGIONS WILL BE KEPT
// template version 3
//
#include <generated/interfaces/auth_token_validator/Implementation.hpp>
#include "../OCPP.hpp"
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
// insert your custom include headers here
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1
namespace module {
namespace auth_validator {
struct Conf {};
class auth_token_validatorImpl : public auth_token_validatorImplBase {
public:
auth_token_validatorImpl() = delete;
auth_token_validatorImpl(Everest::ModuleAdapter* ev, const Everest::PtrContainer<OCPP>& mod, Conf& config) :
auth_token_validatorImplBase(ev, "auth_validator"), mod(mod), config(config){};
// ev@8ea32d28-373f-4c90-ae5e-b4fcc74e2a61:v1
// insert your public definitions here
// ev@8ea32d28-373f-4c90-ae5e-b4fcc74e2a61:v1
protected:
// command handler functions (virtual)
virtual types::authorization::ValidationResult
handle_validate_token(types::authorization::ProvidedIdToken& provided_token) override;
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1
// insert your protected definitions here
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1
private:
const Everest::PtrContainer<OCPP>& mod;
const Conf& config;
virtual void init() override;
virtual void ready() override;
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1
// insert your private definitions here
types::authorization::ValidationResult
validate_standard_request(const types::authorization::ProvidedIdToken& provided_token);
types::authorization::ValidationResult
validate_pnc_request(const types::authorization::ProvidedIdToken& provided_token);
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1
};
// ev@3d7da0ad-02c2-493d-9920-0bbbd56b9876:v1
// insert other definitions here
// ev@3d7da0ad-02c2-493d-9920-0bbbd56b9876:v1
} // namespace auth_validator
} // namespace module
#endif // AUTH_VALIDATOR_AUTH_TOKEN_VALIDATOR_IMPL_HPP