Merge 51884dd6329328e69bb651f5056af5d5b6c924c1 into 590fd624a4d7ddd4fed6de4113129e08e71d262a

This commit is contained in:
august-alt 2024-12-02 16:39:19 +00:00 committed by GitHub
commit 6ddf9002be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
81 changed files with 6663 additions and 0 deletions

View File

@ -97,7 +97,10 @@ LD_PRELOAD=%buildroot%_libdir/gpui/plugins/libadministrative-templates-plugin.so
%_libdir/gpui/plugins/libreg-plugin.so
%_libdir/gpui/plugins/libspol-plugin.so
%_libdir/gpui/plugins/libpol-plugin.so
%_libdir/gpui/plugins/libsdml-plugin.so
%_libdir/gpui/plugins/libsdmx-plugin.so
%_libdir/gpui/plugins/libscripts-plugin.so
%_libdir/gpui/plugins/libsecurity-plugin.so
%_libdir/gpui/plugins/libsmb-storage-plugin.so

2
.gitignore vendored
View File

@ -89,5 +89,7 @@ src/plugins/cmtl/schema/*.cpp
src/plugins/cmtl/schema/*.h
src/plugins/cmtx/schema/*.cpp
src/plugins/cmtx/schema/*.h
src/plugins/security/schema/*.cpp
src/plugins/security/schema/*.h
*.translations.qrc
src/core/version.h

View File

@ -9,6 +9,10 @@ execute_process(
OUTPUT_VARIABLE GPUI_GEAR_VERSION
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
string(REPLACE "." ";" GEAR_VERSION_LIST ${GPUI_GEAR_VERSION})
list(GET GEAR_VERSION_LIST 0 GPUI_VERSION_MAJOR)
list(GET GEAR_VERSION_LIST 1 GPUI_VERSION_MINOR)

View File

@ -1,6 +1,8 @@
find_package(Qt5 COMPONENTS Core REQUIRED)
set(HEADERS
basefile.h
basefile.inl
genericfile.h
genericfile.inl
genericreader.h

66
src/io/basefile.h Normal file
View File

@ -0,0 +1,66 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef GPUI_BASEFILE_H
#define GPUI_BASEFILE_H
#include "io.h"
#include "genericfile.h"
#include "policyfileformat.h"
#include <memory>
namespace io {
template <typename TContent>
class BaseFilePrivate;
template <typename TContent>
class GPUI_IO_EXPORT BaseFile : public GenericFile<BaseFile<TContent>, PolicyFileFormat<BaseFile<TContent>>>
{
public:
BaseFile();
~BaseFile();
void add(std::shared_ptr<TContent> resources);
void remove(std::shared_ptr<TContent> resources);
std::vector<std::shared_ptr<TContent>> getAll();
size_t count();
std::shared_ptr<TContent> get(const size_t index);
private:
BaseFile(const BaseFile&) = delete; // copy ctor
BaseFile(BaseFile&&) = delete; // move ctor
BaseFile& operator=(const BaseFile&) = delete; // copy assignment
BaseFile& operator=(BaseFile&&) = delete; // move assignment
private:
BaseFilePrivate<TContent>* const d;
};
}
#include "basefile.inl"
#endif // GPUI_BASEFILE_H

112
src/io/basefile.inl Normal file
View File

@ -0,0 +1,112 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#include <algorithm>
namespace io
{
template <typename TContent>
class BaseFilePrivate
{
public:
std::vector<std::shared_ptr<TContent>> definitions = {};
};
/*!
* \class BaseFile BaseFile.h
* \brief The BaseFile class represents a policy file.
* \ingroup io
*
* The BaseFile class provides a container for definitions.
*/
template <typename TContent>
BaseFile<TContent>::BaseFile()
: GenericFile<BaseFile, PolicyFileFormat<BaseFile>>()
, d(new BaseFilePrivate<TContent>())
{}
template <typename TContent>
BaseFile<TContent>::~BaseFile()
{
delete d;
}
/*!
* \brief BaseFile<TContent>::addPolicyDefinitions Adds definitions to the file.
* \param policyDefinitions Policy definitions to add.
*/
template <typename TContent>
void BaseFile<TContent>::add(std::shared_ptr<TContent> definitions)
{
d->definitions.emplace_back(definitions);
}
/*!
* \brief BaseFile<TContent>::removePolicyDefinitions Removes policy definitions from the file.
* \param policyDefinitions Policy definitions to remove.
*/
template <typename TContent>
void BaseFile<TContent>::remove(std::shared_ptr<TContent> definitions)
{
d->definitions.erase(std::remove_if(d->definitions.begin(),
d->definitions.end(),
[definitions](std::shared_ptr<TContent> currentPolicy) {
return currentPolicy == definitions;
}));
}
/*!
* \brief BaseFile<TContent>::getAllPolicyDefinitions Returns all definitions from the file.
* \return
*/
template <typename TContent>
std::vector<std::shared_ptr<TContent>> BaseFile<TContent>::getAll()
{
return d->definitions;
}
/*!
* \brief BaseFile<TContent>::policyDefinitionsCount Return number of definitions in current file.
* \return Amount of policy definitions in current file.
*/
template <typename TContent>
size_t BaseFile<TContent>::count()
{
return d->definitions.size();
}
/*!
* \brief BaseFile<TContent>::getPolicyDefinitions Returns a definition by index.
* \param index Index of a definitions.
* \return If definitions are found than returns definitions otherwise retruns null pointer.
*/
template <typename TContent>
std::shared_ptr<TContent> BaseFile<TContent>::get(const size_t index)
{
if (index < d->definitions.size())
{
return d->definitions[index];
}
return std::shared_ptr<TContent>(nullptr);
}
} // namespace io

View File

@ -26,6 +26,9 @@ add_subdirectory(ini_ascii)
add_subdirectory(pol)
add_subdirectory(preferences)
add_subdirectory(reg)
add_subdirectory(sdml)
add_subdirectory(sdmx)
add_subdirectory(scripts)
add_subdirectory(security)
add_subdirectory(spol)
add_subdirectory(storage)

View File

@ -86,7 +86,9 @@ void ScriptsTreeModel::populateModel()
machineNamespace->setProperty(ScriptsFolderItem::CATEGORY, true);
auto machineSystemSettings = insertItem<ScriptsFolderItem>(machineNamespace);
auto machineSystemUuid = QUuid("{123e4567-e89b-12d3-a456-426652340010}");
machineSystemSettings->setDisplayName(QObject::tr("System settings").toStdString());
machineSystemSettings->setProperty(ScriptsFolderItem::NODE_ID, machineSystemUuid);
machineSystemSettings->setProperty(ScriptsFolderItem::PARENT_ID, machineUuid);
machineSystemSettings->setProperty(ScriptsFolderItem::HELP_MSG,
QObject::tr("System settings for computer").toStdString());
@ -110,7 +112,9 @@ void ScriptsTreeModel::populateModel()
userNamespace->setProperty(ScriptsFolderItem::CATEGORY, true);
auto userSystemSetting = insertItem<ScriptsFolderItem>(userNamespace);
auto userSystemUuid = QUuid("{123e4567-e89b-12d3-a456-426652340011}");
userSystemSetting->setDisplayName(QObject::tr("System settings").toStdString());
userSystemSetting->setProperty(ScriptsFolderItem::NODE_ID, userSystemUuid);
userSystemSetting->setProperty(ScriptsFolderItem::PARENT_ID, userUuid);
userSystemSetting->setProperty(ScriptsFolderItem::HELP_MSG,
QObject::tr("System settings for user").toStdString());

View File

@ -0,0 +1,24 @@
find_package(GPUI COMPONENTS core io REQUIRED)
include_directories(${GPUI_INCLUDE_DIRS})
find_package(Qt5 COMPONENTS Core REQUIRED)
set(PLUGIN_NAME "sdml-plugin")
set(HEADERS
sdmlformat.h
)
set(SOURCES
sdmlformat.cpp
sdmlplugin.cpp
)
set(SOURCES ${SOURCES} ${HEADERS})
add_gpui_plugin(${PLUGIN_NAME} ${SOURCES})
target_link_libraries(${PLUGIN_NAME} Qt5::Core)
target_link_libraries(${PLUGIN_NAME} ${GPUI_LIBRARIES})
target_link_libraries(${PLUGIN_NAME} policy-common)
target_link_libraries(${PLUGIN_NAME} security_static_xsd_library)
target_link_libraries(${PLUGIN_NAME} xerces-c)

View File

@ -0,0 +1,474 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#include "sdmlformat.h"
#include "../security/schema/security.h"
#include "../security/model/presentation/securitypresentationresources.h"
#include "../common/exceptionhandler.h"
namespace gpui
{
template<typename TInput, typename TOutput>
inline void assign_if_exists(TOutput &output, const TInput &input)
{
if (input.present())
{
output = input.get();
}
}
class XsdCheckBoxAdapter : public security::CheckBox
{
private:
typedef ::GroupPolicy::SecurityDefinitions::CheckBox CheckBox;
public:
XsdCheckBoxAdapter(const CheckBox &widget)
: security::CheckBox()
{
this->defaultChecked = widget.defaultChecked();
assign_if_exists(this->postfix, widget.postfix());
}
static std::shared_ptr<security::CheckBox> create(const CheckBox &widget)
{
return std::make_shared<XsdCheckBoxAdapter>(widget);
}
};
class XsdComboBoxAdapter : public security::ComboBox
{
private:
typedef ::GroupPolicy::SecurityDefinitions::ComboBox ComboBox;
public:
XsdComboBoxAdapter(const ComboBox &widget)
: security::ComboBox()
{
this->refId = widget.refId();
assign_if_exists(this->postfix, widget.postfix());
assign_if_exists(this->defaultValue, widget.defaultChecked());
for (const auto& suggestionText : widget.suggestion())
{
this->suggestion.emplace_back(suggestionText);
}
}
static std::shared_ptr<security::ComboBox> create(const ComboBox &widget)
{
return std::make_shared<XsdComboBoxAdapter>(widget);
}
};
class XsdDecimalTextBoxAdapter : public security::DecimalTextBox
{
private:
typedef ::GroupPolicy::SecurityDefinitions::DecimalTextBox DecimalTextBox;
public:
XsdDecimalTextBoxAdapter(const DecimalTextBox &widget)
: security::DecimalTextBox()
{
this->spinBox = widget.spin();
assign_if_exists(this->defaultValue, widget.defaultValue());
assign_if_exists(this->spinStep, widget.spinStep());
assign_if_exists(this->postfix, widget.postfix());
}
static std::shared_ptr<security::DecimalTextBox> create(const DecimalTextBox &widget)
{
return std::make_shared<XsdDecimalTextBoxAdapter>(widget);
}
};
class XsdDropdownListAdapter : public security::DropdownList
{
private:
typedef ::GroupPolicy::SecurityDefinitions::DropdownList DropdownList;
public:
XsdDropdownListAdapter(const DropdownList &widget)
: security::DropdownList()
{
Q_UNUSED(widget);
// TODO: Implement.
}
static std::shared_ptr<security::DropdownList> create(const DropdownList &widget)
{
return std::make_shared<XsdDropdownListAdapter>(widget);
}
};
class XsdListBoxAdapter : public security::ListBox
{
private:
typedef ::GroupPolicy::SecurityDefinitions::ListBox ListBox;
public:
XsdListBoxAdapter(const ListBox &widget)
: security::ListBox()
{
assign_if_exists(this->postfix, widget.postfix());
}
static std::shared_ptr<security::ListBox> create(const ListBox &widget)
{
return std::make_shared<XsdListBoxAdapter>(widget);
}
};
class XsdLongDecimalTextBoxAdapter : public security::LongDecimalTextBox
{
private:
typedef ::GroupPolicy::SecurityDefinitions::LongDecimalTextBox LongDecimalTextBox;
public:
XsdLongDecimalTextBoxAdapter(const LongDecimalTextBox &widget)
: security::LongDecimalTextBox()
{
this->spinBox = widget.spin();
assign_if_exists(this->defaultValue, widget.defaultValue());
assign_if_exists(this->spinStep, widget.spinStep());
assign_if_exists(this->postfix, widget.postfix());
}
static std::shared_ptr<security::LongDecimalTextBox> create(const LongDecimalTextBox &widget)
{
return std::make_shared<XsdLongDecimalTextBoxAdapter>(widget);
}
};
class XsdMultiTextBoxAdapter : public security::MultiTextBox
{
private:
typedef ::GroupPolicy::SecurityDefinitions::MultiTextBox MultiTextBox;
public:
XsdMultiTextBoxAdapter(const MultiTextBox &widget)
: security::MultiTextBox()
{
// this->defaultHeight = widget.defaultHeight();
this->refId = widget.refId();
// this->showAsDialog = widget.showAsDialog();
}
static std::shared_ptr<security::MultiTextBox> create(const MultiTextBox &widget)
{
return std::make_shared<XsdMultiTextBoxAdapter>(widget);
}
};
class XsdTextBoxAdapter : public security::TextBox
{
private:
typedef ::GroupPolicy::SecurityDefinitions::TextBox TextBox;
public:
XsdTextBoxAdapter(const TextBox &widget)
: security::TextBox()
{
if (widget.defaultValue().present())
{
this->defaultValue = widget.defaultValue().get();
}
this->label = widget.label();
this->refId = widget.refId();
}
static std::shared_ptr<security::TextBox> create(const TextBox &widget)
{
return std::make_shared<XsdTextBoxAdapter>(widget);
}
};
class XsdTextAdapter : public security::Text
{
private:
typedef ::GroupPolicy::SecurityDefinitions::TextElement TextElement;
public:
XsdTextAdapter(const TextElement &widget)
: security::Text()
{
this->refId = widget.id();
// TODO: Implement.
}
static std::shared_ptr<security::Text> create(const TextElement &string)
{
return std::make_shared<XsdTextAdapter>(string);
}
};
class XsdLdapSearchDialogAdapter : public security::LdapSearchDialog
{
private:
typedef ::GroupPolicy::SecurityDefinitions::LdapSearchDialog LdapSearchDialog;
public:
XsdLdapSearchDialogAdapter(const LdapSearchDialog &widget)
: security::LdapSearchDialog()
{
this->refId = widget.refId();
assign_if_exists(this->postfix, widget.postfix());
assign_if_exists(this->dn, widget.dn());
assign_if_exists(this->filter, widget.filter());
assign_if_exists(this->addLabel, widget.addLabel());
assign_if_exists(this->removeLabel, widget.removeLabel());
assign_if_exists(this->title, widget.title());
}
static std::shared_ptr<security::LdapSearchDialog> create(const LdapSearchDialog &string)
{
return std::make_shared<XsdLdapSearchDialogAdapter>(string);
}
};
class XsdRadioButtonAdapter : public security::RadioButton
{
private:
typedef ::GroupPolicy::SecurityDefinitions::RadioButton RadioButton;
public:
XsdRadioButtonAdapter(const RadioButton& widget)
: security::RadioButton()
{
this->refId = widget.refId();
assign_if_exists(this->defaultChecked, widget.defaultChecked());
}
static std::shared_ptr<security::RadioButton> create(const RadioButton &radioButton)
{
return std::make_shared<XsdRadioButtonAdapter>(radioButton);
}
};
class XsdGroupBoxAdapter : public security::GroupBox
{
private:
typedef ::GroupPolicy::SecurityDefinitions::GroupBox GroupBox;
public:
XsdGroupBoxAdapter(const GroupBox& widget)
: security::GroupBox()
{
this->refId = widget.refId();
assign_if_exists(this->label, widget.label());
assign_if_exists(this->hasCheckBox, widget.hasCheckBox());
assign_if_exists(this->defaultChecked, widget.defaultChecked());
assign_if_exists(this->hasBorder, widget.hasBorder());
}
static std::shared_ptr<security::GroupBox> create(const GroupBox &groupBox)
{
return std::make_shared<XsdGroupBoxAdapter>(groupBox);
}
};
template<typename AdapterType, typename SequenceType>
void adapt_widgets(const SequenceType &sequence,
std::map<std::string, std::shared_ptr<security::DataElement>> &widgets)
{
for (const auto &adaptee : sequence)
{
auto adaptedElement = AdapterType::create(adaptee);
widgets[adaptee.refId()] = std::move(adaptedElement);
}
}
class XsdResourcesAdapter : public security::SecurityPresentationResources
{
private:
typedef ::GroupPolicy::SecurityDefinitions::SecurityPresentationResources SecurityPresentationResources;
public:
XsdResourcesAdapter(const SecurityPresentationResources &resources)
: security::SecurityPresentationResources()
{
this->description = resources.description();
this->displayName = resources.displayName();
if (resources.resources().stringTable().present())
{
for (const auto &string : resources.resources().stringTable()->string())
{
this->stringTable[string.id()] = string;
}
}
if (resources.resources().presentationTable().present())
{
for (const auto &presentation : resources.resources().presentationTable()->presentation())
{
Q_UNUSED(presentation);
auto securityPresentation = std::make_shared<security::SecurityPresentation>();
auto &widgetsVector = securityPresentation->widgets;
this->presentationTable.emplace_back(presentation.id(), securityPresentation);
const xercesc::DOMNode *n = presentation._node();
assert(n->getNodeType() == xercesc::DOMNode::ELEMENT_NODE);
const xercesc::DOMElement *re = static_cast<const xercesc::DOMElement *>(n);
for (n = re->getFirstChild(); n != 0; n = n->getNextSibling())
{
if (n->getNodeType() == xercesc::DOMNode::ELEMENT_NODE)
{
auto elementNode = static_cast<const xercesc::DOMElement *>(n);
auto elementType = QString::fromStdU16String(elementNode->getTagName());
if (elementType.compare("checkBox") == 0)
{
auto checkBox = std::make_unique<::GroupPolicy::SecurityDefinitions::CheckBox>(*elementNode);
auto widget = XsdCheckBoxAdapter::create(*checkBox);
widgetsVector.emplace_back(checkBox->refId(), widget);
}
else if (elementType.compare("comboBox") == 0)
{
auto comboBox = std::make_unique<::GroupPolicy::SecurityDefinitions::ComboBox>(*elementNode);
auto widget = XsdComboBoxAdapter::create(*comboBox);
widgetsVector.emplace_back(comboBox->refId(), widget);
}
else if (elementType.compare("decimalTextBox") == 0)
{
auto decimalTextBox = std::make_unique<::GroupPolicy::SecurityDefinitions::DecimalTextBox>(
*elementNode);
auto widget = XsdDecimalTextBoxAdapter::create(*decimalTextBox);
widgetsVector.emplace_back(decimalTextBox->refId(), widget);
}
else if (elementType.compare("dropdownList") == 0)
{
auto dropdownList = std::make_unique<::GroupPolicy::SecurityDefinitions::DropdownList>(
*elementNode);
auto widget = XsdDropdownListAdapter::create(*dropdownList);
// widgetsVector.emplace_back(dropdownList->refId(), widget);
}
else if (elementType.compare("listBox") == 0)
{
auto listBox = std::make_unique<::GroupPolicy::SecurityDefinitions::ListBox>(*elementNode);
auto widget = XsdListBoxAdapter::create(*listBox);
widgetsVector.emplace_back(listBox->refId(), widget);
}
else if (elementType.compare("longDecimalTextBox") == 0)
{
auto longDecimalTextBox
= std::make_unique<::GroupPolicy::SecurityDefinitions::LongDecimalTextBox>(*elementNode);
auto widget = XsdLongDecimalTextBoxAdapter::create(*longDecimalTextBox);
widgetsVector.emplace_back(longDecimalTextBox->refId(), widget);
}
else if (elementType.compare("multiTextBox") == 0)
{
auto multiTextBox = std::make_unique<::GroupPolicy::SecurityDefinitions::MultiTextBox>(
*elementNode);
auto widget = XsdMultiTextBoxAdapter::create(*multiTextBox);
widgetsVector.emplace_back(multiTextBox->refId(), widget);
}
else if (elementType.compare("textBox") == 0)
{
auto textBox = std::make_unique<::GroupPolicy::SecurityDefinitions::TextBox>(*elementNode);
auto widget = XsdTextBoxAdapter::create(*textBox);
widgetsVector.emplace_back(textBox->refId(), widget);
}
else if (elementType.compare("text") == 0)
{
auto text = std::make_unique<::GroupPolicy::SecurityDefinitions::Comment>(*elementNode);
// TODO: Implement.
}
else if (elementType.compare("ldapSearchDialog") == 0)
{
auto ldapSearch = std::make_unique<::GroupPolicy::SecurityDefinitions::LdapSearchDialog>(*elementNode);
auto widget = XsdLdapSearchDialogAdapter::create(*ldapSearch);
widgetsVector.emplace_back(ldapSearch->refId(), widget);
}
else if (elementType.compare("radioButton") == 0)
{
auto radioButton = std::make_unique<::GroupPolicy::SecurityDefinitions::RadioButton>(*elementNode);
auto widget = XsdRadioButtonAdapter::create(*radioButton);
widgetsVector.emplace_back(radioButton->refId(), widget);
}
else if (elementType.compare("groupBox") == 0)
{
auto groupBox = std::make_unique<::GroupPolicy::SecurityDefinitions::GroupBox>(*elementNode);
auto widget = XsdGroupBoxAdapter::create(*groupBox);
widgetsVector.emplace_back(groupBox->refId(), widget);
}
}
}
}
}
}
static std::shared_ptr<security::SecurityPresentationResources> create(const SecurityPresentationResources &resources)
{
return std::make_shared<XsdResourcesAdapter>(resources);
}
};
SdmlFormat::SdmlFormat()
: io::PolicyFileFormat<SdmlFile>("sdml")
{
}
bool SdmlFormat::read(std::istream &input, SdmlFile *file)
{
Q_UNUSED(input);
std::unique_ptr<::GroupPolicy::SecurityDefinitions::SecurityPresentationResources> securityDefinitions;
auto operation = [&]() {
securityDefinitions = GroupPolicy::SecurityDefinitions::securityPresentationResources(input,
::xsd::cxx::tree::flags::dont_validate
| ::xsd::cxx::tree::flags::keep_dom
| ::xsd::cxx::tree::flags::own_dom);
auto securityPresentation = XsdResourcesAdapter::create(*securityDefinitions);
file->add(securityPresentation);
};
auto errorHandler = [&](const std::string &error) { this->setErrorString(error); };
return ExceptionHandler::handleOperation(operation, errorHandler);
}
bool SdmlFormat::write(std::ostream &output, SdmlFile *file)
{
Q_UNUSED(output);
Q_UNUSED(file);
return false;
}
}

