@Override public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) throws LoginCanceledException { throw new LoginCanceledException(); } }
throw new MalformedChallengeException(ignored.getMessage(), ignored);
public SFTPEngine sftp() throws LoginCanceledException { if(null == sftp) { throw new LoginCanceledException(); } return sftp; }
@Override public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) throws LoginCanceledException { throw new LoginCanceledException(); } }
@Override public Credentials prompt(final Host bookmark, final String username, final String title, final String reason, final LoginOptions options) throws LoginCanceledException { throw new LoginCanceledException(); }
@Override public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) throws LoginCanceledException { throw new LoginCanceledException(); } }
@Override public void warn(final Host bookmark, final String title, final String message, final String continueButton, final String disconnectButton, final String preference) throws LoginCanceledException { throw new LoginCanceledException(); }
@Override public Local select(final Local identity) throws LoginCanceledException { throw new LoginCanceledException(); }
public char[] readPassword(String format, Object... args) throws ConnectionCanceledException { if(console != null) { return this.wrap(console.readPassword(format, args)); } final String line = this.readLine(format, args); if(StringUtils.isBlank(line)) { throw new LoginCanceledException(); } return line.toCharArray(); }
@Override public void warn(final Host bookmark, final String title, final String reason, final String defaultButton, final String cancelButton, final String preference) throws ConnectionCanceledException { console.printf("%n%s", reason); if(!prompt.prompt(String.format("%s (y) or %s (n): ", defaultButton, cancelButton))) { // Switch protocol throw new LoginCanceledException(); } }
@Override public Credentials prompt(final Host bookmark, final String username, final String title, final String reason, final LoginOptions options) throws LoginCanceledException { if(log.isDebugEnabled()) { log.debug(String.format("Prompt for credentials for %s", username)); } final Credentials credentials = new Credentials(username).withSaved(options.save); final LoginController controller = new LoginController(title, reason, bookmark, credentials, options); final SheetInvoker sheet = new SheetInvoker(controller, parent, controller); final int option = sheet.beginSheet(); if(option == SheetCallback.CANCEL_OPTION) { throw new LoginCanceledException(); } return credentials; }
@Override public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) throws LoginCanceledException { if(suppressed) { throw new LoginCanceledException(); } final Credentials credentials = new Credentials().withSaved(options.save); final PasswordController controller = new PasswordController(bookmark, credentials, title, reason, options); final int option = controller.beginSheet(parent); if(option == SheetCallback.CANCEL_OPTION) { if(controller.isSuppressed()) { suppressed = true; } throw new LoginCanceledException(); } return credentials; } }
@Override public void warn(final Host bookmark, final String title, final String message, final String continueButton, final String disconnectButton, final String preference) throws LoginCanceledException { if(log.isDebugEnabled()) { log.debug(String.format("Display insecure connection alert for %s", bookmark)); } final AlertController alert = new InsecureLoginAlertController(title, message, continueButton, disconnectButton, bookmark.getProtocol()); int option = alert.beginSheet(parent); if(alert.isSuppressed()) { // Never show again. preferences.setProperty(preference, true); } switch(option) { case SheetCallback.CANCEL_OPTION: throw new LoginCanceledException(); } // Proceed nevertheless. }
@Override public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) throws LoginCanceledException { console.printf("%n%s", new StringAppender().append(title).append(reason)); try { final char[] input = console.readPassword("%n%s: ", options.getPasswordPlaceholder()); final Credentials credentials = new Credentials(); credentials.setPassword(String.valueOf(input)); return this.prompt(options, credentials); } catch(ConnectionCanceledException e) { throw new LoginCanceledException(e); } }
public Local select(final Local identity) throws LoginCanceledException { final SheetInvoker sheet = new SheetInvoker(new DisabledSheetCallback(), parent, select) { @Override public int beginSheet(final NSWindow window) { select = NSOpenPanel.openPanel(); select.setCanChooseDirectories(false); select.setCanChooseFiles(true); select.setAllowsMultipleSelection(false); select.setMessage(LocaleFactory.localizedString("Select the private key in PEM or PuTTY format", "Credentials")); select.setPrompt(LocaleFactory.localizedString("Choose")); select.beginSheetForDirectory(LocalFactory.get("~/.ssh").getAbsolute(), null, parent.window(), this.id(), Foundation.selector("sheetDidClose:returnCode:contextInfo:"), null); return this.getSelectedOption(); } }; final int option = sheet.beginSheet(); if(option == SheetCallback.DEFAULT_OPTION) { final NSObject selected = select.filenames().lastObject(); if(selected != null) { return LocalFactory.get(selected.toString()); } } throw new LoginCanceledException(); } }
throw new LoginCanceledException();
private String computeFingerprint(final FileKeyProvider provider) throws BackgroundException { try { return new SSHFingerprintGenerator().fingerprint(provider.getPublic()); } catch(PasswordException e) { throw new LoginCanceledException(e); } catch(EncryptionException e) { final StringAppender appender = new StringAppender(); appender.append(StringUtils.capitalize(e.getMessage())); throw new LoginFailureException(appender.toString(), e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } }
throw new LoginCanceledException();
private Credentials unlock(final PasswordCallback callback, final Host bookmark, final UserKeyPair keypair, String passphrase, final String message) throws LoginCanceledException, CryptoException { final Credentials credentials; if(null == passphrase) { credentials = callback.prompt(bookmark, LocaleFactory.localizedString("Decryption password required", "SDS"), message, new LoginOptions() .icon(bookmark.getProtocol().disk()) ); if(credentials.getPassword() == null) { throw new LoginCanceledException(); } } else { credentials = new VaultCredentials(passphrase).withSaved(true); } if(!Crypto.checkUserKeyPair(keypair, credentials.getPassword())) { return this.unlock(callback, bookmark, keypair, null, String.format("%s. %s", LocaleFactory.localizedString("Invalid passphrase", "Credentials"), LocaleFactory.localizedString("Enter your decryption password to access encrypted data rooms.", "SDS"))); } else { if(credentials.isSaved()) { if(log.isInfoEnabled()) { log.info(String.format("Save encryption password for %s", bookmark)); } keychain.addPassword(String.format("Triple-Crypt Encryption Password (%s)", bookmark.getCredentials().getUsername()), new DefaultUrlProvider(bookmark).toUrl(new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory))).find(DescriptiveUrl.Type.provider).getUrl(), credentials.getPassword()); } return credentials; } } }
@Override public Credentials prompt(final Host bookmark, final String username, final String title, final String reason, final LoginOptions options) throws LoginCanceledException { console.printf("%n%s", new StringAppender().append(title).append(reason)); try { final Credentials credentials = new Credentials(username); if(options.user) { if(StringUtils.isBlank(credentials.getUsername())) { final String user = console.readLine("%n%s: ", options.getUsernamePlaceholder()); credentials.setUsername(user); } else { final String user = console.readLine("%n%s (%s): ", options.getUsernamePlaceholder(), credentials.getUsername()); if(StringUtils.isNotBlank(user)) { credentials.setUsername(user); } } console.printf("Login as %s", credentials.getUsername()); } if(options.password) { final char[] input = console.readPassword("%n%s: ", options.getPasswordPlaceholder()); credentials.setPassword(String.valueOf(input)); Arrays.fill(input, ' '); } return this.prompt(options, credentials); } catch(ConnectionCanceledException e) { throw new LoginCanceledException(e); } }