Skip to content

Commit

Permalink
Merge pull request #382 from slovensko-digital/AG-117/windows-eidpkcs…
Browse files Browse the repository at this point in the history
…-cannot-initialize-message

Add custom error info on Windows eID PKCS missing dll dependecies
  • Loading branch information
celuchmarek authored Jan 24, 2024
2 parents 49b7780 + 80d1f7a commit f7f2407
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 1 deletion.
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 [email protected]", 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 [email protected]</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>

0 comments on commit f7f2407

Please sign in to comment.