View File

@ -0,0 +1,50 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef GPUI_SDML_FORMAT_H
#define GPUI_SDML_FORMAT_H
#include "../../../src/core/common.h"
#include "../../../src/io/basefile.h"
#include "../../../src/io/policyfileformat.h"
#include "../../../src/io/policyresourcesfile.h"
namespace security
{
class SecurityPresentationResources;
}
namespace gpui
{
typedef io::BaseFile<security::SecurityPresentationResources> SdmlFile;
class GPUI_SYMBOL_EXPORT SdmlFormat : public io::PolicyFileFormat<SdmlFile>
{
public:
SdmlFormat();
bool read(std::istream &input, SdmlFile *file) override;
bool write(std::ostream &output, SdmlFile *file) override;
};
} // namespace gpui
#endif // GPUI_SDML_FORMAT_H

View File

@ -0,0 +1,38 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#include "../../core/plugin.h"
#include "sdmlformat.h"
namespace gpui
{
class SdmlPlugin : public Plugin
{
public:
SdmlPlugin()
: Plugin("sdml")
{
GPUI_REGISTER_PLUGIN_CLASS(typeid(io::PolicyFileFormat<SdmlFile>).name(), SdmlFormat);
}
};
} // namespace gpui
GPUI_EXPORT_PLUGIN(adml, gpui::SdmlPlugin)

View File

@ -0,0 +1,24 @@
find_package(GPUI COMPONENTS core io REQUIRED)
include_directories(${GPUI_INCLUDE_DIRS})
find_package(Qt5 COMPONENTS Core REQUIRED)
set(PLUGIN_NAME "sdmx-plugin")
set(HEADERS
sdmxformat.h
)
set(SOURCES
sdmxformat.cpp
sdmxplugin.cpp
)
set(SOURCES ${SOURCES} ${HEADERS})
add_gpui_plugin(${PLUGIN_NAME} ${SOURCES})
target_link_libraries(${PLUGIN_NAME} Qt5::Core)
target_link_libraries(${PLUGIN_NAME} ${GPUI_LIBRARIES})
target_link_libraries(${PLUGIN_NAME} policy-common)
target_link_libraries(${PLUGIN_NAME} security_static_xsd_library)
target_link_libraries(${PLUGIN_NAME} xerces-c)

View File

@ -0,0 +1,352 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#include "sdmxformat.h"
#include "../security/schema/security.h"
#include "../security/model/sdmx/securitydefinitions.h"
#include "../common/exceptionhandler.h"
namespace gpui
{
template<typename TInput, typename TOutput>
inline void assign_if_exists(TOutput &output, const TInput &input)
{
if (input.present())
{
output = input.get();
}
}
template<typename ElementType>
void adapter_base(security::SecurityElement *output, const ElementType &input)
{
output->refId = input.id();
if (input.clientExtension().present())
{
output->clientExtension = QUuid(input.clientExtension().get().c_str());
}
output->propertyName = input.propertyName();
}
template<typename TInput, typename TOutput>
void decimal_adapter_base(TOutput *output, const TInput &input)
{
adapter_base(output, input);
assign_if_exists(output->maxValue, input.maxValue());
assign_if_exists(output->minValue, input.minValue());
output->required = input.required();
output->soft = input.soft();
output->storeAsText = input.storeAsText();
output->propertyName = input.propertyName();
}
template<typename AdapterType, typename SequenceType>
void adapt_elements(const SequenceType &sequence, std::vector<std::unique_ptr<security::SecurityElement>> &elements)
{
for (const auto &adaptee : sequence)
{
auto adaptedElement = AdapterType::create(adaptee);
elements.push_back(std::move(adaptedElement));
}
}
class XsdBooleanElementAdapter : public security::BooleanElement
{
private:
typedef ::GroupPolicy::SecurityDefinitions::BooleanElement BooleanElement;
public:
XsdBooleanElementAdapter(const BooleanElement &element)
{
adapter_base(this, element);
this->propertyName = element.propertyName();
}
static std::unique_ptr<security::BooleanElement> create(const BooleanElement &element)
{
return std::make_unique<XsdBooleanElementAdapter>(element);
}
};
class XsdDecimalElementAdapter : public security::DecimalElement
{
private:
typedef ::GroupPolicy::SecurityDefinitions::DecimalElement DecimalElement;
public:
XsdDecimalElementAdapter(const DecimalElement &element) { decimal_adapter_base(this, element); }
static std::unique_ptr<security::DecimalElement> create(const DecimalElement &element)
{
return std::make_unique<XsdDecimalElementAdapter>(element);
}
};
class XsdEnumElementAdapter : public security::EnumerationElement
{
private:
typedef ::GroupPolicy::SecurityDefinitions::EnumerationElement EnumElement;
public:
XsdEnumElementAdapter(const EnumElement &element)
{
adapter_base(this, element);
this->propertyName = element.propertyName();
this->required = element.required();
// for (auto &item : element.)
// {
// if (item.value().decimal().present())
// {
// this->items.push_back(
// std::make_pair(item.displayName(),
// std::make_unique<model::admx::DecimalValue>(item.value().decimal().get().value())));
// }
// if (item.value().longDecimal().present())
// {
// this->items.push_back(std::make_pair(item.displayName(),
// std::make_unique<model::admx::LongDecimalValue>(
// item.value().longDecimal().get().value())));
// }
// if (item.value().string().present())
// {
// this->items.push_back(
// std::make_pair(item.displayName(),
// std::make_unique<model::admx::StringValue>(item.value().string().get())));
// }
// }
}
static std::unique_ptr<security::EnumerationElement> create(const EnumElement &element)
{
return std::make_unique<XsdEnumElementAdapter>(element);
}
};
class XsdListElementAdapter : public security::ListElement
{
private:
typedef ::GroupPolicy::SecurityDefinitions::ListElement ListElement;
public:
XsdListElementAdapter(const ListElement &element)
{
adapter_base(this, element);
assign_if_exists(this->valuePrefix, element.valuePrefix());
this->additive = element.additive();
this->expandable = element.expandable();
this->explicitValue = element.explicitValue();
}
static std::unique_ptr<security::ListElement> create(const ListElement &element)
{
return std::make_unique<XsdListElementAdapter>(element);
}
};
class XsdTextElementAdapter : public security::TextElement
{
private:
typedef ::GroupPolicy::SecurityDefinitions::TextElement TextElement;
public:
XsdTextElementAdapter(const TextElement &element)
{
adapter_base(this, element);
this->propertyName = element.propertyName();
this->required = element.required();
this->maxLength = element.maxLength();
this->soft = element.soft();
}
static std::unique_ptr<security::TextElement> create(const TextElement &element)
{
return std::make_unique<XsdTextElementAdapter>(element);
}
};
class XsdLongDecimalElementAdapter : public security::LongDecimalElement
{
private:
typedef ::GroupPolicy::SecurityDefinitions::LongDecimalElement LongDecimalElement;
public:
XsdLongDecimalElementAdapter(const LongDecimalElement &element) { decimal_adapter_base(this, element); }
static std::unique_ptr<security::LongDecimalElement> create(const LongDecimalElement &element)
{
return std::make_unique<XsdLongDecimalElementAdapter>(element);
}
};
class XsdMultiTextElementAdapter : public security::MultiTextElement
{
private:
typedef ::GroupPolicy::SecurityDefinitions::MultiTextElement MultiTextElement;
public:
XsdMultiTextElementAdapter(const MultiTextElement &element)
{
adapter_base(this, element);
this->propertyName = element.propertyName();
}
static std::unique_ptr<security::MultiTextElement> create(const MultiTextElement &element)
{
return std::make_unique<XsdMultiTextElementAdapter>(element);
}
};
class XsdSecurityAdapter : public security::SecurityDefinition
{
private:
typedef ::GroupPolicy::SecurityDefinitions::SecurityDefinition SecurityDefinition;
public:
XsdSecurityAdapter(const SecurityDefinition &definition)
: security::SecurityDefinition()
{
this->name = definition.name();
this->displayName = definition.displayName();
assign_if_exists(this->explainText, definition.explainText());
if (definition.parentCategory().present())
{
this->parentCategory = definition.parentCategory()->ref();
}
std::string propertyNameLocal{};
std::string sectionNameLocal = definition.sectionName();
assign_if_exists(propertyNameLocal, definition.propertyName());
std::string presentationName{};
assign_if_exists(presentationName, definition.presentation());
this->presentation = std::make_unique<std::string>(presentationName);
this->propertyName = std::make_unique<std::string>(propertyNameLocal);
this->sectionName = std::make_unique<std::string>(sectionNameLocal);
}
static std::shared_ptr<security::SecurityDefinition> create(const SecurityDefinition &element)
{
return std::make_shared<XsdSecurityAdapter>(element);
}
};
class XsdSecurityDefinitionsAdapter : public security::SecurityDefinitions
{
private:
typedef ::GroupPolicy::SecurityDefinitions::SecurityDefinitions SecurityDefinitions;
public:
XsdSecurityDefinitionsAdapter(const SecurityDefinitions &definitions)
: security::SecurityDefinitions()
{
assign_if_exists(this->revision, definitions.revision());
assign_if_exists(this->schemaVersion, definitions.schemaVersion());
for (const auto& securityElement : definitions.security()->securityDefinition())
{
auto ourSecurity = XsdSecurityAdapter::create(securityElement);
if (securityElement.elements().present())
{
adapt_elements<XsdBooleanElementAdapter>(securityElement.elements()->boolean(), ourSecurity->elements);
adapt_elements<XsdDecimalElementAdapter>(securityElement.elements()->decimal(), ourSecurity->elements);
adapt_elements<XsdEnumElementAdapter>(securityElement.elements()->enum_(), ourSecurity->elements);
adapt_elements<XsdTextElementAdapter>(securityElement.elements()->text(), ourSecurity->elements);
adapt_elements<XsdListElementAdapter>(securityElement.elements()->list(), ourSecurity->elements);
adapt_elements<XsdLongDecimalElementAdapter>(securityElement.elements()->longDecimal(), ourSecurity->elements);
adapt_elements<XsdMultiTextElementAdapter>(securityElement.elements()->multiText(), ourSecurity->elements);
}
this->security.push_back(ourSecurity);
}
}
static std::shared_ptr<security::SecurityDefinitions> create(const SecurityDefinitions &element)
{
return std::make_shared<XsdSecurityDefinitionsAdapter>(element);
}
};
SdmxFormat::SdmxFormat()
: io::PolicyFileFormat<SdmxFile>("sdmx")
{
}
bool SdmxFormat::read(std::istream &input, SdmxFile *file)
{
Q_UNUSED(file);
std::unique_ptr<::GroupPolicy::SecurityDefinitions::SecurityDefinitions> securityDefinitions;
auto operation = [&]() {
securityDefinitions = GroupPolicy::SecurityDefinitions::securityDefinitions(input,
::xsd::cxx::tree::flags::dont_validate);
auto security = XsdSecurityDefinitionsAdapter::create(*securityDefinitions);
file->add(security);
};
auto errorHandler = [&](const std::string &error) { this->setErrorString(error); };
return ExceptionHandler::handleOperation(operation, errorHandler);
}
bool SdmxFormat::write(std::ostream &output, SdmxFile *file)
{
Q_UNUSED(output);
Q_UNUSED(file);
return false;
}
}

View File

@ -0,0 +1,50 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef GPUI_SDMX_FORMAT_H
#define GPUI_SDMX_FORMAT_H
#include "../../../src/core/common.h"
#include "../../../src/io/basefile.h"
#include "../../../src/io/policyfileformat.h"
#include "../../../src/io/policyresourcesfile.h"
namespace security
{
class SecurityDefinitions;
}
namespace gpui
{
typedef io::BaseFile<security::SecurityDefinitions> SdmxFile;
class GPUI_SYMBOL_EXPORT SdmxFormat : public io::PolicyFileFormat<SdmxFile>
{
public:
SdmxFormat();
bool read(std::istream &input, SdmxFile *file) override;
bool write(std::ostream &output, SdmxFile *file) override;
};
} // namespace gpui
#endif // GPUI_SDMX_FORMAT_H

