-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
144 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
|
||
module Registration | ||
module UI | ||
|
||
class ImportCertificateDialog | ||
include Yast::Logger | ||
include Yast::I18n | ||
include Yast::UIShortcuts | ||
|
||
Yast.import "UI" | ||
Yast.import "SignatureCheckDialogs" | ||
|
||
def self.run(cert) | ||
dialog = ImportCertificateDialog.new | ||
dialog.run(cert) | ||
end | ||
|
||
def initialize() | ||
textdomain "registration" | ||
end | ||
|
||
def run(cert) | ||
|
||
# popup message - label, part 1, %1 stands for repository name, %2 for its URL | ||
dialog_text = Builtins.sformat( | ||
_( | ||
"The following GnuPG key has been found in repository\n" + | ||
"%1\n" + | ||
"(%2):" | ||
), | ||
Ops.get_locale(repo, "name", _("Unknown")), | ||
Ops.get_locale(repo, "url", _("Unknown")) | ||
) | ||
|
||
# popup message - label, part 2 | ||
dialog_text2 = _( | ||
"You can choose to import it into your keyring of trusted\n" + | ||
"public keys, meaning that you trust the owner of the key.\n" + | ||
"You should be sure that you can trust the owner and that\n" + | ||
"the key really belongs to that owner before importing it." | ||
) | ||
|
||
if Time.now > cert.not_after | ||
dialog_text2 << "\n\n" << _("WARNING: The key has expired!") | ||
end | ||
|
||
|
||
UI.OpenDialog(Opt(:decorated), import_dialog_content(cert)) | ||
|
||
begin | ||
UI.SetFocus(:cancel) | ||
return UI.UserInput == :import | ||
ensure | ||
UI.CloseDialog | ||
end | ||
end | ||
|
||
private | ||
|
||
def certificate_description(cert) | ||
|
||
end | ||
|
||
def import_dialog_content(cert) | ||
displayinfo = UI.GetDisplayInfo | ||
# hide additional help text in narrow terminals | ||
hide_help = displayinfo["TextMode"] && displayinfo["Width"] < 105 | ||
|
||
HBox( | ||
# left-side help | ||
hide_help ? | ||
Empty() : | ||
HWeight(3, VBox(RichText(warning_text))), | ||
HSpacing(1.5), | ||
# dialog | ||
HWeight( | ||
5, | ||
VBox( | ||
HBox( | ||
VCenter(Yast::SignatureCheckDialogs.MessageIcon("question")), | ||
# popup heading | ||
VCenter(Heading(_("Import Untrusted SSL Certificate"))), | ||
HStretch() | ||
), | ||
# dialog message | ||
MarginBox( | ||
0.4, | ||
0.4, | ||
VBox( | ||
Left(Label(dialog_text)), | ||
certificate_description(cert), | ||
Left(Label(dialog_text2)) | ||
) | ||
), | ||
# dialog buttons | ||
ButtonBox( | ||
# push button | ||
PushButton(Id(:import), Opt(:key_F10, :okButton), _("&Import")), | ||
PushButton( | ||
Id(:cancel), | ||
Opt(:key_F9, :cancelButton), | ||
Label.CancelButton | ||
) | ||
) | ||
) | ||
) | ||
) | ||
end | ||
|
||
def self.warning_text | ||
# additional Richtext (HTML) warning text (kind of help), 1/2 | ||
_( | ||
"<p>The owner of the key may distribute updates,\n" + | ||
"packages, and package repositories that your system will trust and offer\n" + | ||
"for installation and update without any further warning. In this way,\n" + | ||
"importing the key into your keyring of trusted keys allows the key owner\n" + | ||
"to have a certain amount of control over the software on your system.</p>" | ||
) | ||
end | ||
|
||
|
||
end | ||
end | ||
end | ||
|