public void privateKeyPanelDidEnd_returnCode_contextInfo(NSOpenPanel sheet, final int returncode, ID contextInfo) { switch(returncode) { case SheetCallback.DEFAULT_OPTION: final NSObject selected = privateKeyOpenPanel.filenames().lastObject(); if(selected != null) { final Local key = LocalFactory.get(selected.toString()); credentials.setIdentity(key); } break; case SheetCallback.ALTERNATE_OPTION: credentials.setIdentity(null); break; } this.update(); }
if(!credentials.getIdentity().attributes().getPermission().isReadable()) { log.warn(String.format("Prompt to select identity file not readable %s", credentials.getIdentity())); credentials.setIdentity(prompt.select(credentials.getIdentity()));
@Override public void validate(final Host bookmark, final String message, final LoginCallback prompt, final LoginOptions options) throws LoginCanceledException, LoginFailureException { final Credentials credentials = bookmark.getCredentials(); if(input.hasOption(TerminalOptionsBuilder.Params.username.name())) { credentials.setUsername(input.getOptionValue(TerminalOptionsBuilder.Params.username.name())); } if(input.hasOption(TerminalOptionsBuilder.Params.password.name())) { credentials.setPassword(input.getOptionValue(TerminalOptionsBuilder.Params.password.name())); } if(input.hasOption(TerminalOptionsBuilder.Params.identity.name())) { credentials.setIdentity(LocalFactory.get(input.getOptionValue(TerminalOptionsBuilder.Params.identity.name()))); } if(StringUtils.isNotBlank(credentials.getUsername()) && StringUtils.isNotBlank(credentials.getPassword())) { return; } super.validate(bookmark, message, prompt, options); } }
log.info(String.format("Using identity %s from %s", entry, configuration)); credentials.setIdentity(entry.getIdentityFile()); log.info(String.format("Using RSA default host key %s from %s", rsa, configuration)); credentials.setIdentity(rsa); log.info(String.format("Using DSA default host key %s from %s", dsa, configuration)); credentials.setIdentity(dsa);
break; case "privatekey": current.getCredentials().setIdentity(LocalFactory.get(value)); break; case "pasvmode":
break; case "PrivateKey": current.getCredentials().setIdentity(LocalFactory.get(elementText)); break; case "FavoriteItem":
bookmark.getCredentials().setIdentity(input.getIdentity()); publickey.set(true);
final String key = this.readNext(name, reader); if(StringUtils.isNotBlank(key)) { current.getCredentials().setIdentity(LocalFactory.get(key));
@Override public Boolean authenticate(final Host bookmark, final LoginCallback callback, final CancelCallback cancel) throws BackgroundException { final Credentials credentials = bookmark.getCredentials(); if(StringUtils.isBlank(credentials.getPassword())) { final Credentials input = callback.prompt(bookmark, credentials.getUsername(), String.format("%s %s", LocaleFactory.localizedString("Login", "Login"), bookmark.getHostname()), MessageFormat.format(LocaleFactory.localizedString( "Login {0} with username and password", "Credentials"), BookmarkNameProvider.toString(bookmark)), // Change of username or service not allowed new LoginOptions(bookmark.getProtocol()).user(false)); if(input.isPublicKeyAuthentication()) { credentials.setIdentity(input.getIdentity()); return new SFTPPublicKeyAuthentication(session).authenticate(bookmark, callback, cancel); } credentials.setSaved(input.isSaved()); credentials.setPassword(input.getPassword()); } return this.authenticate(bookmark, credentials, callback, cancel); }
bookmark.getCredentials().setIdentity(LocalFactory.get(keyObjDeprecated)); bookmark.getCredentials().setIdentity(new LocalDictionary(deserializer).deserialize(keyObj));
@Action public void privateKeyPopupClicked(final NSPopUpButton sender) { final String selected = sender.selectedItem().representedObject(); if(null == selected) { privateKeyOpenPanel = NSOpenPanel.openPanel(); privateKeyOpenPanel.setCanChooseDirectories(false); privateKeyOpenPanel.setCanChooseFiles(true); privateKeyOpenPanel.setAllowsMultipleSelection(false); privateKeyOpenPanel.setMessage(LocaleFactory.localizedString("Select the private key in PEM or PuTTY format", "Credentials")); privateKeyOpenPanel.setPrompt(LocaleFactory.localizedString("Choose")); privateKeyOpenPanel.beginSheetForDirectory(LocalFactory.get(LocalFactory.get(), ".ssh").getAbsolute(), null, this.window(), this.id(), Foundation.selector("privateKeyPanelDidEnd:returnCode:contextInfo:"), null); } else { credentials.setIdentity(StringUtils.isBlank(selected) ? null : LocalFactory.get(selected)); } this.update(); }
credentials.setSaved(input.isSaved()); if(input.isPublicKeyAuthentication()) { credentials.setIdentity(input.getIdentity());
/** * Prompt for credentials if not found in keychain * * @param bookmark Host configuration * @param message Message in prompt * @param prompt Login prompt * @param options Available login options for protocol * @throws LoginCanceledException Prompt canceled by user */ public void prompt(final Host bookmark, final String message, final LoginCallback prompt, final LoginOptions options) throws LoginCanceledException { final Credentials credentials = bookmark.getCredentials(); if(options.password) { final Credentials input = prompt.prompt(bookmark, credentials.getUsername(), String.format("%s %s", LocaleFactory.localizedString("Login", "Login"), bookmark.getHostname()), message, options); credentials.setSaved(input.isSaved()); credentials.setUsername(input.getUsername()); credentials.setPassword(input.getPassword()); credentials.setIdentity(input.getIdentity()); } if(options.token) { final Credentials input = prompt.prompt(bookmark, LocaleFactory.localizedString("Provide additional login credentials", "Credentials"), message, options); credentials.setSaved(input.isSaved()); credentials.setToken(input.getPassword()); } }
@Action public void hostFieldDidChange(final NSNotification sender) { final String input = hostField.stringValue(); if(Scheme.isURL(input)) { final Host parsed = HostParser.parse(input); bookmark.setHostname(parsed.getHostname()); bookmark.setProtocol(parsed.getProtocol()); bookmark.setPort(parsed.getPort()); bookmark.setDefaultPath(parsed.getDefaultPath()); } else { bookmark.setHostname(input); final Credentials auto = CredentialsConfiguratorFactory.get(bookmark.getProtocol()).configure(bookmark); final Credentials credentials = bookmark.getCredentials(); credentials.setUsername(auto.getUsername()); credentials.setPassword(auto.getPassword()); credentials.setIdentity(auto.getIdentity()); credentials.setToken(auto.getToken()); credentials.setCertificate(auto.getCertificate()); } this.update(); }