View File

@ -0,0 +1,38 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#include "../../core/plugin.h"
#include "sdmxformat.h"
namespace gpui
{
class SdmxPlugin : public Plugin
{
public:
SdmxPlugin()
: Plugin("sdmx")
{
GPUI_REGISTER_PLUGIN_CLASS(typeid(io::PolicyFileFormat<SdmxFile>).name(), SdmxFormat);
}
};
} // namespace gpui
GPUI_EXPORT_PLUGIN(adml, gpui::SdmxPlugin)

View File

@ -0,0 +1,109 @@
find_package(Qt5 COMPONENTS Widgets Qml LinguistTools REQUIRED)
find_package(GPUI COMPONENTS core io REQUIRED)
set(PLUGIN_NAME security-plugin)
set(PLUGIN_STATIC_LIBRARY security_static)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
include_directories(${CMAKE_SOURCE_DIR}/src)
add_subdirectory(schema)
set(HEADERS
model/bundle/securitybundle.h
model/presentation/category.h
model/presentation/checkbox.h
model/presentation/combobox.h
model/presentation/comment.h
model/presentation/dataelementcontent.h
model/presentation/dataelement.h
model/presentation/decimaltextbox.h
model/presentation/dropdownlist.h
model/presentation/groupbox.h
model/presentation/ldapsearchdialog.h
model/presentation/listbox.h
model/presentation/longdecimaltextbox.h
model/presentation/multitextbox.h
model/presentation/presentationelements.h
model/presentation/radiobutton.h
model/presentation/securitydescriptoreditor.h
model/presentation/securitypresentation.h
model/presentation/securitypresentationresources.h
model/presentation/textbox.h
model/presentation/text.h
model/sdmx/booleanelement.h
model/sdmx/decimalelement.h
model/sdmx/decimaltype.h
model/sdmx/enumerationelement.h
model/sdmx/listelement.h
model/sdmx/longdecimalelement.h
model/sdmx/longdecimaltype.h
model/sdmx/multitextelement.h
model/sdmx/securitydefinition.h
model/sdmx/securitydefinitions.h
model/sdmx/securityelement.h
model/sdmx/securityelements.h
model/sdmx/security.h
model/sdmx/securityitem.h
model/sdmx/securityvalue.h
model/sdmx/securityvaluelist.h
model/sdmx/textelement.h
model/ui/presentationbuilder.h
model/ui/securityproxymodel.h
model/ui/securitywidget.h
model/ui/ldapsearchlistwidget.h
model/ui/browseldapdialog.h
)
set(SOURCES
model/bundle/securitybundle.cpp
model/ui/presentationbuilder.cpp
model/ui/securityproxymodel.cpp
model/ui/securitywidget.cpp
model/ui/ldapsearchlistwidget.cpp
model/ui/browseldapdialog.cpp
)
set(UI_FORMS
model/ui/securitywidget.ui
model/ui/ldapsearchlistwidget.ui
model/ui/browseldapdialog.ui
)
set(PLUGIN_HEADERS
securitysnapin.h
)
set(PLUGIN_SOURCES
securityplugin.cpp
securitysnapin.cpp
)
file(GLOB_RECURSE TS_FILES ${CMAKE_CURRENT_SOURCE_DIR} *.ts)
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_SOURCE_DIR})
add_translation(QM_FILES ${TS_FILES})
add_translation_resource(RESOURCES_SRC "security" ${QM_FILES})
qt5_add_resources(LIB_RESOURCES ${RESOURCES_SRC} ${ICON_RESOURCES})
set(PLUGIN_SOURCES ${PLUGIN_SOURCES} ${PLUGIN_HEADERS})
set(SOURCES ${SOURCES} ${HEADERS} ${UI_FORMS})
add_library(${PLUGIN_STATIC_LIBRARY} STATIC ${SOURCES})
target_link_libraries(${PLUGIN_STATIC_LIBRARY} Qt5::Core Qt5::Widgets)
target_link_libraries(${PLUGIN_STATIC_LIBRARY} ${GPUI_LIBRARIES})
target_link_libraries(${PLUGIN_STATIC_LIBRARY} security_static_xsd_library)
target_link_libraries(${PLUGIN_STATIC_LIBRARY} xerces-c)
add_gpui_plugin(${PLUGIN_NAME} ${PLUGIN_SOURCES} ${LIB_RESOURCES})
target_link_libraries(${PLUGIN_NAME} ${PLUGIN_STATIC_LIBRARY})

View File

@ -0,0 +1,569 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#include "securitybundle.h"
#include <QDebug>
#include <QDir>
#include <QStandardItemModel>
#include <QUuid>
#include "../administrative_templates/bundle/itemtype.h"
#include "../administrative_templates/bundle/policyroles.h"
#include "../sdmx/security.h"
#include "../../../src/core/pluginstorage.h"
#include "../../../src/plugins/sdml/sdmlformat.h"
#include "../../../src/plugins/sdmx/sdmxformat.h"
#include <algorithm>
#include <memory>
#include <fstream>
#include "../sdmx/securitydefinitions.h"
#include "../presentation/securitypresentationresources.h"
#include "../presentation/securitypresentation.h"
using namespace model::bundle;
namespace security
{
struct CategoryStorage
{
QStandardItem *machineItem = nullptr;
QStandardItem *userItem = nullptr;
Category category = {};
std::string fileName = {};
};
struct SecurityStorage
{
SecurityType type = security::SecurityType::Machine;
std::string category = {};
std::string fileName = {};
QStandardItem *item = nullptr;
};
class SecurityBundlePrivate
{
public:
std::unique_ptr<QStandardItemModel> treeModel = nullptr;
QStandardItem *rootMachineItem = nullptr;
QStandardItem *rootUserItem = nullptr;
std::vector<QStandardItem *> items = {};
std::map<std::string, std::string> supportedOnMap = {};
QStringList languageDirectoryPaths = {};
std::vector<SecurityStorage> unassignedItems = {};
std::map<std::string, CategoryStorage> categoryItemMap = {};
};
template<typename TPolicies, typename TFormat>
std::unique_ptr<TPolicies> loadPolicies(const QString &pluginName, const QFileInfo &fileName)
{
std::unique_ptr<TPolicies> policies;
TFormat *format = gpui::PluginStorage::instance()->createPluginClass<TFormat>(pluginName);
if (!format)
{
return policies;
}
std::ifstream file;
file.open(fileName.absoluteFilePath().toStdString(), std::ifstream::in);
if (file.good())
{
policies = std::make_unique<TPolicies>();
if (!format->read(file, policies.get()))
{
qWarning() << fileName.fileName() + " " + QString::fromStdString(format->getErrorString());
}
}
file.close();
delete format;
return policies;
}
QString SecurityBundle::constructFileName(const QFileInfo &fileName)
{
QString sdmlFileName = fileName.fileName();
sdmlFileName.replace(sdmlFileName.length() - 4, 4, "sdml");
for (const auto &path : d->languageDirectoryPaths)
{
QDir admlDir(path);
if (admlDir.isEmpty())
{
continue;
}
for (const auto &file : admlDir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot))
{
if (file.fileName().toLower().compare(sdmlFileName.toLower()) == 0)
{
return file.absoluteFilePath();
}
}
}
return sdmlFileName;
}
std::string findStringById(const std::string &id, const std::unique_ptr<gpui::SdmlFile> &resource)
{
if (id.length() < 10 || id.compare(0, 9, "$(string.") != 0)
{
return id;
}
std::string pureId = id.substr(9, id.length() - 10);
for (auto &currentResource : resource->getAll())
{
auto search = currentResource->stringTable.find(pureId);
if (search != currentResource->stringTable.end())
{
return search->second;
}
}
return pureId;
}
std::shared_ptr<security::SecurityPresentation> findPresentationById(
const std::string &id, const std::unique_ptr<gpui::SdmlFile> &resource)
{
if (id.length() < 16 || id.compare(0, 15, "$(presentation.") != 0)
{
return nullptr;
}
std::string pureId = id.substr(15, id.length() - 16);
for (auto &currentResource : resource->getAll())
{
auto &table = currentResource->presentationTable;
auto search = std::find_if(table.begin(), table.end(), [pureId](auto& element)
{
return pureId.compare(element.first) == 0;
});
if (search != table.end())
{
return search->second;
}
}
return nullptr;
}
void handlePresentation(const std::shared_ptr<security::SecurityPresentation> &presentation,
const std::shared_ptr<security::SecurityDefinition> &policy,
const std::unique_ptr<::gpui::SdmlFile> &policyResources)
{
Q_UNUSED(presentation);
Q_UNUSED(policy);
Q_UNUSED(policyResources);
// TODO: Implement.
}
SecurityBundle::SecurityBundle()
: d(new SecurityBundlePrivate())
{
}
SecurityBundle::~SecurityBundle()
{
delete d;
}
std::unique_ptr<QStandardItemModel> SecurityBundle::loadFolder(const std::string &path, const std::string &language)
{
d->treeModel = std::make_unique<QStandardItemModel>();
QStandardItem *rootItem = d->treeModel->invisibleRootItem();
QStandardItem *visibleRootItem = createItem(QObject::tr("[Local Group Policy]"),
"text-x-generic-template",
QObject::tr("Local group policies"),
ItemType::ITEM_TYPE_CATEGORY,
SecurityType::Both,
false);
visibleRootItem->setData(QUuid("{123e4567-e89b-12d3-a456-426652340003}"), model::bundle::CURRENT_UUID);
rootItem->appendRow(visibleRootItem);
QStandardItem *machineItem = createItem(QObject::tr("Machine"),
"computer",
QObject::tr("Machine level policies"),
ItemType::ITEM_TYPE_CATEGORY,
SecurityType::Machine,
false);
machineItem->setData(QUuid("{123e4567-e89b-12d3-a456-426652340003}"), model::bundle::PARENT_UUID);
machineItem->setData(QUuid("{123e4567-e89b-12d3-a456-426652340000}"), model::bundle::CURRENT_UUID);
QStandardItem *machineSystemSettingsItem = createItem(QObject::tr("System settings"),
"folder",
QObject::tr("System settings for computer"),
ItemType::ITEM_TYPE_CATEGORY,
SecurityType::Machine,
false);
machineSystemSettingsItem->setData(QUuid("{123e4567-e89b-12d3-a456-426652340000}"), model::bundle::PARENT_UUID);
machineSystemSettingsItem->setData(QUuid("{123e4567-e89b-12d3-a456-426652340010}"), model::bundle::CURRENT_UUID);
machineItem->appendRow(machineSystemSettingsItem);
d->rootMachineItem = createItem(QObject::tr("Security Settings"),
"folder",
QObject::tr("Machine level security settings"),
ItemType::ITEM_TYPE_CATEGORY,
SecurityType::User,
false);
machineSystemSettingsItem->appendRow(d->rootMachineItem);
QStandardItem *userItem = createItem(QObject::tr("User"),
"user-home",
QObject::tr("User level policies"),
ItemType::ITEM_TYPE_CATEGORY,
SecurityType::User,
false);
userItem->setData(QUuid("{123e4567-e89b-12d3-a456-426652340003}"), model::bundle::PARENT_UUID);
userItem->setData(QUuid("{123e4567-e89b-12d3-a456-426652340001}"), model::bundle::CURRENT_UUID);
QStandardItem *userSystemSettingsItem = createItem(QObject::tr("System settings"),
"folder",
QObject::tr("System settings for user"),
ItemType::ITEM_TYPE_CATEGORY,
SecurityType::User,
false);
userSystemSettingsItem->setData(QUuid("{123e4567-e89b-12d3-a456-426652340001}"), model::bundle::PARENT_UUID);
userSystemSettingsItem->setData(QUuid("{123e4567-e89b-12d3-a456-426652340011}"), model::bundle::CURRENT_UUID);
userItem->appendRow(userSystemSettingsItem);
d->rootUserItem = createItem(QObject::tr("Security Settings"),
"folder",
QObject::tr("User level security settings"),
ItemType::ITEM_TYPE_CATEGORY,
SecurityType::User,
false);
userSystemSettingsItem->appendRow(d->rootUserItem);
visibleRootItem->appendRow(machineItem);
visibleRootItem->appendRow(userItem);
const QDir dir(path.c_str());
const QFileInfoList files = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot);
const QFileInfoList directories = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
const QString qLanguage = QString::fromStdString(language).toLower();
d->languageDirectoryPaths.clear();
for (const QFileInfo &subDir : directories)
{
if (subDir.fileName().toLower().endsWith(qLanguage))
{
d->languageDirectoryPaths.append(subDir.absoluteFilePath());
}
}
for (const QFileInfo &file : files)
{
if (file.fileName().toLower().endsWith(".sdmx"))
{
loadSdmxAndSdml(file);
}
}
rearrangeTreeItems();
assignSupportedOn();
removeEmptyItems();
return std::move(d->treeModel);
}
bool SecurityBundle::loadSdmxAndSdml(const QFileInfo &sdmxFileName)
{
auto securityDefinitions
= loadPolicies<gpui::SdmxFile, io::PolicyFileFormat<::gpui::SdmxFile>>("sdmx", sdmxFileName);
if (!securityDefinitions.get())
{
return false;
}
QString admlFileName = constructFileName(sdmxFileName);
auto policyResources
= loadPolicies<::gpui::SdmlFile, io::PolicyFileFormat<::gpui::SdmlFile>>("sdml", admlFileName);
if (!policyResources.get())
{
return false;
}
std::string fileName = sdmxFileName.fileName().toStdString();
for (auto &definition : securityDefinitions->getAll())
{
for (auto &category : definition->categories)
{
auto categoryName = category->name + "." + fileName;
QString displayName = QString::fromStdString(findStringById(category->displayName, policyResources));
QString explainText = QString::fromStdString(findStringById(category->explainText, policyResources));
d->categoryItemMap[categoryName].machineItem = createItem(displayName,
"folder",
explainText,
ItemType::ITEM_TYPE_CATEGORY,
SecurityType::Machine,
false);
d->categoryItemMap[categoryName].userItem = createItem(displayName,
"folder",
explainText,
ItemType::ITEM_TYPE_CATEGORY,
SecurityType::User,
false);
d->categoryItemMap[categoryName].category = *category;
d->categoryItemMap[categoryName].fileName = fileName;
d->categoryItemMap[category->name].machineItem = d->categoryItemMap[categoryName].machineItem;
d->categoryItemMap[category->name].userItem = d->categoryItemMap[categoryName].userItem;
if (category->parentCategory.size() == 0)
{
d->rootUserItem->appendRow(d->categoryItemMap[categoryName].userItem);
d->rootMachineItem->appendRow(d->categoryItemMap[categoryName].machineItem);
}
}
for (auto &policy : definition->security)
{
QString displayName = QString::fromStdString(findStringById(policy->displayName, policyResources));
QString explainText = QString::fromStdString(findStringById(policy->explainText, policyResources));
auto policyItem = createItem(displayName,
"text-x-generic",
explainText,
ItemType::ITEM_TYPE_POLICY,
policy->securityType,
false);
SecurityStorage container;
container.category = policy->parentCategory;
container.item = policyItem;
container.type = policy->securityType;
container.fileName = sdmxFileName.fileName().toStdString();
if (policy->presentation)
{
auto presentation = findPresentationById(*policy->presentation.get(), policyResources);
if (presentation)
{
policyItem->setData(QVariant::fromValue(presentation), PolicyRoles::PRESENTATION);
handlePresentation(presentation, policy, policyResources);
}
}
policyItem->setData(QVariant::fromValue(policy), PolicyRoles::POLICY);
d->unassignedItems.push_back(container);
}
}
return true;
}
void SecurityBundle::rearrangeTreeItems()
{
for (const auto &entry : d->categoryItemMap)
{
assignParentCategory(entry.second.category.parentCategory,
entry.second.machineItem,
entry.second.userItem,
entry.second.fileName);
}
for (const auto &item : d->unassignedItems)
{
if (item.type == SecurityType::User)
{
assignParentCategory(item.category, nullptr, item.item, item.fileName);
}
else if (item.type == SecurityType::Machine)
{
assignParentCategory(item.category, item.item, nullptr, item.fileName);
}
else
{
item.item->setData(static_cast<uint32_t>(SecurityType::Machine), PolicyRoles::POLICY_TYPE);
QStandardItem *copyItem = createItem(item.item->text(),
"text-x-generic",
item.item->data(PolicyRoles::EXPLAIN_TEXT).value<QString>(),
ItemType::ITEM_TYPE_POLICY,
SecurityType::User,
true);
copyItem->setData(item.item->data(PolicyRoles::SUPPORTED_ON), PolicyRoles::SUPPORTED_ON);
copyItem->setData(item.item->data(PolicyRoles::PRESENTATION), PolicyRoles::PRESENTATION);
copyItem->setData(item.item->data(PolicyRoles::POLICY), PolicyRoles::POLICY);
assignParentCategory(item.category, item.item, copyItem, item.fileName);
}
}
}
void SecurityBundle::assignParentCategory(const std::string &rawCategory,
QStandardItem *machineItem,
QStandardItem *userItem,
const std::string &fileName)
{
std::string parentCategory = rawCategory;
std::string::size_type position = parentCategory.find(':');
if (position != std::string::npos)
{
parentCategory = parentCategory.substr(position + 1);
}
std::string parentCategoryWithFilename = parentCategory + "." + fileName;
auto search = d->categoryItemMap.find(parentCategoryWithFilename);
if (search != d->categoryItemMap.end())
{
if (machineItem)
{
if (!machineItem->data(PolicyRoles::POLICY_WIDGET + 1).value<bool>())
{
search->second.machineItem->appendRow(machineItem);
machineItem->setData(true, PolicyRoles::POLICY_WIDGET + 1);
}
}
if (userItem)
{
if (!userItem->data(PolicyRoles::POLICY_WIDGET + 1).value<bool>())
{
search->second.userItem->appendRow(userItem);
userItem->setData(true, PolicyRoles::POLICY_WIDGET + 1);
}
}
}
else if ((search = d->categoryItemMap.find(parentCategory)) != d->categoryItemMap.end())
{
if (machineItem)
{
if (!machineItem->data(PolicyRoles::POLICY_WIDGET + 1).value<bool>())
{
search->second.machineItem->appendRow(machineItem);
machineItem->setData(true, PolicyRoles::POLICY_WIDGET + 1);
}
}
if (userItem)
{
if (!userItem->data(PolicyRoles::POLICY_WIDGET + 1).value<bool>())
{
search->second.userItem->appendRow(userItem);
userItem->setData(true, PolicyRoles::POLICY_WIDGET + 1);
}
}
}
else if (rawCategory.size() > 0)
{
qWarning() << "Unable to find parent category: " << rawCategory.c_str() << fileName.c_str();
if (machineItem)
{
if (!machineItem->data(PolicyRoles::POLICY_WIDGET + 1).value<bool>())
{
d->rootMachineItem->appendRow(machineItem);
machineItem->setData(true, PolicyRoles::POLICY_WIDGET + 1);
}
}
if (userItem)
{
if (!userItem->data(PolicyRoles::POLICY_WIDGET + 1).value<bool>())
{
d->rootUserItem->appendRow(userItem);
userItem->setData(true, PolicyRoles::POLICY_WIDGET + 1);
}
}
}
}
QStandardItem *SecurityBundle::createItem(const QString &displayName,
const QString &iconName,
const QString &explainText,
const uint itemType,
const SecurityType securityType,
const bool alreadyInserted)
{
QStandardItem *categoryItem = new QStandardItem(displayName.trimmed());
categoryItem->setIcon(QIcon::fromTheme(iconName));
categoryItem->setFlags(categoryItem->flags() & (~Qt::ItemIsEditable));
categoryItem->setData(explainText, PolicyRoles::EXPLAIN_TEXT);
categoryItem->setData(itemType, PolicyRoles::ITEM_TYPE);
categoryItem->setData(static_cast<uint32_t>(securityType), PolicyRoles::POLICY_TYPE);
categoryItem->setData(alreadyInserted, PolicyRoles::POLICY_WIDGET + 1);
d->items.push_back(categoryItem);
return categoryItem;
}
void SecurityBundle::assignSupportedOn()
{
}
void SecurityBundle::removeEmptyItems()
{
iterateModelAndRemoveEmptyFolders(d->treeModel.get(), d->rootMachineItem->index());
iterateModelAndRemoveEmptyFolders(d->treeModel.get(), d->rootUserItem->index());
}
void SecurityBundle::iterateModelAndRemoveEmptyFolders(QAbstractItemModel *model,
const QModelIndex &parent)
{
for (int r = 0; r < model->rowCount(parent); ++r)
{
QModelIndex index = model->index(r, 0, parent);
QVariant data = model->data(index, PolicyRoles::ITEM_TYPE);
qDebug() << "Folder " << model->data(index) << " has children: " << model->hasChildren(index)
<< " type: " << data;
if (model->hasChildren(index))
{
iterateModelAndRemoveEmptyFolders(model, index);
}
else
{
if (data == 0)
{
qDebug() << "Deleted folder " << model->data(index);
model->removeRow(index.row(), index.parent());
iterateModelAndRemoveEmptyFolders(model, index.parent());
}
}
}
}
}
Q_DECLARE_METATYPE(std::shared_ptr<::security::SecurityPresentation>)
Q_DECLARE_METATYPE(std::shared_ptr<::security::SecurityDefinition>)

View File

@ -0,0 +1,86 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef GPUI_SECURITY_BUNDLE_H
#define GPUI_SECURITY_BUNDLE_H
#include <memory>
#include <string>
#include "../sdmx/security.h"
class QFileInfo;
class QString;
class QStandardItem;
class QStandardItemModel;
class QAbstractItemModel;
class QModelIndex;
namespace security
{
class SecurityBundlePrivate;
class SecurityBundle
{
public:
SecurityBundle();
~SecurityBundle();
std::unique_ptr<QStandardItemModel> loadFolder(const std::string &path, const std::string &language);
private:
SecurityBundle(const SecurityBundle &) = delete; // copy ctor
SecurityBundle(SecurityBundle &&) = delete; // move ctor
SecurityBundle &operator=(const SecurityBundle &) = delete; // copy assignment
SecurityBundle &operator=(SecurityBundle &&) = delete; // move assignment
private:
SecurityBundlePrivate *d { nullptr };
private:
bool loadSdmxAndSdml(const QFileInfo &sdmxFileName);
QString constructFileName(const QFileInfo &fileName);
void rearrangeTreeItems();
void assignParentCategory(const std::string &rawCategory,
QStandardItem *machineItem,
QStandardItem *userItem,
const std::string &fileName);
QStandardItem *createItem(const QString &displayName,
const QString &iconName,
const QString &explainText,
const uint itemType,
const SecurityType securityType,
const bool alreadyInserted);
void assignSupportedOn();
void removeEmptyItems();
void iterateModelAndRemoveEmptyFolders(QAbstractItemModel *model, const QModelIndex &parent);
};
} // namespace security
#endif // GPUI_SECURITY_BUNDLE_H

View File

@ -0,0 +1,73 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_CATEGORY_H
#define SECURITY_CATEGORY_H
#include <string>
#include <vector>
namespace security
{
/*!
* \class Category
* \brief A grouping of security definitions.
*
* \ingroup model
* \ingroup presentation
*/
class Category
{
public:
/*!
* \brief name Specifies a logical name to use for a specific supported application and revision.
*/
std::string name{};
/*!
* \brief displayName The reference to the category text string located in the string table of the .sdml file.
*/
std::string displayName{};
/*!
* \brief keywords Contains index words that could be used to search for elements.
*/
std::vector<std::string> keywords{};
/*!
* \brief seeAlso Reference to another element that may be related.
*/
std::vector<std::string> seeAlso{};
/*!
* \brief explainText Explain or Help text associated with a specific category.
*/
std::string explainText{};
/*!
* \brief parentCategory Reference to parent of the current category.
*/
std::string parentCategory{};
};
} // of namespace security
#endif // SECURITY_CATEGORY_H

View File

@ -0,0 +1,48 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_CHECKBOX_H
#define SECURITY_CHECKBOX_H
#include "dataelementcontent.h"
namespace security
{
/*!
* \class CheckBox
* \brief Represents a checkbox display element.\nCan be associated with a BooleanElement.
*
* \ingroup security
* \ingroup presentation
*/
class CheckBox: public DataElementContent
{
public:
/*!
* \brief If checkbox should be initially checked upon creation.
*/
bool defaultChecked { false };
};
} // of namespace security
#endif // SECURITY_CHECKBOX_H

View File

@ -0,0 +1,66 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_COMBOBOX_H
#define SECURITY_COMBOBOX_H
#include "dataelementcontent.h"
#include <string>
#include <vector>
namespace security
{
/*!
\class ComboBox
* \brief Represents a combobox display element with default/suggested entries.
*
* \ingroup security
* \ingroup presentation
*/
class ComboBox: public DataElementContent
{
public:
/*!
* \brief label Text associated with the input box to provide prompt text.
*/
std::string label {};
/*!
* \brief defaultValue Specifies a default value. This can be used for either string or numeric data.
*/
std::string defaultValue {};
/*!
* \brief suggestions A suggested value to be placed in the drop-down list.
* Multiple suggestion elements result in multiple suggestions.
*/
std::vector<std::string> suggestion {};
/*!
* \brief noSort If elements should be sorted.
*/
bool noSort { false };
};
} // of namespace security
#endif // SECURITY_COMBOBOX_H

View File

@ -0,0 +1,56 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_COMMENT_H
#define SECURITY_COMMENT_H
#include "dataelement.h"
#include <string>
namespace security
{
/*!
* \class Comment
* \brief Represents a comment display element.
*
* \ingroup security
* \ingroup presentation
*/
class Comment: public DataElement
{
public:
/*!
* \brief text Text of the comment.
*/
std::string text;
/*!
* \brief image Image that can be incorporated into comment.
*/
std::string image;
};
} // of namespace security
#endif // SECURITY_COMMENT_H

View File

@ -0,0 +1,48 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_DATA_ELEMENT_H
#define SECURITY_DATA_ELEMENT_H
#include <string>
namespace security
{
/*!
* \class DataElement
* \brief Represents base of simple graphical elements.
*
* \ingroup security
* \ingroup presentation
*/
class DataElement
{
public:
/*!
* \brief refId A reference Id.
*/
std::string refId {};
};
} // of namespace security
#endif // SECURITY_DATA_ELEMENT_H

View File

@ -0,0 +1,57 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_DATA_ELEMENT_CONTENT_H
#define SECURITY_DATA_ELEMENT_CONTENT_H
#include <string>
namespace security
{
/*!
\class DataElementContent
* \brief The DataElementContent class base class for graphical element such as combobox or radio-button.
*
* \ingroup security
* \ingroup presentation
*/
class DataElementContent
{
public:
/*!
* \brief value An initial value of graphical element.
*/
std::string value{};
/*!
* \brief refId A reference Id.
*/
std::string refId{};
/*!
* \brief postfix A description that follows graphical element.
*/
std::string postfix{};
};
} // of namespace security
#endif // SECURITY_DATA_ELEMENT_CONTENT_H

View File

@ -0,0 +1,59 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_DECIMAL_TEXTBOX_H
#define SECURITY_DECIMAL_TEXTBOX_H
#include "dataelementcontent.h"
namespace security
{
/*!
* \class DecimalTextBox
* \brief Represents a text box with or without a spin control for entering decimal numbers.
*
* \ingroup security
* \ingroup presentation
*/
class DecimalTextBox: public DataElementContent
{
public:
/*!
* \brief defaultValue
*/
uint32_t defaultValue {0};
/*!
* \brief spinBox
*/
bool spinBox { false };
/*!
* \brief spinStep
*/
uint32_t spinStep {1};
};
} // of namespace security
#endif // SECURITY_DECIMAL_TEXTBOX_H

View File

@ -0,0 +1,68 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_DROPDOWNLIST_H
#define SECURITY_DROPDOWNLIST_H
#include "dataelementcontent.h"
#include <string>
#include <vector>
namespace security
{
/*!
* \class DropdownList
* \brief Represents a dropdown list display element.
*/
class DropdownList : public DataElementContent
{
public:
/*!
* \brief noSort
*/
bool noSort { false };
/*!
* \brief defaultItem The numerical value identifying the default choice of the list of items.
* The item list is numbered starting from 0.
*/
unsigned int defaultItem { 0 };
/*!
* \brief label Text associated with the drop-down list.
*/
std::string label{};
/*!
* \brief values Values of the drop-down list.
*/
std::vector<std::string> values{};
/*!
* \brief refId A mapping to the element.
*/
std::string refId{};
};
} // of namespace security
#endif // SECURITY_DROPDOWNLIST_H

View File

@ -0,0 +1,73 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_GROUPBOX_H
#define SECURITY_GROUPBOX_H
#include "dataelementcontent.h"
#include "presentationelements.h"
#include <memory>
namespace security
{
class PresentationElements;
/*!
* \class GroupBox
* \brief The GroupBox class are used to provide an identifiable grouping for other graphical elements.
*
* \ingroup security
* \ingroup presentation
*/
class GroupBox: public DataElementContent
{
public:
/*!
* \brief hasCheckBox If group box has checkbox.
*/
bool hasCheckBox { false };
/*!
* \brief defaultChecked If group box's check box is checked.
*/
bool defaultChecked { false };
/*!
* \brief elements Content of the group box.
*/
std::unique_ptr<PresentationElements> elements{};
/*!
* \brief label Description of the group box.
*/
std::string label{};
/*!
* \brief hasBorder If group box is flat or it has border.
*/
bool hasBorder { false };
};
} // of namespace security
#endif // SECURITY_GROUPBOX_H

View File

@ -0,0 +1,69 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_LDAP_SEARCH_DIALOG_H
#define SECURITY_LDAP_SEARCH_DIALOG_H
#include "dataelementcontent.h"
#include <string>
namespace security
{
/*!
* \class LdapSearchDialog
* \brief Represents a LDAP search dialog display element.\nCan be associated with a TextElement.
*
* \ingroup security
* \ingroup presentation
*/
class LdapSearchDialog: public DataElementContent
{
public:
/*!
* \brief dn Base DN for elements to search.
*/
std::string dn{};
/*!
* \brief filter LDAP search filter.
*/
std::string filter{};
/*!
* \brief addLabel Label for add button.
*/
std::string addLabel{};
/*!
* \brief removeLabel Label for remove button.
*/
std::string removeLabel{};
/*!
* \brief title Label for group box.
*/
std::string title{};
};
} // of namespace security
#endif // SECURITY_LDAP_SEARCH_DIALOG_H

View File

@ -0,0 +1,42 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_LISTBOX_H
#define SECURITY_LISTBOX_H
#include "dataelementcontent.h"
namespace security
{
/*!
* \class ListBox
* \brief Represents a listbox display element.
*
* \ingroup security
* \ingroup presentation
*/
class ListBox : public DataElementContent
{
};
} // of namespace security
#endif // SECURITY_LISTBOX_H

View File

@ -0,0 +1,58 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_LONG_DECIMAL_TEXTBOX_H
#define SECURITY_LONG_DECIMAL_TEXTBOX_H
#include "dataelementcontent.h"
namespace security {
/**
* \class LongDecimalTextBox
* \brief Represents a text box with or without a spin control for entering long decimal numbers.
*
* \ingroup security
* \ingroup presentation
*/
class LongDecimalTextBox: public DataElementContent
{
public:
/*!
* \brief defaultValue
*/
uint64_t defaultValue{};
/*!
* \brief spinBox
*/
bool spinBox { false };
/*!
* \brief spinStep
*/
uint64_t spinStep {1};
};
} // of namespace security
#endif // SECURITY_LONG_DECIMAL_TEXTBOX_H

View File

@ -0,0 +1,62 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_MULTITEXTBOX_H
#define SECURITY_MULTITEXTBOX_H
#include "dataelementcontent.h"
namespace security
{
/**
* \class MultiTextBox
* \brief Represents a textbox display element with default entry.
*
* \ingroup security
* \ingroup presentation
*/
class MultiTextBox : public DataElementContent
{
public:
/*!
* \brief label
*/
std::string label{};
/*!
* \brief defaultValue
*/
std::string defaultValue{};
/*!
* \brief showAsDialog If we need to display multitext as a dialog.
*/
bool showAsDialog = false;
/*!
* \brief defaultHeight Deafult height of the widget.
*/
unsigned int defaultHeight = 3;
};
} // of namespace security
#endif // SECURITY_MULTITEXTBOX_H

View File

@ -0,0 +1,121 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_PRESENTATION_ELEMENTS_H
#define SECURITY_PRESENTATION_ELEMENTS_H
#include "checkbox.h"
#include "combobox.h"
#include "comment.h"
#include "decimaltextbox.h"
#include "dropdownlist.h"
#include "groupbox.h"
#include "listbox.h"
#include "longdecimaltextbox.h"
#include "ldapsearchdialog.h"
#include "radiobutton.h"
#include "multitextbox.h"
#include "textbox.h"
#include "text.h"
#include <vector>
namespace security
{
class GroupBox;
/*!
* \class PresentationElements
* \brief The PresentationElements class
*/
class PresentationElements
{
public:
/*!
* \brief decimalTextBox
*/
std::vector<DecimalTextBox> decimalTextBox {};
/*!
* \brief textBox
*/
std::vector<TextBox> textBox{};
/*!
* \brief checkBox
*/
std::vector<CheckBox> checkBox{};
/*!
* \brief comboBox
*/
std::vector<ComboBox> comboBox{};
/*!
* \brief dropdownList
*/
std::vector<DropdownList> dropdownList{};
/*!
* \brief longDecimalTextBox
*/
std::vector<LongDecimalTextBox> longDecimalTextBox{};
/*!
* \brief multiTextBox
*/
std::vector<MultiTextBox> multiTextBox{};
/*!
* \brief groupBox
*/
std::vector<GroupBox> groupBox{};
/*!
* \brief listBox
*/
std::vector<ListBox> listBox{};
/*!
* \brief comment
*/
std::vector<Comment> comment{};
/*!
* \brief text
*/
std::vector<Text> text{};
/*!
* \brief ldapSearchDialog
*/
std::vector<LdapSearchDialog> ldapSearchDialog{};
/*!
* \brief radioButton
*/
std::vector<RadioButton> radioButton{};
};
} // of namespace security
#endif // SECURITY_PRESENTATION_ELEMENTS_H

