|
1
|
|
|
# |
|
2
|
|
|
# Copyright (C) 2020 Red Hat, Inc. |
|
3
|
|
|
# |
|
4
|
|
|
# This copyrighted material is made available to anyone wishing to use, |
|
5
|
|
|
# modify, copy, or redistribute it subject to the terms and conditions of |
|
6
|
|
|
# the GNU General Public License v.2, or (at your option) any later version. |
|
7
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT |
|
8
|
|
|
# ANY WARRANTY expressed or implied, including the implied warranties of |
|
9
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
|
10
|
|
|
# Public License for more details. You should have received a copy of the |
|
11
|
|
|
# GNU General Public License along with this program; if not, write to the |
|
12
|
|
|
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
13
|
|
|
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the |
|
14
|
|
|
# source code or documentation are not subject to the GNU General Public |
|
15
|
|
|
# License and may only be used or replicated with the express permission of |
|
16
|
|
|
# Red Hat, Inc. |
|
17
|
|
|
# |
|
18
|
|
|
from dasbus.server.interface import dbus_interface |
|
19
|
|
|
from dasbus.server.property import emits_properties_changed |
|
20
|
|
|
from dasbus.typing import * # pylint: disable=wildcard-import |
|
21
|
|
|
|
|
22
|
|
|
from pyanaconda.modules.common.base import KickstartModuleInterface |
|
23
|
|
|
|
|
24
|
|
|
from org_fedora_oscap.constants import OSCAP |
|
25
|
|
|
from org_fedora_oscap.structures import PolicyData |
|
26
|
|
|
|
|
27
|
|
|
__all__ = ["OSCAPInterface"] |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
@dbus_interface(OSCAP.interface_name) |
|
31
|
|
|
class OSCAPInterface(KickstartModuleInterface): |
|
32
|
|
|
"""The DBus interface of the OSCAP service.""" |
|
33
|
|
|
|
|
34
|
|
|
def connect_signals(self): |
|
35
|
|
|
super().connect_signals() |
|
36
|
|
|
self.watch_property("PolicyEnabled", self.implementation.policy_enabled_changed) |
|
37
|
|
|
self.watch_property("PolicyData", self.implementation.policy_data_changed) |
|
38
|
|
|
|
|
39
|
|
|
@property |
|
40
|
|
|
def PolicyEnabled(self) -> Bool: |
|
41
|
|
|
"""Is the security policy enabled? |
|
42
|
|
|
|
|
43
|
|
|
:return: True or False |
|
44
|
|
|
""" |
|
45
|
|
|
return self.implementation.policy_enabled |
|
46
|
|
|
|
|
47
|
|
|
@PolicyEnabled.setter |
|
48
|
|
|
@emits_properties_changed |
|
49
|
|
|
def PolicyEnabled(self, value: Bool): |
|
50
|
|
|
"""Should be the security policy enabled? |
|
51
|
|
|
|
|
52
|
|
|
:param value: True or False |
|
53
|
|
|
""" |
|
54
|
|
|
self.implementation.policy_enabled = value |
|
55
|
|
|
|
|
56
|
|
|
@property |
|
57
|
|
|
def PolicyData(self) -> Structure: |
|
58
|
|
|
"""The security policy data. |
|
59
|
|
|
|
|
60
|
|
|
:return: a structure defined by the PolicyData class |
|
61
|
|
|
""" |
|
62
|
|
|
return PolicyData.to_structure(self.implementation.policy_data) |
|
63
|
|
|
|
|
64
|
|
|
@PolicyData.setter |
|
65
|
|
|
@emits_properties_changed |
|
66
|
|
|
def PolicyData(self, value: Structure): |
|
67
|
|
|
"""Set the security policy data. |
|
68
|
|
|
|
|
69
|
|
|
:param value: a structure defined by the PolicyData class |
|
70
|
|
|
""" |
|
71
|
|
|
self.implementation.policy_data = PolicyData.from_structure(value) |
|
72
|
|
|
|