From 37b87b7653b19025443880c1c7b63e9cb90aeff8 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Wed, 9 Feb 2022 06:30:09 -0800 Subject: [PATCH] ConnectionContextStore to expose API to retrieve store items path Summary: ^ This change allow callers to retrieve the path of different store items some of which are used for connection authentication. Reviewed By: aigoncharov Differential Revision: D34081942 fbshipit-source-id: c6b8d3590993de6c48a36266a5c16f2caf9f5a93 --- xplat/Flipper/ConnectionContextStore.cpp | 17 +++++++++++++++++ xplat/Flipper/ConnectionContextStore.h | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/xplat/Flipper/ConnectionContextStore.cpp b/xplat/Flipper/ConnectionContextStore.cpp index 04f5547ab..c661c657a 100644 --- a/xplat/Flipper/ConnectionContextStore.cpp +++ b/xplat/Flipper/ConnectionContextStore.cpp @@ -150,6 +150,23 @@ std::string ConnectionContextStore::getCACertificatePath() { return absoluteFilePath(FLIPPER_CA_FILE_NAME); } +std::string ConnectionContextStore::getPath(StoreItem storeItem) { + switch (storeItem) { + case CSR: + return absoluteFilePath(CSR_FILE_NAME); + case FLIPPER_CA: + return absoluteFilePath(FLIPPER_CA_FILE_NAME); + case CLIENT_CERT: + return absoluteFilePath(CLIENT_CERT_FILE_NAME); + case PRIVATE_KEY: + return absoluteFilePath(PRIVATE_KEY_FILE); + case CERTIFICATE: + return absoluteFilePath(CERTIFICATE_FILE_NAME); + case CONNECTION_CONFIG: + return absoluteFilePath(CONNECTION_CONFIG_FILE); + } +} + bool ConnectionContextStore::resetState() { // Clear in-memory state csr = ""; diff --git a/xplat/Flipper/ConnectionContextStore.h b/xplat/Flipper/ConnectionContextStore.h index 9cfac0c8f..be551b555 100644 --- a/xplat/Flipper/ConnectionContextStore.h +++ b/xplat/Flipper/ConnectionContextStore.h @@ -19,6 +19,14 @@ namespace flipper { class ConnectionContextStore { public: + enum StoreItem { + CSR, + FLIPPER_CA, + CLIENT_CERT, + PRIVATE_KEY, + CERTIFICATE, + CONNECTION_CONFIG, + }; ConnectionContextStore(DeviceData deviceData); bool hasRequiredFiles(); std::string getCertificateSigningRequest(); @@ -26,6 +34,7 @@ class ConnectionContextStore { std::string getCertificateDirectoryPath(); std::string getCACertificatePath(); std::string getDeviceId(); + std::string getPath(StoreItem storeItem); /** * Get medium over which the certificate was received. */