View File

@ -0,0 +1,45 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_RADIO_BUTTON_H
#define SECURITY_RADIO_BUTTON_H
#include "dataelement.h"
namespace security
{
/*!
* \class RadioButton
* \brief Represents a radio button display element.\nCan be associated with a BooleanElement.
*/
class RadioButton: public DataElement
{
public:
/*!
* \brief defaultChecked Shows if radio button is enabled by default.
*/
bool defaultChecked { false };
};
} // of namespace security
#endif // SECURITY_RADIO_BUTTON_H

View File

@ -0,0 +1,44 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_SECURITY_DESCRIPTOR_EDITOR_H
#define SECURITY_SECURITY_DESCRIPTOR_EDITOR_H
#include "dataelement.h"
namespace security
{
/*!
* \class SecurityDescriptorEditor
* \brief Represents a security descriptor editor display element.
*/
class SecurityDescriptorEditor: public DataElement
{
public:
/*!
* \brief label Label of the security editor button.
*/
std::string label{};
};
} // of namespace security
#endif // SECURITY_SECURITY_DESCRIPTOR_EDITOR_H

View File

@ -0,0 +1,82 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_SECURITY_PRESENTATION_H
#define SECURITY_SECURITY_PRESENTATION_H
#include "presentationelements.h"
#include <memory>
#include <string>
#include <type_traits>
#include <variant>
#include <vector>
namespace security
{
// the variant to visit
typedef ::std::variant<std::shared_ptr<DecimalTextBox>,
std::shared_ptr<TextBox>,
std::shared_ptr<CheckBox>,
std::shared_ptr<ComboBox>,
std::shared_ptr<DropdownList>,
std::shared_ptr<LongDecimalTextBox>,
std::shared_ptr<MultiTextBox>,
std::shared_ptr<GroupBox>,
std::shared_ptr<ListBox>,
std::shared_ptr<Comment>,
std::shared_ptr<Text>,
std::shared_ptr<LdapSearchDialog>,
std::shared_ptr<RadioButton> > PresentationElement;
/*!
* \class SecurityPresentation
* \brief Root presentation element.
*
* \ingroup security
* \ingroup presentation
*/
class SecurityPresentation: public PresentationElements
{
public:
/*!
* \brief id Id of current presentation element.
*/
std::string id{};
/*!
* \brief text
*/
std::string text{};
/*!
* \brief icon Icon associated with current presentation element.
*/
std::string icon{};
/*!
* \brief widgets List of widgets, associated with their ids.
*/
std::vector<std::pair<std::string, PresentationElement>> widgets{};
};
} // of namespace security
#endif // SECURITY_SECURITY_PRESENTATION_H

View File

@ -0,0 +1,70 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_SECURITY_PRESENTATION_RESOURCES_H
#define SECURITY_SECURITY_PRESENTATION_RESOURCES_H
#include "securitypresentation.h"
#include <map>
#include <string>
namespace security
{
/*!
* \class SecurityPresentationResources
* \brief Root presentation element.
*/
class SecurityPresentationResources
{
public:
/*!
* \brief displayName The localized friendly name of the policy settings file.
* Unsupported by current Group Policy tools.
*/
std::string displayName{};
/*!
* \brief description The localized description of policy settings contained in an .adml file.
* Unsupported by current Group Policy tools.
*/
std::string description{};
/*!
* \brief annotation A comment string for .adml files.
* Strings added to this tag will not be processed by Group Policy tools.
*/
std::vector<std::string> annotation{};
/*!
* \brief stringTable A table of localized strings.
*/
std::map<std::string, std::string> stringTable{};
/*!
* \brief presentationTable A table of presentation elements representing policy setting parameters.
*/
std::vector<std::pair<std::string, std::shared_ptr<SecurityPresentation>>> presentationTable{};
};
} // of namespace security
#endif // SECURITY_SECURITY_PRESENTATION_RESOURCES_H

View File

@ -0,0 +1,47 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_TEXT_H
#define SECURITY_TEXT_H
#include "dataelement.h"
#include <string>
namespace security
{
/**
* \class Text
* \brief Represents a text display element with default entry.
*/
class Text: public DataElement
{
public:
/*!
* \brief content
*/
std::string content{};
};
} // of namespace security
#endif // SECURITY_TEXT_H

View File

@ -0,0 +1,52 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_TEXTBOX_H
#define SECURITY_TEXTBOX_H
#include "dataelementcontent.h"
#include <string>
namespace security
{
/**
* \class TextBox
* \brief Represents a textbox display element with default entry.
*/
class TextBox: public DataElementContent
{
public:
/*!
* \brief label
*/
std::string label{};
/*!
* \brief defaultValue
*/
std::string defaultValue{};
};
} // of namespace security
#endif // SECURITY_TEXTBOX_H

View File

@ -0,0 +1,39 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_BOOLEAN_ELEMENT_H
#define SECURITY_BOOLEAN_ELEMENT_H
#include "securityelement.h"
namespace security
{
/*!
* \class BooleanElement
* \brief Describes a choice element in a policy with associated values for the true and false cases.
*/
class BooleanElement: public SecurityElement
{
};
} // of namespace security
#endif // SECURITY_BOOLEAN_ELEMENT_H

View File

@ -0,0 +1,66 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_DECIMAL_ELEMENT_H
#define SECURITY_DECIMAL_ELEMENT_H
#include "security.h"
#include "securityelement.h"
namespace security
{
/*!
* \brief The DecimalElement class
*/
class DecimalElement: public SecurityElement
{
public:
/*!
*
*/
bool required { false };
/*!
*
*/
bool soft { false };
/*!
*
*/
bool storeAsText { false };
/*!
*
*/
uint32_t minValue { std::numeric_limits<uint32_t>::min() };
/*!
*
*/
uint32_t maxValue { std::numeric_limits<uint32_t>::max() };
};
} // of namespace security
#endif // SECURITY_DECIMAL_ELEMENT_H

View File

@ -0,0 +1,45 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_DECIMALTYPE_H
#define SECURITY_DECIMALTYPE_H
#include "security.h"
#include <stdint.h>
namespace security
{
/*!
* \brief The DecimalType class
*/
class DecimalType {
public:
/**
*
*/
uint32_t value {0};
};
} // of namespace security
#endif // SECURITY_DECIMALTYPE_H

View File

@ -0,0 +1,46 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_ENUMERATION_ELEMENT_H
#define SECURITY_ENUMERATION_ELEMENT_H
#include "security.h"
#include "securityelement.h"
namespace security
{
/*!
* \class EnumerationElement
* \brief The EnumerationElement class
*/
class EnumerationElement: public SecurityElement
{
public:
/*!
* \brief required
*/
bool required { false };
};
} // of namespace security
#endif // SECURITY_ENUMERATION_ELEMENT_H

View File

@ -0,0 +1,62 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_LIST_ELEMENT_H
#define SECURITY_LIST_ELEMENT_H
#include "security.h"
#include "securityelement.h"
namespace security
{
/*!
* \class ListElement
* \brief The ListElement class
*/
class ListElement: public SecurityElement
{
public:
/*!
* \brief valuePrefix
*/
std::string valuePrefix{};
/*!
* \brief additive
*/
bool additive { false };
/*!
* \brief expandable
*/
bool expandable { false };
/*!
* \brief explicitValue
*/
bool explicitValue { false };
};
} // of namespace security
#endif // SECURITY_LIST_ELEMENT_H

View File

@ -0,0 +1,67 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_LONG_DECIMAL_ELEMENT_H
#define SECURITY_LONG_DECIMAL_ELEMENT_H
#include "security.h"
#include "securityelement.h"
namespace security
{
/*!
* \class LongDecimalElement
* \brief The LongDecimalElement class
*/
class LongDecimalElement: public SecurityElement
{
public:
/*!
* \brief required
*/
bool required { false };
/*!
* \brief sorf
*/
bool soft { false };
/*!
* \brief storeAsText
*/
bool storeAsText { false };
/*!
* \brief minValue
*/
uint64_t minValue { std::numeric_limits<uint64_t>::min() };
/**
* \brief maxValue
*/
uint64_t maxValue { std::numeric_limits<uint64_t>::max() };
};
} // of namespace security
#endif // SECURITY_LONG_DECIMAL_ELEMENT_H

View File

@ -0,0 +1,46 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_LONG_DECIMAL_TYPE_H
#define SECURITY_LONG_DECIMAL_TYPE_H
#include "security.h"
#include <stdint.h>
namespace security
{
/*!
* \class LongDecimalElement
* \brief The LongDecimalType class
*/
class LongDecimalType
{
public:
/*!
* \brief value
*/
uint64_t value {};
};
} // of namespace security
#endif // SECURITY_LONG_DECIMAL_TYPE_H

View File

@ -0,0 +1,41 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_MULTITEXT_ELEMENT_H
#define SECURITY_MULTITEXT_ELEMENT_H
#include "security.h"
#include "securityelement.h"
namespace security
{
/*!
* \class MultiTextElement
* \brief Describes a multi line text element in a policy.
*/
class MultiTextElement: public SecurityElement
{
};
} // of namespace security
#endif // SECURITY_MULTITEXT_ELEMENT_H

View File

@ -0,0 +1,31 @@
#ifndef SECURITY_H
#define SECURITY_H
namespace security
{
/**
* \enum SecurityType
* \brief bAn enumeration of the 3 possible types a security definition can belong to.
*/
enum class SecurityType
{
/*!
*
*/
User = 0,
/*!
*
*/
Machine = 1,
/*!
*
*/
Both = 2
};
} // of namespace security
#endif // SECURITY_H

View File

@ -0,0 +1,112 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_SECURITY_DEFINITION_H
#define SECURITY_SECURITY_DEFINITION_H
#include "security.h"
#include "securityelements.h"
#include "securityvalue.h"
#include "securityvaluelist.h"
#include <memory>
#include <string>
#include <vector>
namespace security
{
/*!
\class SecurityDefinition
* \brief The SecurityDefinition class
*/
class SecurityDefinition
{
public:
/*!
* \brief name
*/
std::string name {};
/*!
* \brief displayName
*/
std::string displayName {};
/*!
* \brief explainText
*/
std::string explainText {};
/*!
* \brief sectionName
*/
std::unique_ptr<std::string> sectionName {};
/*!
* \brief propertyName
*/
std::unique_ptr<std::string> propertyName {};
/*!
* \brief securityType
*/
SecurityType securityType { SecurityType::Machine };
/*!
* \brief presentation A reference to a policy presentation in the localized presentation section/table.
*/
std::unique_ptr<std::string> presentation{};
/*!
* \brief parentCategory
*/
std::string parentCategory {};
/*!
* \brief elements
*/
std::vector<std::unique_ptr<SecurityElement>> elements {};
/*!
* \brief enabledValue
*/
std::unique_ptr<SecurityValue> enabledValue {};
/*!
* \brief disabledValue
*/
std::unique_ptr<SecurityValue> disabledValue {};
/*!
* \brief enabledList
*/
std::unique_ptr<SecurityValueList> enabledList{};
/*!
* \brief disabledList
*/
std::unique_ptr<SecurityValueList> disabledList{};
};
} // of namespace security
#endif // SECURITY_SECURITY_DEFINITION_H

View File

@ -0,0 +1,68 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_SECURITY_DEFINITIONS_H
#define SECURITY_SECURITY_DEFINITIONS_H
#include "security.h"
#include "securitydefinition.h"
#include "../presentation/category.h"
#include <memory>
#include <string>
#include <vector>
namespace security
{
/*!
* \class SecurityDefinitions
* \brief The SecurityDefinitions class
*/
class SecurityDefinitions
{
public:
/*!
* \brief revision
*/
std::string revision{};
/*!
* \brief schemaVersion
*/
std::string schemaVersion{};
/*!
* \brief categories Contains a list of categories under which Group Policy
* settings will be displayed in the Editor.
*/
std::vector<std::shared_ptr<Category>> categories{};
/*!
* \brief security
*/
std::vector<std::shared_ptr<SecurityDefinition> > security {};
};
} // of namespace security
#endif // SECURITY_SECURITY_DEFINITIONS_H

View File

@ -0,0 +1,58 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_SECURITY_ELEMENT_H
#define SECURITY_SECURITY_ELEMENT_H
#include "security.h"
#include <string>
#include <QUuid>
namespace security
{
/*!
* \class SecurityElement
* \brief The SecurityElement class
*/
class SecurityElement
{
public:
/*!
* \brief refId
*/
std::string refId{};
/*!
* \brief clientExtension
*/
QUuid clientExtension{};
/*!
* \brief propertyName
*/
std::string propertyName{};
};
} // of namespace security
#endif // SECURITY_SECURITY_ELEMENT_H

View File

@ -0,0 +1,85 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_SECURITY_ELEMENTS_H
#define SECURITY_SECURITY_ELEMENTS_H
#include "security.h"
#include "booleanelement.h"
#include "decimalelement.h"
#include "enumerationelement.h"
#include "listelement.h"
#include "longdecimalelement.h"
#include "multitextelement.h"
#include "textelement.h"
#include <string>
#include <vector>
namespace security
{
/*!
* \class SecurityElements
* \brief The SecurityElements class
*/
class SecurityElements
{
public:
/*!
* \brief boolean
*/
std::vector<BooleanElement> boolean {};
/*!
* \brief decimal
*/
std::vector<DecimalElement> decimal {};
/*!
* \brief text
*/
std::vector<TextElement> text {};
/*!
* \brief enumElement
*/
std::vector<EnumerationElement> enumElement {};
/*!
* \brief list
*/
std::vector<ListElement> list {};
/*!
* \brief longDecimal
*/
std::vector<LongDecimalElement> longDecimal {};
/*!
* \brief multiText
*/
std::vector<MultiTextElement> multiText {};
};
} // of namespace security
#endif // SECURITY_SECURITY_ELEMENTS_H

View File

@ -0,0 +1,61 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_SECURITY_ITEM_H
#define SECURITY_SECURITY_ITEM_H
#include "security.h"
#include "securityvalue.h"
#include <string>
namespace security {
/*!
* \class SecurityItem
* \brief The SecurityItem class represents element of security policy.
*
* \ingroup security
*
* \see SecurityValue
*/
class SecurityItem
{
public:
/*!
* \brief sectionName Name of the section to place item into.
*/
std::string sectionName {};
/*!
* \brief propertyName Name of the property associated with this security policy element.
*/
std::string propertyName {};
/*!
* \brief value Value of current element.
*/
SecurityValue value {};
};
} // of namespace security
#endif // SECURITY_SECURITY_ITEM_H

View File

@ -0,0 +1,40 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_SECURITY_VALUE_H
#define SECURITY_SECURITY_VALUE_H
#include "security.h"
namespace security {
/*!
* \class SecurityValue
* \brief The SecurityValue class
*/
class SecurityValue
{
public:
// TODO: implement
};
} // of namespace security
#endif // SECURITY_SECURITY_VALUE_H

View File

@ -0,0 +1,53 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_SECURITY_VALUE_LIST_H
#define SECURITY_SECURITY_VALUE_LIST_H
#include "security.h"
#include "securityvalue.h"
#include <string>
#include <vector>
namespace security {
/*!
\class SecurityValueList
* \brief The SecurityValueList class stores list of values.
*/
class SecurityValueList
{
public:
/*!
* \brief item List of items.
*/
std::vector<SecurityValue> items{};
/*!
* \brief defaultString
*/
std::string defaultString{};
};
} // of namespace security
#endif // SECURITY_SECURITY_VALUE_LIST_H

View File

@ -0,0 +1,59 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_TEXT_ELEMENT_H
#define SECURITY_TEXT_ELEMENT_H
#include "security.h"
#include "securityelement.h"
namespace security
{
/**
* \class TextElement
* \brief Describes a single line text element in a policy.
*
* \ingroup model
*/
class TextElement: public SecurityElement
{
public:
/*!
* \brief required If this element is required.
*/
bool required { false };
/*!
* \brief maxLength Maximum length of text element. If text exceeds maximum length it will be truncated.
*/
uint32_t maxLength { 1024 };
/*!
* \brief soft If previous value should be replaced.
*/
bool soft { false };
};
} // of namespace security
#endif // SECURITY_TEXT_ELEMENT_H

View File

@ -0,0 +1,47 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#include "browseldapdialog.h"
#include "ui_browseldapdialog.h"
namespace security
{
class BrowseLdapDialogPrivate
{
private:
};
BrowseLdapDialog::BrowseLdapDialog(QWidget *parent)
: QDialog(parent)
, d(new BrowseLdapDialogPrivate())
, ui(new Ui::BrowseLdapDialog())
{
ui->setupUi(this);
}
BrowseLdapDialog::~BrowseLdapDialog()
{
delete d;
delete ui;
}
}

View File

