Skip to content
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 @@ -60,7 +60,7 @@ public MobileBKUConnector(@NonNull MobileBKUState state) {
private static class UserDisplayedError extends Exception {
private final @NonNull String msg;
@Override public @NonNull String getMessage() { return this.msg; }
private UserDisplayedError(@NonNull String s) { this.msg = s; }
private UserDisplayedError(@NonNull String key, Object... values) { this.msg = Messages.formatString(key, values); }
}

public @NonNull UsernameAndPassword credentials = new UsernameAndPassword();
Expand Down Expand Up @@ -123,9 +123,9 @@ public String handleSLRequest(PdfAs4SLRequest slRequest) throws SignatureExcepti

if (httpStatus != HttpStatus.SC_OK) {
switch (httpStatus) {
case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED: throw new UserDisplayedError(Messages.getString("error.ProxyAuthRequired"));
case HttpStatus.SC_REQUEST_TOO_LONG: throw new UserDisplayedError(Messages.getString("atrusterror.http_413"));
default: throw new UserDisplayedError(Messages.formatString("atrusterror.http_generic", httpStatus, Optional.ofNullable(response.getReasonPhrase()).orElse("(null)")));
case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED: throw new UserDisplayedError("error.ProxyAuthRequired");
case HttpStatus.SC_REQUEST_TOO_LONG: throw new UserDisplayedError("atrusterror.http_413");
default: throw new UserDisplayedError("atrusterror.http_generic", httpStatus, Optional.ofNullable(response.getReasonPhrase()).orElse("(null)"));
}
}

Expand All @@ -151,6 +151,10 @@ public String handleSLRequest(PdfAs4SLRequest slRequest) throws SignatureExcepti
log.debug("Failed to parse A-Trust server response as HTML:\n{}", entityBody);
throw new IOException("Failed to parse HTML");
}

if (resultDocument.selectFirst("body > *") == null) {
throw new UserDisplayedError("atrusterror.empty_document");
}

Element metaRefresh = resultDocument.selectFirst("meta[http-equiv=\"refresh\"i]");
if (metaRefresh != null) {
Expand All @@ -160,6 +164,7 @@ public String handleSLRequest(PdfAs4SLRequest slRequest) throws SignatureExcepti
continue;
}
}

