From bea300424951e64e79cad78872d3afe9a14d6e91 Mon Sep 17 00:00:00 2001 From: Florian Seligmann Date: Mon, 23 Sep 2024 10:45:16 +0200 Subject: [PATCH] simplify method --- .../grading/git/SSHCloningStrategy.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/git/SSHCloningStrategy.java b/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/git/SSHCloningStrategy.java index b696372..82a9aac 100644 --- a/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/git/SSHCloningStrategy.java +++ b/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/git/SSHCloningStrategy.java @@ -132,17 +132,7 @@ public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCreden } } else if (item instanceof CredentialItem.Password passwordItem) { if (this.passphrase == null) { - try { - SwingUtilities.invokeAndWait(() -> { - this.passphrase = PasswordPanel.show("Clone via SSH", passwordItem.getPromptText()) - .orElse(null); - }); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } + this.askForPassword(passwordItem); } if (this.passphrase != null) { @@ -154,5 +144,19 @@ public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCreden } return true; } + + private void askForPassword(CredentialItem.Password passwordItem) { + try { + SwingUtilities.invokeAndWait(() -> { + this.passphrase = PasswordPanel.show("Clone via SSH", passwordItem.getPromptText()) + .orElse(null); + }); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } + } } }