From 0ab72733d5b9b4a31c8619e2f540b25907f01eb4 Mon Sep 17 00:00:00 2001 From: Viktor UZLOV Date: Wed, 3 Nov 2021 14:40:21 +0300 Subject: [PATCH] Add SSL mode --- src/engine/BL_NamingService_Wrapper.cxx | 47 ++++++++++++++++++++ src/engine/BL_NamingService_Wrapper.hxx | 57 +++++++++++++++++++++++++ src/engine/BL_SALOMEServices.cxx | 2 +- src/engine/BL_SALOMEServices.hxx | 3 +- src/engine/CMakeLists.txt | 2 + src/salomegui/CMakeLists.txt | 1 + 6 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 src/engine/BL_NamingService_Wrapper.cxx create mode 100644 src/engine/BL_NamingService_Wrapper.hxx diff --git a/src/engine/BL_NamingService_Wrapper.cxx b/src/engine/BL_NamingService_Wrapper.cxx new file mode 100644 index 0000000..1e2322e --- /dev/null +++ b/src/engine/BL_NamingService_Wrapper.cxx @@ -0,0 +1,47 @@ +// Copyright (C) 2021 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "BL_NamingService_Wrapper.hxx" + +#include "SALOME_NamingService.hxx" +#include "SALOME_Fake_NamingService.hxx" +#include "KernelBasis.hxx" + +BL_SALOME_NamingService_Wrapper::BL_SALOME_NamingService_Wrapper() +{ + this->initializeEffectiveNS(); +} + +BL_SALOME_NamingService_Wrapper::BL_SALOME_NamingService_Wrapper(CORBA::ORB_ptr orb) +{ + this->initializeEffectiveNS(); + this->_effective_ns->init_orb(orb); +} + +BL_SALOME_NamingService_Wrapper::BL_SALOME_NamingService_Wrapper(const BL_SALOME_NamingService_Wrapper& other):_effective_ns(other._effective_ns->cloneCoVar()) +{ +} + +void BL_SALOME_NamingService_Wrapper::initializeEffectiveNS() +{ + if(getSSLMode()) + _effective_ns.reset( new SALOME_Fake_NamingService ); + else + _effective_ns.reset( new SALOME_NamingService ); +} diff --git a/src/engine/BL_NamingService_Wrapper.hxx b/src/engine/BL_NamingService_Wrapper.hxx new file mode 100644 index 0000000..d77163d --- /dev/null +++ b/src/engine/BL_NamingService_Wrapper.hxx @@ -0,0 +1,57 @@ +// Copyright (C) 2021 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#pragma once + +#include "SALOME_NamingService_Abstract.hxx" +#include "BL_Engine.hxx" + +#include + +/*! + * Decorator class that allows YACS engine to switch between : + * - NamingService CORBA server (SALOME_NamingService) + * - NamingService embedded (SALOME_Fake_NamingService) + */ +class BL_Engine_EXPORT BL_SALOME_NamingService_Wrapper : public SALOME_NamingService_Abstract +{ +public: + BL_SALOME_NamingService_Wrapper(); + BL_SALOME_NamingService_Wrapper(CORBA::ORB_ptr orb); + std::vector< std::string > repr() override { return _effective_ns->repr(); } + void init_orb(CORBA::ORB_ptr orb=0) override { _effective_ns->init_orb(orb); } + bool IsTrueNS() const override { return _effective_ns->IsTrueNS(); } + void Register(CORBA::Object_ptr ObjRef, const char* Path) override { _effective_ns->Register(ObjRef,Path); } + CORBA::Object_ptr Resolve(const char* Path) override { return _effective_ns->Resolve(Path); } + CORBA::Object_ptr ResolveFirst(const char* Path) override { return _effective_ns->ResolveFirst(Path); } + void Destroy_Name(const char* Path) override { _effective_ns->Destroy_Name(Path); } + void Destroy_Directory(const char* Path) override { _effective_ns->Destroy_Directory(Path); } + void Destroy_FullDirectory(const char* Path) override { _effective_ns->Destroy_FullDirectory(Path); } + bool Change_Directory(const char* Path) override { return _effective_ns->Change_Directory(Path); } + std::vector list_subdirs() override { return _effective_ns->list_directory(); } + std::vector list_directory() override { return _effective_ns->list_directory(); } + std::vector list_directory_recurs() override { return _effective_ns->list_directory_recurs(); } + SALOME_NamingService_Abstract *clone() override { return new BL_SALOME_NamingService_Wrapper(*this); } + CORBA::Object_ptr ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc=0) override { return _effective_ns->ResolveComponent(hostname,containerName,componentName,nbproc); } +private: + BL_SALOME_NamingService_Wrapper(const BL_SALOME_NamingService_Wrapper& other); + void initializeEffectiveNS(); +private: + std::unique_ptr _effective_ns; +}; diff --git a/src/engine/BL_SALOMEServices.cxx b/src/engine/BL_SALOMEServices.cxx index 25cbb0f..ff67bd0 100644 --- a/src/engine/BL_SALOMEServices.cxx +++ b/src/engine/BL_SALOMEServices.cxx @@ -61,7 +61,7 @@ bool BL::SALOMEServices::initNS() { bool return_value = true; - _salome_naming_service = new SALOME_NamingService(_orb); + _salome_naming_service = new BL_SALOME_NamingService_Wrapper(_orb); _lcc = new SALOME_LifeCycleCORBA(_salome_naming_service); CORBA::Object_var obj = _salome_naming_service->Resolve("/SalomeLauncher"); _salome_launcher = Engines::SalomeLauncher::_narrow(obj); diff --git a/src/engine/BL_SALOMEServices.hxx b/src/engine/BL_SALOMEServices.hxx index 83f141a..dd7e0f6 100644 --- a/src/engine/BL_SALOMEServices.hxx +++ b/src/engine/BL_SALOMEServices.hxx @@ -23,6 +23,7 @@ #include "BL_Engine.hxx" #include "BL_Traces.hxx" #include "BL_Job.hxx" +#include "BL_NamingService_Wrapper.hxx" #include "SALOME_NamingService.hxx" #include "SALOME_LifeCycleCORBA.hxx" @@ -97,7 +98,7 @@ namespace BL{ private: CORBA::ORB_var _orb; - SALOME_NamingService * _salome_naming_service; + BL_SALOME_NamingService_Wrapper * _salome_naming_service; SALOME_LifeCycleCORBA * _lcc; Engines::SalomeLauncher_var _salome_launcher; Engines::ResourcesManager_var _resources_manager; diff --git a/src/engine/CMakeLists.txt b/src/engine/CMakeLists.txt index d1e9493..94ada39 100644 --- a/src/engine/CMakeLists.txt +++ b/src/engine/CMakeLists.txt @@ -53,6 +53,8 @@ SET(BL_Engine_SOURCES BL_SALOMEServices.hxx BL_SALOMEServices.cxx BL_Observer.hxx + BL_NamingService_Wrapper.hxx + BL_NamingService_Wrapper.cxx ) # --- rules --- diff --git a/src/salomegui/CMakeLists.txt b/src/salomegui/CMakeLists.txt index 460aaba..7cb164e 100644 --- a/src/salomegui/CMakeLists.txt +++ b/src/salomegui/CMakeLists.txt @@ -70,6 +70,7 @@ SET(_other_SOURCES # --- resources --- SALOME_CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/resources/SalomeApp.xml.in ${CMAKE_CURRENT_BINARY_DIR}/resources/SalomeApp.xml INSTALL ${SALOME_JOBMANAGER_INSTALL_RES_DATA}) +SALOME_CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/resources/SalomeApp.xml.in ${CMAKE_CURRENT_BINARY_DIR}/resources/SalomeAppSL.xml INSTALL ${SALOME_JOBMANAGER_INSTALL_RES_DATA}) # resource files / static SET(_other_RESOURCES -- 2.39.2