@ -0,0 +1,59 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_BROWSE_LDAP_DIALOG_H
#define SECURITY_BROWSE_LDAP_DIALOG_H
#include <QtWidgets>
QT_BEGIN_NAMESPACE
namespace Ui { class BrowseLdapDialog; }
QT_END_NAMESPACE
namespace security
{
class BrowseLdapDialogPrivate;
class BrowseLdapDialog : public QDialog
{
public:
Q_OBJECT
public:
explicit BrowseLdapDialog(QWidget* parent = nullptr);
~BrowseLdapDialog() override;
private:
BrowseLdapDialog(const BrowseLdapDialog&) = delete; // copy ctor
BrowseLdapDialog(BrowseLdapDialog&&) = delete; // move ctor
BrowseLdapDialog& operator=(const BrowseLdapDialog&) = delete; // copy assignment
BrowseLdapDialog& operator=(BrowseLdapDialog&&) = delete; // move assignment
private:
BrowseLdapDialogPrivate *d{};
private:
Ui::BrowseLdapDialog *ui{};
};
}
#endif//SECURITY_BROWSE_LDAP_DIALOG_H

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BrowseLdapDialog</class>
<widget class="QDialog" name="BrowseLdapDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>411</width>
<height>83</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QPushButton" name="browseButton">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="nameLineEdit"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Resource to browse:</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>BrowseLdapDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>BrowseLdapDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_US">
<context>
<name>BrowseLdapDialog</name>
<message>
<location filename="../browseldapdialog.ui" line="14"/>
<source>Dialog</source>
<translation>Dialog</translation>
</message>
<message>
<location filename="../browseldapdialog.ui" line="20"/>
<source>Browse</source>
<translation>Browse</translation>
</message>
<message>
<location filename="../browseldapdialog.ui" line="40"/>
<source>Resource to browse:</source>
<translation>Resource to browse:</translation>
</message>
</context>
<context>
<name>LdapSearchListWidget</name>
<message>
<location filename="../ldapsearchlistwidget.ui" line="14"/>
<source>Form</source>
<translation>Form</translation>
</message>
<message>
<location filename="../ldapsearchlistwidget.ui" line="20"/>
<source>Add button</source>
<translation>Add button</translation>
</message>
<message>
<location filename="../ldapsearchlistwidget.ui" line="27"/>
<source>Remove button</source>
<translation>Remove button</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../../bundle/securitybundle.cpp" line="207"/>
<source>[Local Group Policy]</source>
<translation>[Local Group Policy]</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="209"/>
<source>Local group policies</source>
<translation>Local group policies</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="217"/>
<source>Machine</source>
<translation>Machine</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="219"/>
<source>Machine level policies</source>
<translation>Machine level policies</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="225"/>
<location filename="../../bundle/securitybundle.cpp" line="250"/>
<source>System settings</source>
<translation>System settings</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="227"/>
<source>System settings for computer</source>
<translation>System settings for computer</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="234"/>
<location filename="../../bundle/securitybundle.cpp" line="259"/>
<source>Security Settings</source>
<translation>Security Settings</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="236"/>
<source>Machine level security settings</source>
<translation>Machine level security settings</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="242"/>
<source>User</source>
<translation>User</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="244"/>
<source>User level policies</source>
<translation>User level policies</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="252"/>
<source>System settings for user</source>
<translation>System settings for user</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="261"/>
<source>User level security settings</source>
<translation>User level security settings</translation>
</message>
<message>
<location filename="../presentationbuilder.cpp" line="181"/>
<source>Edit</source>
<translation>Edit</translation>
</message>
</context>
<context>
<name>SecurityWidget</name>
<message>
<location filename="../securitywidget.ui" line="14"/>
<source>Form</source>
<translation>Form</translation>
</message>
<message>
<location filename="../securitywidget.ui" line="97"/>
<source>Help:</source>
<translation>Help:</translation>
</message>
<message>
<location filename="../securitywidget.ui" line="146"/>
<source>&amp;Cancel</source>
<translation>&amp;Cancel</translation>
</message>
<message>
<location filename="../securitywidget.ui" line="153"/>
<source>&amp;OK</source>
<translation>&amp;OK</translation>
</message>
</context>
<context>
<name>security::SecurityWidget</name>
<message>
<location filename="../securitywidget.cpp" line="58"/>
<source>Security policy: </source>
<translation>Security policy: </translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="ru_RU">
<context>
<name>BrowseLdapDialog</name>
<message>
<location filename="../browseldapdialog.ui" line="14"/>
<source>Dialog</source>
<translation>Диалог</translation>
</message>
<message>
<location filename="../browseldapdialog.ui" line="20"/>
<source>Browse</source>
<translation>Просмотр</translation>
</message>
<message>
<location filename="../browseldapdialog.ui" line="40"/>
<source>Resource to browse:</source>
<translation>Ресурс для поиска:</translation>
</message>
</context>
<context>
<name>LdapSearchListWidget</name>
<message>
<location filename="../ldapsearchlistwidget.ui" line="14"/>
<source>Form</source>
<translation>Форма</translation>
</message>
<message>
<location filename="../ldapsearchlistwidget.ui" line="20"/>
<source>Add button</source>
<translation>Кнопка добавить</translation>
</message>
<message>
<location filename="../ldapsearchlistwidget.ui" line="27"/>
<source>Remove button</source>
<translation>Кнопка удалить</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../../bundle/securitybundle.cpp" line="207"/>
<source>[Local Group Policy]</source>
<translation>[Локальная групповая политика]</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="209"/>
<source>Local group policies</source>
<translation>Локальные групповые политики</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="217"/>
<source>Machine</source>
<translation>Компьютер</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="219"/>
<source>Machine level policies</source>
<translation>Политики уровня компьютера</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="225"/>
<location filename="../../bundle/securitybundle.cpp" line="250"/>
<source>System settings</source>
<translation>Настройки системы</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="227"/>
<source>System settings for computer</source>
<translation>Настройки системы для компьютера</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="234"/>
<location filename="../../bundle/securitybundle.cpp" line="259"/>
<source>Security Settings</source>
<translation>Настройки безопастности</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="236"/>
<source>Machine level security settings</source>
<translation>Настройки безопастности компьютера</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="242"/>
<source>User</source>
<translation>Пользователь</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="244"/>
<source>User level policies</source>
<translation>Групповые политики пользователя</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="252"/>
<source>System settings for user</source>
<translation>Настройки системы пользователя</translation>
</message>
<message>
<location filename="../../bundle/securitybundle.cpp" line="261"/>
<source>User level security settings</source>
<translation>Настройки безовпстности пользователя</translation>
</message>
<message>
<location filename="../presentationbuilder.cpp" line="181"/>
<source>Edit</source>
<translation>Редактировать</translation>
</message>
</context>
<context>
<name>SecurityWidget</name>
<message>
<location filename="../securitywidget.ui" line="14"/>
<source>Form</source>
<translation>Форма</translation>
</message>
<message>
<location filename="../securitywidget.ui" line="97"/>
<source>Help:</source>
<translation>Помощь:</translation>
</message>
<message>
<location filename="../securitywidget.ui" line="146"/>
<source>&amp;Cancel</source>
<translation>&amp;Отмена</translation>
</message>
<message>
<location filename="../securitywidget.ui" line="153"/>
<source>&amp;OK</source>
<translation>&amp;ОК</translation>
</message>
</context>
<context>
<name>security::SecurityWidget</name>
<message>
<location filename="../securitywidget.cpp" line="58"/>
<source>Security policy: </source>
<translation>Политика безопастности: </translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,91 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#include "ldapsearchlistwidget.h"
#include "ui_ldapsearchlistwidget.h"
#include "browseldapdialog.h"
#include <QDataWidgetMapper>
namespace security
{
class LdapSearchListWidgetPrivate
{
public:
QString filter{};
QString dn{};
LdapSearchListWidgetPrivate(const QString &newFilter, const QString &newDN)
: filter(newFilter)
, dn(newDN)
{}
};
LdapSearchListWidget::LdapSearchListWidget(const QString &filter, const QString &dn, const QString &title, QWidget *parent)
: QWidget(parent)
, d(new LdapSearchListWidgetPrivate(filter, dn))
, ui(new Ui::LdapSearchListWidget())
{
ui->setupUi(this);
ui->groupBox->setTitle(title);
}
LdapSearchListWidget::LdapSearchListWidget(const std::string &filter, const std::string &dn, const std::string &title, QWidget *parent)
: LdapSearchListWidget(QString::fromStdString(filter), QString::fromStdString(dn), QString::fromStdString(title), parent)
{
}
LdapSearchListWidget::~LdapSearchListWidget()
{
delete d;
delete ui;
}
void LdapSearchListWidget::setAddButtonText(const QString &text)
{
ui->addButton->setText(text);
}
void LdapSearchListWidget::setRemoveButtonText(const QString &text)
{
ui->removeButton->setText(text);
}
void security::LdapSearchListWidget::on_addButton_clicked()
{
auto browseLdapDialog = new BrowseLdapDialog(this);
browseLdapDialog->show();
}
void security::LdapSearchListWidget::on_removeButton_clicked()
{
auto selectedItems = ui->listWidget->selectedItems();
for (const auto& selectedItem : selectedItems)
{
ui->listWidget->removeItemWidget(selectedItem);
delete selectedItem;
}
}
}

View File

@ -0,0 +1,67 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_LDAP_SEARCH_LIST_WIDGET_H
#define SECURITY_LDAP_SEARCH_LIST_WIDGET_H
#include <QtWidgets>
QT_BEGIN_NAMESPACE
namespace Ui { class LdapSearchListWidget; }
QT_END_NAMESPACE
namespace security
{
class LdapSearchListWidgetPrivate;
class LdapSearchListWidget : public QWidget
{
public:
Q_OBJECT
public:
explicit LdapSearchListWidget(const QString& filter, const QString& dn, const QString &title, QWidget* parent = nullptr);
explicit LdapSearchListWidget(const std::string& filter, const std::string& dn, const std::string &title, QWidget* parent = nullptr);
~LdapSearchListWidget() override;
void setAddButtonText(const QString& text);
void setRemoveButtonText(const QString& text);
private slots:
void on_addButton_clicked();
void on_removeButton_clicked();
private:
LdapSearchListWidget(const LdapSearchListWidget&) = delete; // copy ctor
LdapSearchListWidget(LdapSearchListWidget&&) = delete; // move ctor
LdapSearchListWidget& operator=(const LdapSearchListWidget&) = delete; // copy assignment
LdapSearchListWidget& operator=(LdapSearchListWidget&&) = delete; // move assignment
private:
LdapSearchListWidgetPrivate *d{};
private:
Ui::LdapSearchListWidget *ui{};
};
}
#endif//SECURITY_LDAP_SEARCH_LIST_WIDGET_H

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LdapSearchListWidget</class>
<widget class="QWidget" name="LdapSearchListWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>411</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Ldap search header:</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>7</number>
</property>
<property name="topMargin">
<number>7</number>
</property>
<property name="rightMargin">
<number>7</number>
</property>
<property name="bottomMargin">
<number>7</number>
</property>
<property name="horizontalSpacing">
<number>5</number>
</property>
<item row="0" column="0" colspan="3">
<widget class="QListWidget" name="listWidget"/>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add button</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="removeButton">
<property name="text">
<string>Remove button</string>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>190</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,356 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#include "presentationbuilder.h"
#include <QVBoxLayout>
#include "../presentation/checkbox.h"
#include "../presentation/combobox.h"
#include "../presentation/decimaltextbox.h"
#include "../presentation/dropdownlist.h"
#include "../presentation/groupbox.h"
#include "../presentation/ldapsearchdialog.h"
#include "../presentation/listbox.h"
#include "../presentation/longdecimaltextbox.h"
#include "../presentation/multitextbox.h"
#include "../presentation/text.h"
#include "../presentation/textbox.h"
#include "../presentation/securitypresentationresources.h"
#include "ldapsearchlistwidget.h"
#include <type_traits>
#include <variant>
#include <QLabel>
#include <QCheckBox>
#include <QLineEdit>
#include <QTextEdit>
#include <QIntValidator>
#include <QComboBox>
#include <QGroupBox>
#include <QRadioButton>
#include <gui/altspinbox.h>
#include <gui/listboxdialog.h>
template<class>
inline constexpr bool always_false_v = false;
namespace security
{
template<typename TLayoutItem>
QLayoutItem *createAndAttachLabel(QWidget *buddy, const QString &text)
{
Q_UNUSED(text);
TLayoutItem *container = new TLayoutItem();
container->addWidget(buddy);
return container;
}
class PresentationBuilderPrivate
{
public:
void visit(DecimalTextBox &widget) const
{
QWidget *textBox = createAnyDecimalTextBox(widget.spinBox, widget.defaultValue, widget.spinStep);
QLayoutItem *container = createAndAttachLabel<QHBoxLayout>(textBox, QString::fromStdString(widget.postfix));
addToLayout(container);
}
void visit(TextBox &widget) const
{
QLineEdit *lineEdit = new QLineEdit();
lineEdit->setText(QString::fromStdString(widget.defaultValue));
QLayoutItem *container = createAndAttachLabel<QHBoxLayout>(lineEdit, QString::fromStdString(widget.label));
addToLayout(container);
}
void visit(CheckBox &widget) const
{
QCheckBox *checkBox = new QCheckBox();
checkBox->setChecked(widget.defaultChecked);
QLayoutItem *container = createAndAttachLabel<QHBoxLayout>(checkBox, QString::fromStdString(widget.postfix));
addToLayout(container);
}
void visit(ComboBox &widget) const
{
QComboBox *comboBox = new QComboBox();
comboBox->setCurrentText(QString::fromStdString(widget.defaultValue));
for (const auto &item : widget.suggestion)
{
comboBox->addItem(QString::fromStdString(item));
}
QLayoutItem *container = createAndAttachLabel<QHBoxLayout>(comboBox, QString::fromStdString(widget.label));
addToLayout(container);
}
void visit(DropdownList &widget) const
{
QComboBox *comboBox = new QComboBox();
comboBox->setCurrentIndex(widget.defaultItem);
QLayoutItem *container = createAndAttachLabel<QHBoxLayout>(comboBox, QString::fromStdString(widget.label));
if (widget.values.size() > 0)
{
for (auto &value : widget.values)
{
comboBox->addItem(QString::fromStdString(value));
}
if (widget.defaultItem < widget.values.size())
{
comboBox->setCurrentIndex(widget.defaultItem);
}
}
addToLayout(container);
}
void visit(LongDecimalTextBox &widget) const
{
QWidget *textBox = createAnyDecimalTextBox(widget.spinBox, widget.defaultValue, widget.spinStep);
QLayoutItem *container = createAndAttachLabel<QHBoxLayout>(textBox, QString::fromStdString(widget.postfix));
addToLayout(container);
}
void visit(MultiTextBox &widget) const
{
Q_UNUSED(widget);
QTextEdit *textEdit = new QTextEdit();
textEdit->setMaximumHeight(widget.defaultHeight * textEdit->fontMetrics().height());
addToLayout(textEdit);
}
void visit(GroupBox &widget) const
{
QGroupBox *groupBox = new QGroupBox();
groupBox->setCheckable(widget.hasCheckBox);
groupBox->setChecked(widget.defaultChecked);
// TODO: Implement.
addToLayout(groupBox);
}
void visit(ListBox &widget) const
{
QPushButton *button = new QPushButton(QObject::tr("Edit"));
QLayoutItem *container = createAndAttachLabel<QHBoxLayout>(button, QString::fromStdString(widget.postfix));
auto onClicked = [&]() {
gpui::ListBoxDialog *listBox = new gpui::ListBoxDialog(QString::fromStdString(widget.postfix));
listBox->setAttribute(Qt::WA_DeleteOnClose);
listBox->show();
};
QObject::connect(button, &QPushButton::clicked, onClicked);
addToLayout(container);
}
void visit(LdapSearchDialog &widget) const
{
LdapSearchListWidget* ldapSearchListWidget = new LdapSearchListWidget(widget.filter, widget.dn, widget.title);
ldapSearchListWidget->setAddButtonText(QString::fromStdString(widget.addLabel));
ldapSearchListWidget->setRemoveButtonText(QString::fromStdString(widget.removeLabel));
QLayoutItem *container = createAndAttachLabel<QHBoxLayout>(ldapSearchListWidget,
QString::fromStdString(widget.postfix));
addToLayout(container);
}
void visit(RadioButton &widget) const
{
QRadioButton *radioButton = new QRadioButton();
radioButton->setChecked(widget.defaultChecked);
QLayoutItem *container = createAndAttachLabel<QHBoxLayout>(radioButton, "");
addToLayout(container);
}
void visit(Comment &widget) const
{
QLabel *label = new QLabel();
label->setText(QString::fromStdString(widget.text));
label->setWordWrap(true);
label->setAlignment(Qt::AlignHCenter);
addToLayout(label);
}
void visit(Text &widget) const
{
QLabel *label = new QLabel();
label->setText(QString::fromStdString(widget.content));
label->setWordWrap(true);
label->setAlignment(Qt::AlignHCenter);
addToLayout(label);
}
void setLayout(QLayout *layout) { m_layout = layout; }
void setSecurity(const SecurityDefinition &security) { m_security = &security; }
void setCurrentElementName(std::string elementName) { m_elementName = elementName; }
private:
QLayout *m_layout = nullptr;
const SecurityDefinition *m_security = nullptr;
std::string m_elementName = "";
private:
void addToLayout(QWidget *widget) const
{
if (m_layout)
{
m_layout->addWidget(widget);
}
}
void addToLayout(QLayoutItem *container) const
{
if (container)
{
m_layout->addItem(container);
}
}
private:
template<typename Number>
QWidget *createAnyDecimalTextBox(bool spin, Number value, Number step) const
{
if (spin)
{
::gui::AltSpinBox *spinBox = new ::gui::AltSpinBox();
spinBox->setMinimum(0);
spinBox->setMaximum(std::numeric_limits<int>::max());
spinBox->setSingleStep(step);
spinBox->setValue(value);
return spinBox;
}
QLineEdit *edit = new QLineEdit();
edit->setText(QString::number(value));
edit->setValidator(new QIntValidator(0, std::numeric_limits<int>::max()));
return edit;
}
};
PresentationBuilderPrivate* PresentationBuilder::d = new PresentationBuilderPrivate();
QVBoxLayout *PresentationBuilder::build(const PresentationBuilderParams &params)
{
QVBoxLayout *layout = new QVBoxLayout();
d->setLayout(layout);
d->setSecurity(params.security);
for (const auto &widget : params.presentation.widgets)
{
d->setCurrentElementName(widget.first);
std::visit([](auto&& arg) noexcept
{
using T = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<T, std::shared_ptr<DecimalTextBox> >)
{
d->visit(*arg);
}
else if constexpr (std::is_same_v<T, std::shared_ptr<TextBox> >)
{
d->visit(*arg);
}
else if constexpr (std::is_same_v<T, std::shared_ptr<CheckBox> >)
{
d->visit(*arg);
}
else if constexpr (std::is_same_v<T, std::shared_ptr<ComboBox> >)
{
d->visit(*arg);
}
else if constexpr (std::is_same_v<T, std::shared_ptr<DropdownList> >)
{
d->visit(*arg);
}
else if constexpr (std::is_same_v<T, std::shared_ptr<LongDecimalTextBox> >)
{
d->visit(*arg);
}
else if constexpr (std::is_same_v<T, std::shared_ptr<MultiTextBox> >)
{
d->visit(*arg);
}
else if constexpr (std::is_same_v<T, std::shared_ptr<GroupBox> >)
{
d->visit(*arg);
}
else if constexpr (std::is_same_v<T, std::shared_ptr<ListBox> >)
{
d->visit(*arg);
}
else if constexpr (std::is_same_v<T, std::shared_ptr<Comment> >)
{
d->visit(*arg);
}
else if constexpr (std::is_same_v<T, std::shared_ptr<Text> >)
{
d->visit(*arg);
}
else if constexpr (std::is_same_v<T, std::shared_ptr<LdapSearchDialog> >)
{
d->visit(*arg);
}
else if constexpr (std::is_same_v<T, std::shared_ptr<RadioButton> >)
{
d->visit(*arg);
}
else
{
static_assert(always_false_v<T>, "non-exhaustive visitor!");
}
}, widget.second);
}
layout->addStretch();
return layout;
}
}