return ATrustParser.Parse(resultDocument);
} else {
return ATrustParser.Parse(request.getUri(), contentType.getMimeType(), entityBody);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -523,13 +523,7 @@ public void run() {
this.signingState.bkuConnector = new MobileBKUConnector(this);
this.signingState.useBase64Request = false;

if (this.threadException != null) {
displayError(this.threadException);
return;
}

getStateMachine().display(
this.getWaitingComposite());
getStateMachine().display(this.getWaitingComposite());

this.setNextState(new SigningState(getStateMachine()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,6 @@ private OutputComposite getOutputComposite() {

@Override
public void run() {
Status status = getStateMachine().status;

if (status.signResult == null) {
ErrorDialog error = new ErrorDialog(getStateMachine().getMainShell(),
Messages.getString("error.Signatur"), BUTTONS.RETRY_CANCEL);
if(error.open() == SWT.RETRY) {
this.setNextState(new PrepareSigningState(getStateMachine()));
} else {
this.setNextState(new BKUSelectionState(getStateMachine()));
}
return;
}

OutputComposite outputComposite = this.getOutputComposite();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@

//Imports
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Objects;

import org.eclipse.swt.SWT;

import at.asit.pdfover.gui.MainWindowBehavior;
import at.asit.pdfover.commons.Messages;
import at.asit.pdfover.gui.MainWindow.Buttons;
import at.asit.pdfover.gui.MainWindowBehavior;
import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.commons.Messages;
import at.asit.pdfover.gui.workflow.StateMachine;
import at.asit.pdfover.gui.workflow.Status;
import at.asit.pdfover.signer.SignatureException;
Expand Down Expand Up @@ -57,7 +59,7 @@ public FinishSignThread(SigningState signingState) {
public void run() {
try {
Status status = this.state.getStateMachine().status;
status.signResult = PdfAs4Signer.sign(status.signingState);
status.signResult = Objects.requireNonNull(PdfAs4Signer.sign(status.signingState));
} catch(Exception e) {
this.state.threadException = e;
} finally {
Expand Down Expand Up @@ -87,14 +89,18 @@ public void run() {
}

if(this.threadException != null) {
String message = Messages.getString("error.Signatur");
String message = Messages.formatString("error.Signatur",
this.threadException.getClass().getSimpleName(),
Objects.requireNonNullElse(this.threadException.getMessage(), "(null)"));
if (this.threadException instanceof SignatureException) {
Throwable cause = this.threadException;
while (cause.getCause() != null)
cause = cause.getCause();

if (cause instanceof SocketException) {
message += ": " + cause.getMessage();
if (cause instanceof UnknownHostException) {
message = Messages.formatString("error.CouldNotResolveHostname", cause.getMessage());
} else if (cause instanceof SocketException) {
message = Messages.formatString("error.FailedToConnect", cause.getMessage());
} else if (cause instanceof SLPdfAsException) {
var ex = ((SLPdfAsException)cause);
message = Messages.formatString("error.SLError", ex.getCode(), ex.getInfo());
Expand All @@ -104,8 +110,7 @@ public void run() {
// TODO legacy hack
this.threadException = new UserCancelledException();
}
}
if (this.threadException instanceof UserCancelledException) {
} else if (this.threadException instanceof UserCancelledException) {
// don't display error, clear remembered password and go back to BKU Selection
if (this.getConfig().getRememberMobilePassword())
this.getConfig().setDefaultMobilePasswordOverlay(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ dataSourceSelection.DropLabel2=or...
dataSourceSelection.browse=&Browse for PDF on your computer
dataSourceSelection.usePlaceholderText=A marker has been found where the creator of the document wants you to put your signature. Do you want to use it?
dataSourceSelection.usePlaceholderTitle=Info
error.ATrustConnection=Connection to A-Trust could not be established
error.CouldNotResolveHostname=Could not resolve hostname '%s'.\nAre you connected to the internet?
error.CouldNotResolveHostname=Could not resolve hostname.\n%s\nAre you connected to the internet?
error.CmdLineArgs=Error parsing the command-line arguments\:
error.Details=Details
error.EnteredReferenceValue=You entered the reference value\!
Expand Down Expand Up @@ -161,7 +160,7 @@ error.PrepareDocument=Failed to prepare document for signature.
error.Retry=Retry
error.SWTLib=Error loading SWT library
error.SaveOutputFolder=Failed to save signed document to configured output folder.
error.Signatur=Signature error
error.Signatur=Signature error (%s):\%s
error.TanTooLong=Entered TAN too long
error.SLError=Operation aborted by signature server (%d):\n%s
error.Title=Error
Expand Down Expand Up @@ -269,6 +268,7 @@ config.fido2.UnsupportedPlatform=FIDO2 authentication is currently unsupported o
config.fido2.InfoURL=https://www.oesterreich.gv.at/id-austria/haeufige-fragen/allgemeines-zu-id-austria#fido
config.fido2.Group=FIDO2 settings
config.fido2.ByDefault=Select FIDO2 authentication by default
atrusterror.http_413=a-trust.at rejected request:\nProvided document exceeds size limit.
atrusterror.http_generic=a-trust.at rejected request:\nHTTP %d %s
atrusterror.message=a-trust.at reports:\n%s
atrusterror.empty_document=<A-Trust sent an empty response.>\n(The PDF document is potentially too large. (> 20 MB))
atrusterror.http_413=PDF document exceeds size limit.
atrusterror.http_generic=Signature failed (HTTP %d %s)
atrusterror.message=a-trust.at rejected request:\n%s
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,13 @@ error.PrepareDocument=Konnte Dokument nicht zur Signatur vorbereiten.
error.Retry=Wiederholen
error.SWTLib=Fehler beim Laden der SWT-Bibliothek
error.SaveOutputFolder=Konnte Dokument nicht in den konfigurierten Ausgabeordner speichern.
error.Signatur=Signatur-Fehler
error.Signatur=Signatur-Fehler (%s):\n%s
error.TanTooLong=Eingegebene TAN zu lang
error.SLError=Vorgang vom Signaturserver abgebrochen (%d):\n%s
error.Title=Fehler
error.TitleFatal=Fataler Fehler
error.Unexpected=Unerwarteter Fehler
error.ATrustConnection=Verbindung zu A-Trust konnte nicht aufgebaut werden
error.CouldNotResolveHostname=Server '%s' wurde nicht gefunden.\nÜberprüfen Sie Ihre Internetverbindung.
error.CouldNotResolveHostname=Server %s wurde nicht gefunden:\n%s\nÜberprüfen Sie Ihre Internetverbindung.
error.FailedToConnect=Verbindung zum Signaturserver fehlgeschlagen:\n%s
error.ProxyAuthRequired=HTTP-Proxy lehnt Verbindung ab:\nHTTP/1.1 407 Proxy Authentication Required
exception.InvalidEmblemFile=%s ist eine ungültige Bildmarken-Datei\!
Expand Down Expand Up @@ -266,6 +265,7 @@ config.UpdateStatus.CHECKING=Versions-Infos werden abgefragt...
config.UpdateStatus.OUTDATED=Neue Version verfügbar. <a>Herunterladen</a>?
config.UpdateStatus.UP_TO_DATE=Ihre Version ist aktuell. <a>Nochmals prüfen</a>?
config.UpdateStatus.FAILED=Versions-Check fehlgeschlagen. <a>Nochmal versuchen</a>?
atrusterror.http_413=a-trust.at lehnt Anfrage ab:\nDateigröße des PDF-Dokuments überschreitet Grenzwert.
atrusterror.http_generic=a-trust.at lehnt Anfrage ab:\nHTTP %d %s
atrusterror.message=a-trust.at meldet:\n%s
atrusterror.empty_document=<Die Antwort des A-Trust-Servers ist leer.>\n(Möglicherweise ist das ausgewählte PDF-Dokument zu groß. (> 20 MB))
atrusterror.http_413=Dateigröße des PDF-Dokuments überschreitet Grenzwert.
atrusterror.http_generic=Signatur fehlgeschlagen (HTTP %d %s)
atrusterror.message=a-trust.at lehnt Anfrage ab:\n%s
Loading