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); + } + } } }