public HostKeyCallback create(final Controller c, final Protocol protocol) { if(Scheme.sftp.equals(protocol.getScheme())) { try { if(null == constructor) { constructor = ConstructorUtils.getMatchingAccessibleConstructor(clazz, c.getClass()); } if(null == constructor) { log.warn(String.format("No matching constructor for parameter %s", c.getClass())); // Call default constructor for disabled implementations return clazz.newInstance(); } return constructor.newInstance(c); } catch(InstantiationException | InvocationTargetException | IllegalAccessException e) { log.error(String.format("Failure loading callback class %s. %s", clazz, e.getMessage())); return new DisabledHostKeyCallback(); } } return new DisabledHostKeyCallback(); }
private <T> T connected(final Connected<T> run, final LoginCallback prompt) throws BackgroundException { new LoginConnectionService(prompt, new DisabledHostKeyCallback(), PasswordStoreFactory.get(), new DisabledProgressListener()) .check(session, PathCache.empty(), new DisabledCancelCallback()); return run.call(); }
public Credentials get() throws BackgroundException { final Host address = new HostParser(factory).get(url); final Path access = new Path(PathNormalizer.normalize(address.getDefaultPath()), EnumSet.of(Path.Type.file)); address.setDefaultPath(String.valueOf(Path.DELIMITER)); final DAVSession connection = new DAVSession(address, trust, key); connection.withListener(transcript).open(ProxyFactory.get().find(address), new DisabledHostKeyCallback(), new DisabledLoginCallback()); final InputStream in = new DAVReadFeature(connection).read(access, new TransferStatus(), new DisabledConnectionCallback()); try { final Credentials credentials = this.parse(in); connection.close(); return credentials; } finally { connection.removeListener(transcript); } }
@Override public void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException { final StorageCredentials credentials = client.getCredentials(); if(host.getCredentials().isPasswordAuthentication()) { // Update credentials ((StorageCredentialsAccountAndKey) credentials).updateKey(host.getCredentials().getPassword()); } else if(host.getCredentials().isTokenAuthentication()) { if(!StringUtils.equals(host.getCredentials().getToken(), ((StorageCredentialsSharedAccessSignature) credentials).getToken())) { this.interrupt(); this.open(proxy, new DisabledHostKeyCallback(), prompt); } } // Fetch reference for directory to check login credentials try { this.getFeature(ListService.class).list(new AzureHomeFinderService(this).find(), new DisabledListProgressListener() { @Override public void chunk(final Path parent, final AttributedList<Path> list) throws ListCanceledException { throw new ListCanceledException(list); } }); } catch(ListCanceledException e) { // Success } }