@Test(expected = LoginCanceledException.class) public void testNoResolveForHTTPProxy() throws Exception { final Session session = new NullSession(new Host(new TestProtocol(), "unknownhost.local", new Credentials("user", ""))) { @Override public boolean isConnected() { return false; } }; final LoginConnectionService s = new LoginConnectionService(new DisabledLoginCallback(), new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener(), new DisabledProxyFinder() { @Override public Proxy find(final Host target) { return new Proxy(Proxy.Type.HTTP, "proxy.local", 6666); } }); s.check(session, PathCache.empty(), new DisabledCancelCallback()); }
@Override public boolean check(final Session<?> session, final Cache<Path> cache, final CancelCallback callback) throws BackgroundException { final Host bookmark = session.getHost(); if(bookmark.getProtocol().isHostnameConfigurable() && StringUtils.isBlank(bookmark.getHostname())) { throw new ConnectionCanceledException(); } if(session.isConnected()) { if(log.isDebugEnabled()) { log.debug(String.format("Skip opening connection for session %s", session)); } return false; } synchronized(login) { final LoginOptions options = new LoginOptions(bookmark.getProtocol()); final StringAppender message = new StringAppender(); if(options.password) { message.append(MessageFormat.format(LocaleFactory.localizedString( "Login {0} with username and password", "Credentials"), BookmarkNameProvider.toString(bookmark))); } if(options.publickey) { message.append(LocaleFactory.localizedString( "Select the private key in PEM or PuTTY format", "Credentials")); } login.validate(bookmark, message.toString(), prompt, options); } this.connect(session, cache, callback); return true; }
LoginConnectionService implements ConnectionService { @Override public boolean check(final Session<?> session, final Cache<Path> cache, final CancelCallback callback) throws BackgroundException { final Host bookmark = session.getHost(); if(bookmark.getProtocol().isHostnameConfigurable() && StringUtils.isBlank(bookmark.getHostname())) { throw new ConnectionCanceledException(); } if(session.isConnected()) { if(log.isDebugEnabled()) { log.debug(String.format("Skip opening connection for session %s", session)); } return false; } synchronized(login) { final LoginOptions options = new LoginOptions(bookmark.getProtocol()); final StringAppender message = new StringAppender(); if(options.password) { message.append(MessageFormat.format(LocaleFactory.localizedString( "Login {0} with username and password", "Credentials"), BookmarkNameProvider.toString(bookmark))); } if(options.publickey) { message.append(LocaleFactory.localizedString( "Select the private key in PEM or PuTTY format", "Credentials")); } login.validate(bookmark, message.toString(), prompt, options); } this.connect(session, cache, callback); return true; } }
LoginConnectionService implements ConnectionService { @Override public boolean check(final Session<?> session, final Cache<Path> cache, final CancelCallback callback) throws BackgroundException { final Host bookmark = session.getHost(); if(bookmark.getProtocol().isHostnameConfigurable() && StringUtils.isBlank(bookmark.getHostname())) { throw new ConnectionCanceledException(); } if(session.isConnected()) { if(log.isDebugEnabled()) { log.debug(String.format("Skip opening connection for session %s", session)); } return false; } synchronized(login) { final LoginOptions options = new LoginOptions(bookmark.getProtocol()); final StringAppender message = new StringAppender(); if(options.password) { message.append(MessageFormat.format(LocaleFactory.localizedString( "Login {0} with username and password", "Credentials"), BookmarkNameProvider.toString(bookmark))); } if(options.publickey) { message.append(LocaleFactory.localizedString( "Select the private key in PEM or PuTTY format", "Credentials")); } login.validate(bookmark, message.toString(), prompt, options); } this.connect(session, cache, callback); return true; } LoginConnectionService(final LoginCallback prompt,
                                  final HostKeyCallback key,
                                  final HostPasswordStore keychain,
                                  final ProgressListener listener);  LoginConnectionService(final LoginCallback prompt,
                                  final HostKeyCallback key,
                                  final HostPasswordStore keychain,
                                  final ProgressListener listener,
                                  final ProxyFinder proxy);  LoginConnectionService(final LoginService login,
                                  final LoginCallback prompt,
                                  final HostKeyCallback key,
                                  final ProgressListener listener);  LoginConnectionService(final LoginService login,
                                  final LoginCallback prompt,
                                  final HostKeyCallback key,
                                  final ProgressListener listener,
                                  final ProxyFinder proxy); }