View File

@ -0,0 +1,65 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef GPUI_SECURITY_PRESENTATION_BUILDER_H
#define GPUI_SECURITY_PRESENTATION_BUILDER_H
#include <QWidget>
#include <QDialogButtonBox>
#include <QVBoxLayout>
namespace security
{
class SecurityPresentation;
class SecurityDefinition;
}
namespace security
{
struct PresentationBuilderParams final
{
const security::SecurityPresentation& presentation;
const security::SecurityDefinition& security;
};
class PresentationBuilderPrivate;
/*!
* \class PresentationBuilder
* \brief The PresentationBuilder class
*
* \ingroup gui
*/
class PresentationBuilder
{
public:
/*!
* @brief build
* @param presentation Defines a reference to policy representation.
* @return nullptr if build failed, and widget associated with policy otherwise.
*/
static QVBoxLayout *build(const PresentationBuilderParams& params);
private:
static PresentationBuilderPrivate* d;
};
}
#endif // GPUI_SECURITY_PRESENTATION_BUILDER_H

View File

@ -0,0 +1,73 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#include "securityproxymodel.h"
#include "../administrative_templates/bundle/itemtype.h"
#include "../administrative_templates/bundle/policyroles.h"
#include "securitywidget.h"
namespace security
{
class SecurityProxyModelPrivate
{
public:
};
SecurityProxyModel::SecurityProxyModel()
: d(new SecurityProxyModelPrivate())
{
}
SecurityProxyModel::~SecurityProxyModel()
{
delete d;
}
QVariant SecurityProxyModel::data(const QModelIndex &proxyIndex, int role) const
{
if (role == model::bundle::POLICY_WIDGET)
{
std::function<QWidget *()> widgetCreator = [=]() {
auto contentWidget = new SecurityWidget();
contentWidget->setMachineSecuritySource();
contentWidget->setUserSecuritySource();
contentWidget->setModelIndex(proxyIndex);
connect(contentWidget,
&SecurityWidget::savePolicyChanges,
this,
&SecurityProxyModel::savePolicyChanges);
return contentWidget;
};
return QVariant::fromValue(widgetCreator);
}
return QIdentityProxyModel::data(proxyIndex, role);
}
} // namespace security
Q_DECLARE_METATYPE(std::function<QWidget *()>)

View File

@ -0,0 +1,58 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef GPUI_SECURITY_PROXY_MODEL_H
#define GPUI_SECURITY_PROXY_MODEL_H
#include <QIdentityProxyModel>
namespace security
{
class SecurityProxyModelPrivate;
class SecurityProxyModel : public QIdentityProxyModel
{
Q_OBJECT
public:
SecurityProxyModel();
~SecurityProxyModel();
QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const override;
void setUserSecuritySource();
void setMachineSecuritySource();
signals:
void savePolicyChanges();
private:
SecurityProxyModelPrivate *d = nullptr;
private:
SecurityProxyModel(const SecurityProxyModel &) = delete; // copy ctor
SecurityProxyModel(SecurityProxyModel &&) = delete; // move ctor
SecurityProxyModel &operator=(const SecurityProxyModel &) = delete; // copy assignment
SecurityProxyModel &operator=(SecurityProxyModel &&) = delete; // move assignment
};
} // namespace security
#endif // GPUI_SECURITY_PROXY_MODEL_H

View File

@ -0,0 +1,99 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#include "securitywidget.h"
#include "ui_securitywidget.h"
#include "../administrative_templates/bundle/itemtype.h"
#include "../administrative_templates/bundle/policyroles.h"
#include "../sdmx/securitydefinition.h"
#include "../presentation/securitypresentation.h"
#include "presentationbuilder.h"
using namespace model::bundle;
namespace security
{
typedef std::shared_ptr<::security::SecurityDefinition> SecurityPtr;
typedef std::shared_ptr<::security::SecurityPresentation> PresentationPtr;
SecurityWidget::SecurityWidget(QWidget *parent)
: PluginWidgetInterface(parent)
, ui(new Ui::SecurityWidget())
{
ui->setupUi(this);
}
SecurityWidget::~SecurityWidget()
{
delete ui;
}
void SecurityWidget::setModelIndex(const QModelIndex &index)
{
const QAbstractItemModel *model = index.model();
if (model)
{
ui->securityNameLabel->setText((tr("Security policy: ") + model->data(index, Qt::DisplayRole).value<QString>()).trimmed());
ui->descriptionTextEdit->setText(model->data(index, PolicyRoles::EXPLAIN_TEXT).value<QString>());
if (model->data(index, PolicyRoles::ITEM_TYPE).value<uint>() == ItemType::ITEM_TYPE_POLICY)
{
auto presentation = model->data(index, PolicyRoles::PRESENTATION).value<PresentationPtr>();
auto security = model->data(index, PolicyRoles::POLICY).value<SecurityPtr>();
if (presentation && security)
{
auto layout = ::security::PresentationBuilder::build(
{
*presentation,
*security,
});
if (layout)
{
ui->contentScrollArea->widget()->setLayout(layout);
}
}
}
}
}
void SecurityWidget::setUserSecuritySource()
{
}
void SecurityWidget::setMachineSecuritySource()
{
}
bool SecurityWidget::hasDataChanged()
{
return false;
}
}
Q_DECLARE_METATYPE(std::shared_ptr<::security::SecurityDefinition>)
Q_DECLARE_METATYPE(std::shared_ptr<::security::SecurityPresentation>)

View File

@ -0,0 +1,66 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef SECURITY_SECURITY_WIDGET_H
#define SECURITY_SECURITY_WIDGET_H
#include <QtWidgets>
#include "../../gui/pluginwidgetinterface.h"
QT_BEGIN_NAMESPACE
namespace Ui { class SecurityWidget; }
QT_END_NAMESPACE
namespace security
{
class SecurityWidget : public gui::PluginWidgetInterface
{
public:
Q_OBJECT
public:
explicit SecurityWidget(QWidget* parent = nullptr);
~SecurityWidget();
void setModelIndex(const QModelIndex &index);
void setUserSecuritySource();
void setMachineSecuritySource();
virtual bool hasDataChanged() override final;
signals:
void savePolicyChanges();
private:
SecurityWidget(const SecurityWidget&) = delete; // copy ctor
SecurityWidget(SecurityWidget&&) = delete; // move ctor
SecurityWidget& operator=(const SecurityWidget&) = delete; // copy assignment
SecurityWidget& operator=(SecurityWidget&&) = delete; // move assignment
private:
Ui::SecurityWidget *ui {nullptr};
};
}
#endif // SECURITY_SECURITY_WIDGET_H

View File

@ -0,0 +1,161 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SecurityWidget</class>
<widget class="QWidget" name="SecurityWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>649</width>
<height>544</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item row="0" column="0" colspan="3">
<widget class="QFrame" name="securityNameFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>52</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>52</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="securityNameLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QScrollArea" name="contentScrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>445</height>
</rect>
</property>
</widget>
</widget>
<widget class="QWidget" name="">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="helpLabel">
<property name="text">
<string>Help:</string>
</property>
<property name="buddy">
<cstring>descriptionTextEdit</cstring>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="descriptionTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>4</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>215</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>508</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="cancelPushButton">
<property name="text">
<string>&amp;Cancel</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="okPushButton">
<property name="text">
<string>&amp;OK</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,10 @@
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(XSD_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/basetypes.xsd"
"${CMAKE_CURRENT_SOURCE_DIR}/securitydefinitions.xsd"
"${CMAKE_CURRENT_SOURCE_DIR}/securitydefinitionfiles.xsd"
"${CMAKE_CURRENT_SOURCE_DIR}/security.xsd"
)
add_xsd_library(security_static_xsd_library ${XSD_FILES})

View File

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ADMX" elementFormDefault="qualified" targetNamespace="http://www.microsoft.com/GroupPolicy/PolicyDefinitions" xmlns:pd="http://www.microsoft.com/GroupPolicy/PolicyDefinitions" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="GUID">
<xs:annotation>
<xs:documentation>A standard {12345678-1234-1234-1234-123456789abcd} style guid string.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="\{[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="versionString">
<xs:restriction base="xs:token">
<xs:pattern value="[0-9]{1,4}\.[0-9]{1,5}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="stringReference">
<xs:annotation>
<xs:documentation>A reference to a localized string in the localized string section/table.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="\\$\(string\.(\p{L}|\p{N}|_)+\)"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="presentationReference">
<xs:annotation>
<xs:documentation>A reference to a policy presentation in the localized presentation section/table.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="\\$\(presentation\.(\p{L}|\p{N}|_)+\)"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="resourceID">
<xs:annotation>
<xs:documentation>A localized string id (used in the localized string section/table).</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="(\p{L}|\p{N}|_)+"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="Annotation" mixed="true">
<xs:sequence>
<xs:any processContents="skip"/>
</xs:sequence>
<xs:attribute name="application" type="xs:string" use="required"/>
</xs:complexType>
<xs:simpleType name="itemName">
<xs:annotation>
<xs:documentation>The base type for all defined type names, e.g. categories.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="(\p{L}|\p{N}|_)+"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="itemReference">
<xs:annotation>
<xs:documentation>The base type for all references to defined types, e.g. categories.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="((\p{L}|\p{N}|_)+)|((\p{L}|\p{N}|_)+:(\p{L}|\p{N}|_)+)"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="LocalizedString">
<xs:annotation>
<xs:documentation>A localized string</xs:documentation>
</xs:annotation>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="id" type="pd:resourceID" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="registryKey">
<xs:annotation>
<xs:documentation>A valid registry key path (without reference to local system or user hive).</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:simpleType name="registryValueName">
<xs:annotation>
<xs:documentation>A valid registry value
name.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:simpleType name="fileName">
<xs:annotation>
<xs:documentation>A valid file name (without a file path).
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:schema>

View File

