Skip to content

Commit

Permalink
Added few finals and replaced redundant new File in SetupSshKey
Browse files Browse the repository at this point in the history
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Feb 21, 2024
1 parent 5872a8e commit bd6374a
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -66,7 +66,7 @@ protected void validate() throws CommandException {
if (sshkeyfile == null) {
// if user hasn't specified a key file and there is no key file at default
// location, then generate one
File existingKey = SSHUtil.getExistingKeyFile();
final File existingKey = SSHUtil.getExistingKeyFile();
if (existingKey == null) {
sshkeyfile = SSHUtil.getDefaultKeyFile().getAbsolutePath();
if (promptForKeyGeneration()) {
Expand All @@ -81,9 +81,9 @@ protected void validate() throws CommandException {
}
}
} else {
File keyFile = new File(sshkeyfile);
final File keyFile = new File(sshkeyfile);
promptPass = SSHUtil.validateKeyFile(keyFile);
if (SSHUtil.isEncryptedKey(new File(sshkeyfile))) {
if (SSHUtil.isEncryptedKey(keyFile)) {
sshkeypassphrase = getSSHPassphrase(false);
}
}
Expand All @@ -101,7 +101,7 @@ protected int executeCommand() throws CommandException {
String previousPassword = null;
boolean status = false;
for (String node : hosts) {
File keyFile = sshkeyfile == null ? null : new File(sshkeyfile);
final File keyFile = sshkeyfile == null ? null : new File(sshkeyfile);
sshL.init(getRemoteUser(), node, getRemotePort(), sshpassword, keyFile, sshkeypassphrase, logger);
if (generatekey || promptPass) {
//prompt for password iff required
Expand Down

0 comments on commit bd6374a

Please sign in to comment.