@Test public void testGetKeyFile() { final String myPrivateKeyFileName = "myPrivateKeyFile"; final String myPrivateKeyPassPhraseName = "myPrivateKeyPassPhrase"; final String myPrivatePassword = "myPrivatePassword"; IdentityKey keyFile = IdentityKeyUtils.getIdentityKey(myPrivateKeyFileName, null, myPrivatePassword); assert(keyFile instanceof KeyFile); assertEquals(myPrivatePassword, new String(keyFile.getPassPhrase(), StandardCharsets.UTF_8)); assertEquals(myPrivateKeyFileName, ((KeyFile) keyFile).getKeyFilePath()); keyFile = IdentityKeyUtils.getIdentityKey(null, myPrivateKeyPassPhraseName, myPrivatePassword); assert(keyFile instanceof KeyData); assertEquals(myPrivatePassword, new String(keyFile.getPassPhrase(), StandardCharsets.UTF_8)); assertEquals(myPrivatePassword, new String(keyFile.getPassPhrase(), StandardCharsets.UTF_8)); keyFile = IdentityKeyUtils.getIdentityKey(null, null, myPrivatePassword); assertNull(keyFile); }
protected KeyFile getKeyFile(String privateKeyFile, String privateKeyPassPhrase) { KeyFile keyFile = null; if (privateKeyFile != null && !privateKeyFile.isEmpty()) { if (privateKeyPassPhrase != null && !privateKeyPassPhrase.isEmpty()) { keyFile = new KeyFile(privateKeyFile, privateKeyPassPhrase); } else { keyFile = new KeyFile(privateKeyFile); } } return keyFile; }
SSHShellAbstract { protected KeyFile getKeyFile(String privateKeyFile, String privateKeyPassPhrase) { KeyFile keyFile = null; if (privateKeyFile != null && !privateKeyFile.isEmpty()) { if (privateKeyPassPhrase != null && !privateKeyPassPhrase.isEmpty()) { keyFile = new KeyFile(privateKeyFile, privateKeyPassPhrase); } else { keyFile = new KeyFile(privateKeyFile); } } return keyFile; } }
SSHShellAbstract { protected KeyFile getKeyFile(String privateKeyFile, String privateKeyPassPhrase) { KeyFile keyFile = null; if (privateKeyFile != null && !privateKeyFile.isEmpty()) { if (privateKeyPassPhrase != null && !privateKeyPassPhrase.isEmpty()) { keyFile = new KeyFile(privateKeyFile, privateKeyPassPhrase); } else { keyFile = new KeyFile(privateKeyFile); } } return keyFile; }  }
SSHShellAbstract { protected KeyFile getKeyFile(String privateKeyFile, String privateKeyPassPhrase) { KeyFile keyFile = null; if (privateKeyFile != null && !privateKeyFile.isEmpty()) { if (privateKeyPassPhrase != null && !privateKeyPassPhrase.isEmpty()) { keyFile = new KeyFile(privateKeyFile, privateKeyPassPhrase); } else { keyFile = new KeyFile(privateKeyFile); } } return keyFile; }   }
SSHShellAbstract { protected KeyFile getKeyFile(String privateKeyFile, String privateKeyPassPhrase) { KeyFile keyFile = null; if (privateKeyFile != null && !privateKeyFile.isEmpty()) { if (privateKeyPassPhrase != null && !privateKeyPassPhrase.isEmpty()) { keyFile = new KeyFile(privateKeyFile, privateKeyPassPhrase); } else { keyFile = new KeyFile(privateKeyFile); } } return keyFile; }   static final String COMMAND_IS_NOT_SPECIFIED_MESSAGE; }