@ -0,0 +1,427 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.basealt.ru/GroupPolicy/SecurityDefinitions" xmlns="http://www.basealt.ru/GroupPolicy/SecurityDefinitions">
<xsd:complexType name="BooleanElement">
<xsd:annotation>
<xsd:documentation>Describes a choice element in a policy with associated values for the true and false cases.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="SecurityElement"/>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="DecimalElement">
<xsd:complexContent>
<xsd:extension base="SecurityElement">
<xsd:attribute default="false" name="required" type="xsd:boolean"/>
<xsd:attribute default="false" name="soft" type="xsd:boolean"/>
<xsd:attribute default="false" name="storeAsText" type="xsd:boolean"/>
<xsd:attribute name="minValue" type="xsd:int"/>
<xsd:attribute name="maxValue" type="xsd:int"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="EnumerationElement">
<xsd:complexContent>
<xsd:extension base="SecurityElement">
<xsd:attribute default="false" name="required" type="xsd:boolean"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="LongDecimalElement">
<xsd:complexContent>
<xsd:extension base="SecurityElement">
<xsd:attribute default="false" name="required" type="xsd:boolean"/>
<xsd:attribute default="false" name="soft" type="xsd:boolean"/>
<xsd:attribute default="false" name="storeAsText" type="xsd:boolean"/>
<xsd:attribute name="minValue" type="xsd:long"/>
<xsd:attribute name="maxValue" type="xsd:long"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="ListElement">
<xsd:annotation>
<xsd:documentation>Describes a list element in a security policy.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="SecurityElement">
<xsd:attribute name="valuePrefix" type="xsd:string"/>
<xsd:attribute name="additive" type="xsd:boolean"/>
<xsd:attribute name="expandable" type="xsd:boolean"/>
<xsd:attribute name="explicitValue" type="xsd:boolean"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="MultiTextElement">
<xsd:annotation>
<xsd:documentation>Describes a multi line text element in a policy.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="SecurityElement"/>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="TextElement">
<xsd:annotation>
<xsd:documentation>Describes a single line text element in a policy.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="SecurityElement">
<xsd:attribute default="false" name="required" type="xsd:boolean"/>
<xsd:attribute default="1024" name="maxLength" type="xsd:int"/>
<xsd:attribute default="false" name="soft" type="xsd:boolean"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="SecurityDefinition">
<xsd:sequence>
<xsd:element type="CategoryReference" minOccurs="0" maxOccurs="1" name="parentCategory"/>
<xsd:element type="SecurityElements" minOccurs="0" maxOccurs="1" name="elements"/>
<xsd:element type="SecurityValue" minOccurs="0" maxOccurs="1" name="enabledValue"/>
<xsd:element type="SecurityValue" minOccurs="0" maxOccurs="1" name="disabledValue"/>
<xsd:element type="SecurityValueList" minOccurs="0" maxOccurs="1" name="enabledList"/>
<xsd:element type="SecurityValueList" minOccurs="0" maxOccurs="1" name="disabledList"/>
</xsd:sequence>
<xsd:attribute name="name" type="ItemReference" use="required"/>
<xsd:attribute name="displayName" type="StringReference" use="required"/>
<xsd:attribute name="explainText" type="StringReference"/>
<xsd:attribute name="sectionName" type="SectionName" use="required"/>
<xsd:attribute name="propertyName" type="PropertyName"/>
<xsd:attribute name="presentation" type="StringReference"/>
<xsd:attribute name="class" type="SecurityType" use="required"/>
</xsd:complexType>
<xsd:simpleType name="SecurityType">
<xsd:annotation>
<xsd:documentation>An enumeration of the 3 possible types a security definition can belong to.</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Machine"/>
<xsd:enumeration value="User"/>
<xsd:enumeration value="Both"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="Category">
<xsd:annotation>
<xsd:documentation>A grouping of security definitions.</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="keywords" nillable="true" type="xsd:string"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="seeAlso" nillable="true" type="xsd:string"/>
<xsd:element type="CategoryReference" name="parentCategory"/>
</xsd:sequence>
<xsd:attribute name="name" type="ItemReference" use="required"/>
<xsd:attribute name="displayName" type="StringReference" use="required"/>
<xsd:attribute name="explainText" type="StringReference"/>
</xsd:complexType>
<xsd:complexType name="CategoryReference">
<xsd:attribute name="ref" type="ItemReference" use="required"/>
</xsd:complexType>
<xsd:simpleType name="ItemReference">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:simpleType name="StringReference">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:complexType name="SecurityList">
<xsd:sequence minOccurs="1" maxOccurs="unbounded">
<xsd:element name="securityDefinition" type="SecurityDefinition"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SecurityDefinitions">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="security" type="SecurityList"/>
</xsd:sequence>
<xsd:attribute name="revision" type="xsd:string"/>
<xsd:attribute name="schemaVersion" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="SecurityElements">
<xsd:sequence>
<xsd:element minOccurs="0" type="BooleanElement" maxOccurs="unbounded" name="boolean"/>
<xsd:element minOccurs="0" type="DecimalElement" maxOccurs="unbounded" name="decimal"/>
<xsd:element minOccurs="0" type="TextElement" maxOccurs="unbounded" name="text"/>
<xsd:element minOccurs="0" type="EnumerationElement" maxOccurs="unbounded" name="enum"/>
<xsd:element minOccurs="0" type="ListElement" maxOccurs="unbounded" name="list"/>
<xsd:element minOccurs="0" type="LongDecimalElement" maxOccurs="unbounded" name="longDecimal"/>
<xsd:element minOccurs="0" type="MultiTextElement" maxOccurs="unbounded" name="multiText"/>
<xsd:choice maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="SectionName">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:simpleType name="PropertyName">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:complexType name="SecurityElement">
<xsd:attribute name="id" type="xsd:string" use="required"/>
<xsd:attribute name="clientExtension" type="xsd:string"/>
<xsd:attribute name="propertyName" type="PropertyName" use="required"/>
</xsd:complexType>
<xsd:complexType name="SecurityValue">
<xsd:sequence>
<xsd:element type="DecimalType" minOccurs="0" name="decimal"/>
<xsd:element type="LongDecimalType" minOccurs="0" name="longDecimal"/>
<xsd:element minOccurs="0" name="string" type="SecurityType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SecurityItem">
<xsd:sequence>
<xsd:element type="SecurityValue" name="value"/>
</xsd:sequence>
<xsd:attribute name="sectionName" type="SectionName"/>
<xsd:attribute name="peropertyName" type="PropertyName" use="required"/>
</xsd:complexType>
<xsd:complexType name="SecurityValueList">
<xsd:sequence>
<xsd:element type="SecurityValue" maxOccurs="unbounded" minOccurs="0" name="item"/>
</xsd:sequence>
<xsd:attribute name="defaultSectionName" type="SectionName"/>
</xsd:complexType>
<xsd:complexType name="DecimalType">
<xsd:attribute name="value" type="xsd:int"/>
</xsd:complexType>
<xsd:complexType name="LongDecimalType">
<xsd:attribute name="value" type="xsd:long"/>
</xsd:complexType>
<xsd:simpleType name="StringType">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="255"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="SecurityPresentation">
<xsd:annotation>
<xsd:documentation>Root presentation element.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="PresentationElements">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="text" nillable="true" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="id" type="ResourceID" use="required"/>
<xsd:attribute name="icon" type="xsd:string"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="CheckBox">
<xsd:annotation>
<xsd:documentation>Represents a checkbox display element.\nCan be associated with a BooleanElement.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="DataElementContent">
<xsd:attribute name="defaultChecked" type="xsd:boolean"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="DataElementContent">
<xsd:attribute name="value" type="xsd:string"/>
<xsd:attribute name="refId" type="xsd:string" use="required"/>
<xsd:attribute name="postfix" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="DecimalTextBox">
<xsd:annotation>
<xsd:documentation>Represents a text box with or without a spin control for entering decimal numbers.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="DataElementContent">
<xsd:attribute name="defaultValue" type="xsd:int"/>
<xsd:attribute name="spin" type="xsd:boolean"/>
<xsd:attribute name="spinStep" type="xsd:int"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="GroupBox">
<xsd:complexContent>
<xsd:extension base="DataElementContent">
<xsd:sequence>
<xsd:element type="PresentationElements" minOccurs="0" name="elements"/>
</xsd:sequence>
<xsd:attribute name="hasCheckBox" type="xsd:boolean"/>
<xsd:attribute name="defaultChecked" type="xsd:boolean"/>
<xsd:attribute name="label" type="xsd:string"/>
<xsd:attribute name="hasBorder" type="xsd:boolean"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="PresentationElements">
<xsd:sequence>
<xsd:element minOccurs="0" type="DecimalTextBox" maxOccurs="unbounded" name="decimalTextBox"/>
<xsd:element minOccurs="0" type="TextBox" maxOccurs="unbounded" name="textBox"/>
<xsd:element minOccurs="0" type="CheckBox" maxOccurs="unbounded" name="checkBox"/>
<xsd:element minOccurs="0" type="ComboBox" maxOccurs="unbounded" name="comboBox"/>
<xsd:element minOccurs="0" type="DropdownList" maxOccurs="unbounded" name="dropdownList"/>
<xsd:element minOccurs="0" type="LongDecimalTextBox" maxOccurs="unbounded" name="longDecimalTextBox"/>
<xsd:element minOccurs="0" type="MultiTextBox" maxOccurs="unbounded" name="multiTextBox"/>
<xsd:element minOccurs="0" type="GroupBox" maxOccurs="unbounded" name="groupBox"/>
<xsd:choice maxOccurs="unbounded">
<xsd:element minOccurs="0" type="ListBox" maxOccurs="unbounded" name="listBox"/>
<xsd:element minOccurs="0" type="Comment" maxOccurs="unbounded" name="comment"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="ResourceID">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:complexType name="ComboBox">
<xsd:annotation>
<xsd:documentation>Represents a combobox display element with default/suggested entries.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="DataElementContent">
<xsd:sequence>
<xsd:element name="label" type="xsd:string"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="suggestion" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="noSort" type="xsd:boolean"/>
</xsd:sequence>
<xsd:attribute name="defaultChecked" type="xsd:boolean"/>
<xsd:attribute name="default" type="xsd:string"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="TextBox">
<xsd:annotation>
<xsd:documentation>Represents a textbox display element with default entry.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="DataElementContent">
<xsd:sequence>
<xsd:element name="label" type="xsd:string"/>
<xsd:element minOccurs="0" name="defaultValue" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="DropdownList">
<xsd:annotation>
<xsd:documentation>Represents a dropdown list display element.</xsd:documentation>
</xsd:annotation>
<xsd:attribute name="defaultItem" type="xsd:unsignedInt"/>
<xsd:attribute name="noSort" type="xsd:boolean"/>
</xsd:complexType>
<xsd:complexType name="MultiTextBox">
<xsd:annotation>
<xsd:documentation>Represents a textbox display element with default entry.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="DataElement">
<xsd:sequence>
<xsd:element name="label" type="xsd:string"/>
<xsd:element minOccurs="0" name="defaultValue" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="ListBox">
<xsd:annotation>
<xsd:documentation>Represents a listbox display element.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="DataElementContent"/>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="Comment">
<xsd:annotation>
<xsd:documentation>Represents a comment display element.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="DataElement">
<xsd:attribute name="text" type="StringReference" use="required"/>
<xsd:attribute name="image" type="xsd:string"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="SecurityDescriptorEditor">
<xsd:annotation>
<xsd:documentation>Represents a security descriptor editor display element.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="DataElement">
<xsd:attribute name="label" type="xsd:string" use="required"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="LdapSearchDialog">
<xsd:annotation>
<xsd:documentation>Represents a LDAP search dialog display element.\nCan be associated with a TextElement.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="DataElementContent">
<xsd:attribute name="dn" type="xsd:string"/>
<xsd:attribute name="filter" type="xsd:string"/>
<xsd:attribute name="addLabel" type="StringReference"/>
<xsd:attribute name="removeLabel" type="StringReference"/>
<xsd:attribute name="title" type="StringReference"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="RadioButton">
<xsd:annotation>
<xsd:documentation>Represents a radio button display element.\nCan be associated with a BooleanElement.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="DataElement">
<xsd:attribute name="defaultChecked" type="xsd:boolean"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:simpleType name="GUID">
<xsd:annotation>
<xsd:documentation>A standard {12345678-1234-1234-1234-123456789abcd} style guid string.</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:pattern value="\{[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\}"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="DataElement">
<xsd:attribute name="refId" type="xsd:string" use="required"/>
</xsd:complexType>
<xsd:complexType name="LongDecimalTextBox">
<xsd:annotation>
<xsd:documentation>Represents a text box with or without a spin control for entering long decimal numbers.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="DataElementContent">
<xsd:attribute name="defaultValue" type="xsd:long"/>
<xsd:attribute name="spin" type="xsd:boolean"/>
<xsd:attribute name="spinStep" type="xsd:long"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="LocalizedString">
<xsd:annotation>
<xsd:documentation>A localized string</xsd:documentation>
</xsd:annotation>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="id" type="xsd:string" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="StringTable">
<xsd:sequence minOccurs="1" maxOccurs="unbounded">
<xsd:element name="string" type="LocalizedString"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="PresentationTable">
<xsd:sequence minOccurs="1" maxOccurs="unbounded">
<xsd:element name="presentation" type="SecurityPresentation"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SecurityLocalization">
<xsd:annotation>
<xsd:documentation>A table of referenced localized strings and policy presentations.</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="stringTable" minOccurs="0" type="StringTable"/>
<xsd:element name="presentationTable" minOccurs="0" type="PresentationTable"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SecurityPresentationResources">
<xsd:sequence>
<xsd:element name="displayName" type="xsd:string"/>
<xsd:element name="description" type="xsd:string"/>
<xsd:element name="annotation" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="resources" type="SecurityLocalization" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="revision" type="xsd:string" use="required"/>
<xsd:attribute name="schemaVersion" type="xsd:string" use="required"/>
</xsd:complexType>
<xsd:element name="securityDefinitions" type="SecurityDefinitions"/>
<xsd:element name="securityPresentationResources" type="SecurityPresentationResources"/>
</xsd:schema>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="SCMX" elementFormDefault="qualified" targetNamespace="http://www.microsoft.com/GroupPolicy/PolicyDefinitions" xmlns:pd="http://www.microsoft.com/GroupPolicy/PolicyDefinitions" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
</xs:schema>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="SCMX" targetNamespace="http://www.microsoft.com/GroupPolicy/PolicyDefinitions" elementFormDefault="qualified" xmlns:pd="http://www.microsoft.com/GroupPolicy/PolicyDefinitions" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
<xs:include schemaLocation="basetypes.xsd"/>
</xs:schema>

View File

@ -0,0 +1,40 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#include "core/plugin.h"
#include "securitysnapin.h"
#include "core/isnapin.h"
namespace gpui
{
class SecurityPlugin : public Plugin
{
public:
SecurityPlugin()
: gpui::Plugin("SecuritySnapIn")
{
GPUI_REGISTER_PLUGIN_CLASS(typeid(::gpui::ISnapIn).name(), SecuritySnapIn);
}
};
} // namespace gpui
GPUI_EXPORT_PLUGIN(security, ::gpui::SecurityPlugin)

View File

@ -0,0 +1,167 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#include "securitysnapin.h"
#include <gui/mainwindow.h>
#include "model/ui/securityproxymodel.h"
#include "model/bundle/securitybundle.h"
#include "../storage/smb/smbdirectory.h"
using namespace security;
namespace gpui
{
class SecuritySnapInPrivate
{
public:
std::string sdmxPath = "/usr/share/PolicyDefinitions/";
std::string localeName = "en-US";
std::string policyPath = "";
std::unique_ptr<QStandardItemModel> model = nullptr;
std::unique_ptr<SecurityProxyModel> proxyModel = nullptr;
void onDataSave()
{
createDirectory(policyPath + "/User/");
createDirectory(policyPath + "/Machine/");
}
void policyBundleLoad()
{
auto bundle = std::make_unique<security::SecurityBundle>();
model = bundle->loadFolder(sdmxPath, localeName);
proxyModel->setSourceModel(model.get());
}
void createDirectory(const std::string &directoryName)
{
const QString path = QString::fromStdString(directoryName);
if (path.startsWith("smb://"))
{
gpui::smb::SmbDirectory dir(path);
if (!dir.exists())
{
dir.mkdir(path);
}
}
else
{
QDir dir(path);
if (!dir.exists())
{
dir.mkdir(path);
}
}
}
SecuritySnapInPrivate() {}
private:
SecuritySnapInPrivate(const SecuritySnapInPrivate&) = delete; // copy ctor
SecuritySnapInPrivate(SecuritySnapInPrivate&&) = delete; // move ctor
SecuritySnapInPrivate& operator=(const SecuritySnapInPrivate&) = delete; // copy assignment
SecuritySnapInPrivate& operator=(SecuritySnapInPrivate&&) = delete; // move assignment
};
SecuritySnapIn::SecuritySnapIn()
: AbstractSnapIn("ISnapIn",
"SecuritySnapIn",
"Snap-in for security management.",
{1, 0, 0},
"GPL-2.0",
"Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>")
, d(new SecuritySnapInPrivate())
{
}
void SecuritySnapIn::onInitialize(QMainWindow *window)
{
auto mainWindow = dynamic_cast<::gpui::MainWindow *>(window);
if (mainWindow)
{
d->sdmxPath = mainWindow->getAdmxPath().toStdString();
d->localeName = mainWindow->getLanguage().toStdString();
qWarning() << "Setting default settings for security templates snap-in: "
<< d->sdmxPath.c_str()
<< d->localeName.c_str();
}
d->proxyModel = std::make_unique<SecurityProxyModel>();
d->policyBundleLoad();
QObject::connect(d->proxyModel.get(), &SecurityProxyModel::savePolicyChanges, [&]() {
d->onDataSave();
});
setRootNode(static_cast<QAbstractItemModel *>(d->proxyModel.get()));
if (mainWindow)
{
QObject::connect(mainWindow, &MainWindow::admxPathChanged, [&](const QString &admxPath) {
qWarning() << "Loading bundle from snap-in: " << admxPath;
d->sdmxPath = admxPath.toStdString();
d->policyBundleLoad();
});
QObject::connect(d->proxyModel.get(),
&SecurityProxyModel::savePolicyChanges,
mainWindow,
&MainWindow::updateStatusBar);
}
}
void SecuritySnapIn::onShutdown()
{
}
void SecuritySnapIn::onDataLoad(const std::string &policyPath, const std::string &locale)
{
Q_UNUSED(locale);
if (!policyPath.empty())
{
d->policyPath = policyPath;
}
}
void SecuritySnapIn::onDataSave()
{
d->onDataSave();
}
void SecuritySnapIn::onRetranslateUI(const std::string &locale)
{
d->localeName = locale;
d->policyBundleLoad();
setRootNode(static_cast<QAbstractItemModel *>(d->proxyModel.get()));
}
}

View File

@ -0,0 +1,52 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef GPUI_SECURITY_SNAPIN_H
#define GPUI_SECURITY_SNAPIN_H
#include "core/abstractsnapin.h"
namespace gpui
{
class SecuritySnapInPrivate;
class SecuritySnapIn final : public AbstractSnapIn
{
public:
SecuritySnapIn();
void onInitialize(QMainWindow *mainWindow) override;
void onShutdown() override;
void onDataLoad(const std::string &policyPath, const std::string &locale) override;
void onDataSave() override;
void onRetranslateUI(const std::string &locale) override;
private:
std::unique_ptr<SecuritySnapInPrivate> d;
};
} // namespace gpui
#endif//GPUI_SECURITY_SNAPIN_H

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<SecurityDefinitionResources xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.0" schemaVersion="1.0" xmlns:security="http://www.basealt.ru/GroupPolicy/SecurityDefinitions" xsi:schemaLocation="http://www.basealt.ru/GroupPolicy/SecurityDefinitions">
<resources>
<stringTable>
<string id="SeDenyBatchLogonRight_Name">Deny log on as a batch job</string>
<string id="SeDenyBatchLogonRight_Help">
Deny log on as a service
This security setting determines which service accounts are prevented from registering a process as a service. This policy setting supersedes the Log on as a service policy setting if an account is subject to both policies.
Note: This security setting does not apply to the System, Local Service, or Network Service accounts.
Default: None.
</string>
</stringTable>
<presentationTable>
<presentation id="SeDenyBatchLogonRight">
<ldapSearchDialog refId="SeDenyBatchLogonRight_Editor" dn="" filter="" addLabel="" removeLabel=""/>
</presentation>
</presentationTable>
</resources>
</SecurityDefinitionResources>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<SecurityDefinitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.0" schemaVersion="1.0" xmlns:security="http://www.basealt.ru/GroupPolicy/SecurityDefinitions" xsi:schemaLocation="http://www.basealt.ru/GroupPolicy/SecurityDefinitions">
<policyNamespaces>
<target prefix="startmenu" namespace="Microsoft.Policies.StartMenu" />
<using prefix="windows" namespace="Microsoft.Policies.Windows" />
</policyNamespaces>
<resources minRequiredRevision="1.0" />
<policies>
<security name="SeDenyBatchLogonRight" displayName="$(string.SeDenyBatchLogonRight)" explainText="$(string.$(string.SeDenyBatchLogonRight_Help)" securityType="Machine">
<parentCategory ref="security:UserRightsAssignment" />
<elements>
<text id="SeDenyBatchLogonRight_Editor" sectionName="Privilege Rights" propertyName="SeDenyBatchLogonRight"/>
</elements>
</security>
</policies>
</SecurityDefinitions>