Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom error info on Windows eID PKCS missing dll dependecies #382

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import eu.europa.esig.dss.model.DSSException;
import eu.europa.esig.dss.spi.exception.DSSExternalResourceException;

import java.io.IOException;

public class AutogramException extends RuntimeException {
private final String heading;
private final String subheading;
Expand Down Expand Up @@ -59,6 +61,8 @@ public static AutogramException createFromDSSException(DSSException e) {
return new TsaServerMisconfiguredException("Nastavený TSA server odmietol pridať časovú pečiatku. Skontrolujte nastavenia TSA servera.", cause);
} else if (cause instanceof NullPointerException && cause.getMessage().contains("Host name")) {
return new TsaServerMisconfiguredException("Nie je nastavená žiadna adresa TSA servera. Skontrolujte nastavenia TSA servera.", cause);
} else if (cause instanceof IOException && cause.getMessage().contains("The specified module could not be found")) {
return new PkcsEidWindowsDllException(e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package digital.slovensko.autogram.core.errors;

public class PkcsEidWindowsDllException extends AutogramException {
public PkcsEidWindowsDllException(Exception e) {
super("Chyba komunikácie s kartou", "Ovládač nie je možné použiť", "Nie je možné použiť ovládač pre podpisovanie vybranou kartou. Pravdepodobne je potrebné do systému nainštalovať balík Microsoft Visual C++ 2015 Redistributable.\n\nAk to nepomôže, kontaktujte nás na podpora@slovensko.digital", e);
}
}
2 changes: 2 additions & 0 deletions src/main/java/digital/slovensko/autogram/ui/cli/CliUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ public static String parseError(AutogramException e) {
return "TSA server refused to add timestamp. Check TSA server configuration.";
} else if (e instanceof SlotIndexOutOfRangeException) {
return "Provided slot index is out of range for chosen driver.";
} else if (e instanceof PkcsEidWindowsDllException) {
return "PKCS library problem. Microsoft Visual C++ 2015 Redistributable probably needs to be installed.";
} else {
e.printStackTrace();
return "Unknown error occurred";
Expand Down
23 changes: 22 additions & 1 deletion src/main/java/digital/slovensko/autogram/ui/gui/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,23 @@ public void showError(AutogramException e) {
stage.show();
}

public void showPkcsEidWindowsDllError(AutogramException e) {
var controller = new PkcsEidWindowsDllErrorController(hostServices);
var root = GUIUtils.loadFXML(controller, "pkcs-eid-windows-dll-error-dialog.fxml");

var stage = new Stage();
stage.setTitle(e.getSubheading());
stage.setScene(new Scene(root));

stage.sizeToScene();
stage.setResizable(false);
stage.initModality(Modality.APPLICATION_MODAL);

GUIUtils.suppressDefaultFocus(stage, controller);

stage.show();
}

public char[] getKeystorePassword() {
var futurePassword = new FutureTask<>(() -> {
var controller = new PasswordController("Aký je kód k úložisku klúčov?", "Zadajte kód k úložisku klúčov.", false, true);
Expand Down Expand Up @@ -353,7 +370,11 @@ private void disableKeyPicking() {

@Override
public void onPickSigningKeyFailed(AutogramException e) {
showError(e);
if (e instanceof PkcsEidWindowsDllException)
showPkcsEidWindowsDllError(e);
else
showError(e);

resetSigningKey();
enableSigningOnAllJobs();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package digital.slovensko.autogram.ui.gui;

import javafx.application.HostServices;
import javafx.fxml.FXML;
import javafx.event.ActionEvent;
import javafx.scene.Node;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class PkcsEidWindowsDllErrorController implements SuppressedFocusController {
private final HostServices hostServices;

@FXML
VBox mainBox;

public PkcsEidWindowsDllErrorController(HostServices hostServices) {
this.hostServices = hostServices;
}

public void downloadAction(ActionEvent ignored) {
hostServices.showDocument("https://sluzby.slovensko.digital/autogram/vc-redist-redirect");
}

public void onMainButtonAction() {
((Stage) mainBox.getScene().getWindow()).close();
}

@Override
public Node getNodeForLoosingFocus() {
return mainBox;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<?import javafx.scene.text.TextFlow?>
<?import javafx.scene.text.Text?>

<VBox xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
prefWidth="450" minWidth="450"
fx:id="mainBox">

<VBox styleClass="autogram-error-summary">
<TextFlow styleClass="autogram-error-summary__title">
<Text>Chyba komunikácie s kartou</Text>
</TextFlow>
<TextFlow styleClass="autogram-error-summary__error">
<Text>Ovládač nie je možné použiť</Text>
</TextFlow>
<TextFlow styleClass="autogram-error-summary__description,autogram-body-s">
<Text text="Nie je možné použiť ovládač pre podpisovanie vybranou kartou. Pravdepodobne je potrebné do systému nainštalovať balík "/>
<Hyperlink styleClass="autogram-body-s,autogram-link" text="Microsoft Visual C++ 2015 Redistributable" onAction="#downloadAction"/>
</TextFlow>
<TextFlow styleClass="autogram-error-summary__description,autogram-body-s">
<Text>Ak to nepomôže, kontaktujte nás na podpora@slovensko.digital</Text>
</TextFlow>
</VBox>


<HBox styleClass="autogram-actions">
<Button fx:id="mainButton" styleClass="autogram-button,autogram-button--secondary"
text="Pokračovať" onAction="#onMainButtonAction" />
</HBox>

<TextArea fx:id="errorDetails" styleClass="autogram-details__text" editable="false"
visible="false" managed="false">Error details</TextArea>
</VBox>