LoginConnectionService implements ConnectionService { @Override public boolean check(final Session<?> session, final Cache<Path> cache, final CancelCallback callback) throws BackgroundException { final Host bookmark = session.getHost(); if(bookmark.getProtocol().isHostnameConfigurable() && StringUtils.isBlank(bookmark.getHostname())) { throw new ConnectionCanceledException(); } if(session.isConnected()) { if(log.isDebugEnabled()) { log.debug(String.format("Skip opening connection for session %s", session)); } return false; } synchronized(login) { final LoginOptions options = new LoginOptions(bookmark.getProtocol()); final StringAppender message = new StringAppender(); if(options.password) { message.append(MessageFormat.format(LocaleFactory.localizedString( "Login {0} with username and password", "Credentials"), BookmarkNameProvider.toString(bookmark))); } if(options.publickey) { message.append(LocaleFactory.localizedString( "Select the private key in PEM or PuTTY format", "Credentials")); } login.validate(bookmark, message.toString(), prompt, options); } this.connect(session, cache, callback); return true; } LoginConnectionService(final LoginCallback prompt,
                                  final HostKeyCallback key,
                                  final HostPasswordStore keychain,
                                  final ProgressListener listener);  LoginConnectionService(final LoginCallback prompt,
                                  final HostKeyCallback key,
                                  final HostPasswordStore keychain,
                                  final ProgressListener listener,
                                  final ProxyFinder proxy);  LoginConnectionService(final LoginService login,
                                  final LoginCallback prompt,
                                  final HostKeyCallback key,
                                  final ProgressListener listener);  LoginConnectionService(final LoginService login,
                                  final LoginCallback prompt,
                                  final HostKeyCallback key,
                                  final ProgressListener listener,
                                  final ProxyFinder proxy); @Override boolean check(final Session<?> session, final Cache<Path> cache, final CancelCallback callback); @Override void close(final Session<?> session); @Override void connect(final Session<?> session, final Cache<Path> cache, final CancelCallback callback); }
LoginConnectionService implements ConnectionService { @Override public boolean check(final Session<?> session, final Cache<Path> cache, final CancelCallback callback) throws BackgroundException { final Host bookmark = session.getHost(); if(bookmark.getProtocol().isHostnameConfigurable() && StringUtils.isBlank(bookmark.getHostname())) { throw new ConnectionCanceledException(); } if(session.isConnected()) { if(log.isDebugEnabled()) { log.debug(String.format("Skip opening connection for session %s", session)); } return false; } synchronized(login) { final LoginOptions options = new LoginOptions(bookmark.getProtocol()); final StringAppender message = new StringAppender(); if(options.password) { message.append(MessageFormat.format(LocaleFactory.localizedString( "Login {0} with username and password", "Credentials"), BookmarkNameProvider.toString(bookmark))); } if(options.publickey) { message.append(LocaleFactory.localizedString( "Select the private key in PEM or PuTTY format", "Credentials")); } login.validate(bookmark, message.toString(), prompt, options); } this.connect(session, cache, callback); return true; } LoginConnectionService(final LoginCallback prompt,
                                  final HostKeyCallback key,
                                  final HostPasswordStore keychain,
                                  final ProgressListener listener);  LoginConnectionService(final LoginCallback prompt,
                                  final HostKeyCallback key,
                                  final HostPasswordStore keychain,
                                  final ProgressListener listener,
                                  final ProxyFinder proxy);  LoginConnectionService(final LoginService login,
                                  final LoginCallback prompt,
                                  final HostKeyCallback key,
                                  final ProgressListener listener);  LoginConnectionService(final LoginService login,
                                  final LoginCallback prompt,
                                  final HostKeyCallback key,
                                  final ProgressListener listener,
                                  final ProxyFinder proxy); @Override boolean check(final Session<?> session, final Cache<Path> cache, final CancelCallback callback); @Override void close(final Session<?> session); @Override void connect(final Session<?> session, final Cache<Path> cache, final CancelCallback callback);  }