|
37 | 37 | * only if the new code is made subject to such option by the copyright
|
38 | 38 | * holder.
|
39 | 39 | */
|
40 |
| -// Portions Copyright [2018-2019] [Payara Foundation and/or its affiliates] |
| 40 | +// Portions Copyright [2018-2025] [Payara Foundation and/or its affiliates] |
41 | 41 |
|
42 | 42 | package com.sun.enterprise.admin.cli.cluster;
|
43 | 43 |
|
@@ -296,55 +296,58 @@ String expandPasswordAlias(String host, String alias, boolean verifyConn) {
|
296 | 296 |
|
297 | 297 | try {
|
298 | 298 | File domainsDirFile = DomainDirs.getDefaultDomainsDir();
|
299 |
| - |
300 |
| - //get the list of domains |
301 |
| - File[] files = domainsDirFile.listFiles(new FileFilter() { |
302 |
| - @Override |
303 |
| - public boolean accept(File f) { |
304 |
| - return f.isDirectory(); |
305 |
| - } |
306 |
| - }); |
307 |
| - |
308 |
| - for (File f : files) { |
309 |
| - //the following property is required for initializing the password helper |
310 |
| - System.setProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY, f.getAbsolutePath()); |
311 |
| - try { |
312 |
| - final PasswordAdapter pa = new PasswordAdapter(null); |
313 |
| - final boolean exists = pa.aliasExists(alias); |
314 |
| - if (exists) { |
315 |
| - String mPass = getMasterPassword(f.getName()); |
316 |
| - expandedPassword = new PasswordAdapter(mPass.toCharArray()).getPasswordForAlias(alias); |
317 |
| - } |
318 |
| - } catch (Exception e) { |
319 |
| - if (logger.isLoggable(Level.FINER)) { |
320 |
| - logger.finer(StringUtils.cat(": ", alias, e.getMessage())); |
| 299 | + if (domainsDirFile != null) { |
| 300 | + //get the list of domains |
| 301 | + //if(domainsDirFile != null) { |
| 302 | + File[] files = domainsDirFile.listFiles(new FileFilter() { |
| 303 | + @Override |
| 304 | + public boolean accept(File f) { |
| 305 | + return f.isDirectory(); |
321 | 306 | }
|
322 |
| - logger.warning(Strings.get("GetPasswordFailure", f.getName())); |
323 |
| - continue; |
324 |
| - } |
325 |
| - |
326 |
| - if (expandedPassword != null) { |
327 |
| - SSHLauncher sshL = new SSHLauncher(); |
328 |
| - if (host != null) { |
329 |
| - sshpassword = expandedPassword; |
330 |
| - sshL.init(getRemoteUser(), host, getRemotePort(), sshpassword, null, null, logger); |
331 |
| - connStatus = sshL.checkPasswordAuth(); |
332 |
| - if (!connStatus) { |
333 |
| - logger.warning(Strings.get("PasswordAuthFailure", f.getName())); |
334 |
| - } |
335 |
| - } else { |
336 |
| - sshkeypassphrase = expandedPassword; |
337 |
| - if (verifyConn) { |
338 |
| - sshL.init(getRemoteUser(), hosts[0], getRemotePort(), sshpassword, getSshKeyFile(), sshkeypassphrase, logger); |
339 |
| - connStatus = sshL.checkConnection(); |
340 |
| - if (!connStatus) { |
341 |
| - logger.warning(Strings.get("PasswordAuthFailure", f.getName())); |
| 307 | + }); |
| 308 | + if (files != null) { |
| 309 | + for (File f : files) { |
| 310 | + //the following property is required for initializing the password helper |
| 311 | + System.setProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY, f.getAbsolutePath()); |
| 312 | + try { |
| 313 | + final PasswordAdapter pa = new PasswordAdapter(null); |
| 314 | + final boolean exists = pa.aliasExists(alias); |
| 315 | + if (exists) { |
| 316 | + String mPass = getMasterPassword(f.getName()); |
| 317 | + expandedPassword = new PasswordAdapter(mPass.toCharArray()).getPasswordForAlias(alias); |
342 | 318 | }
|
| 319 | + } catch (Exception e) { |
| 320 | + if (logger.isLoggable(Level.FINER)) { |
| 321 | + logger.finer(StringUtils.cat(": ", alias, e.getMessage())); |
| 322 | + } |
| 323 | + logger.warning(Strings.get("GetPasswordFailure", f.getName())); |
| 324 | + continue; |
343 | 325 | }
|
344 |
| - } |
345 | 326 |
|
346 |
| - if (connStatus) { |
347 |
| - break; |
| 327 | + if (expandedPassword != null) { |
| 328 | + SSHLauncher sshL = new SSHLauncher(); |
| 329 | + if (host != null) { |
| 330 | + sshpassword = expandedPassword; |
| 331 | + sshL.init(getRemoteUser(), host, getRemotePort(), sshpassword, null, null, logger); |
| 332 | + connStatus = sshL.checkPasswordAuth(); |
| 333 | + if (!connStatus) { |
| 334 | + logger.warning(Strings.get("PasswordAuthFailure", f.getName())); |
| 335 | + } |
| 336 | + } else { |
| 337 | + sshkeypassphrase = expandedPassword; |
| 338 | + if (verifyConn) { |
| 339 | + sshL.init(getRemoteUser(), hosts[0], getRemotePort(), sshpassword, getSshKeyFile(), sshkeypassphrase, logger); |
| 340 | + connStatus = sshL.checkConnection(); |
| 341 | + if (!connStatus) { |
| 342 | + logger.warning(Strings.get("PasswordAuthFailure", f.getName())); |
| 343 | + } |
| 344 | + } |
| 345 | + } |
| 346 | + |
| 347 | + if (connStatus) { |
| 348 | + break; |
| 349 | + } |
| 350 | + } |
348 | 351 | }
|
349 | 352 | }
|
350 | 353 | }
|
|
0 commit comments