(Client client, CommandLine commands,
LinkedList<String> arguments, PrintStream out)
| 514 | } |
| 515 | |
| 516 | public int doPull(Client client, CommandLine commands, |
| 517 | LinkedList<String> arguments, PrintStream out) { |
| 518 | |
| 519 | if (arguments.size() < 1) { |
| 520 | printPullUsage(); |
| 521 | return 127; // "command not found" |
| 522 | } |
| 523 | |
| 524 | // decryption option |
| 525 | String id = commands.getOptionValue("d"); |
| 526 | PrivateKey[] decryptionKeys = null; |
| 527 | |
| 528 | if (id != null) { |
| 529 | // obtain password |
| 530 | id = Common.toFeedIdString(id); |
| 531 | char[] password = null; |
| 532 | String pass = commands.getOptionValue("p"); |
| 533 | if (pass != null) { |
| 534 | password = pass.toCharArray(); |
| 535 | } else { |
| 536 | try { |
| 537 | Console console = System.console(); |
| 538 | if (console != null) { |
| 539 | password = console.readPassword("Password: "); |
| 540 | } else { |
| 541 | log.info("No console detected for password input."); |
| 542 | } |
| 543 | } catch (Throwable t) { |
| 544 | log.error("Unexpected error while reading password", t); |
| 545 | } |
| 546 | } |
| 547 | if (password == null) { |
| 548 | log.error("Password is required to decrypt."); |
| 549 | return 127; // "command not found" |
| 550 | } |
| 551 | if (password.length < 6) { |
| 552 | System.err |
| 553 | .println("Password must be at least six characters in length."); |
| 554 | return 127; // "command not found" |
| 555 | } |
| 556 | |
| 557 | // obtain keys |
| 558 | KeyPair signingKeys = null; |
| 559 | KeyPair encryptionKeys = null; |
| 560 | String keyPath = commands.getOptionValue("k"); |
| 561 | |
| 562 | File keyFile; |
| 563 | if (keyPath != null) { |
| 564 | keyFile = new File(keyPath, id + Common.KEY_EXTENSION); |
| 565 | } else { |
| 566 | keyFile = new File(Common.getClientRoot(), id |
| 567 | + Common.KEY_EXTENSION); |
| 568 | } |
| 569 | |
| 570 | if (keyFile.exists()) { |
| 571 | System.err.println("Using existing account id: " + id); |
| 572 | |
| 573 | } else { |
no test coverage detected