public SFTPEngine(SessionFactory ssh, String pathSep) throws SSHException { Session session = ssh.startSession(); loggerFactory = session.getLoggerFactory(); log = loggerFactory.getLogger(getClass()); sub = session.startSubsystem("sftp"); out = sub.getOutputStream(); reader = new PacketReader(this); pathHelper = new PathHelper(new PathHelper.Canonicalizer() { @Override public String canonicalize(String path) throws IOException { return SFTPEngine.this.canonicalize(path); } }, pathSep); }
@Before public void setPathHelper() throws Exception { PathHelper helper = new PathHelper(new PathHelper.Canonicalizer() { /** * Very basic, it does not try to canonicalize relative bits in the middle of a path. */ @Override public String canonicalize(String path) throws IOException { if ("".equals(path) || ".".equals(path) || "./".equals(path)) return "/home/me"; if ("..".equals(path) || "../".equals(path)) return "/home"; return path; } }, DEFAULT_PATH_SEPARATOR); when(sftpEngine.getPathHelper()).thenReturn(helper); when(sftpEngine.stat("/")).thenReturn(new FileAttributes.Builder().withType(FileMode.Type.DIRECTORY).build()); when(sftpEngine.getLoggerFactory()).thenReturn(LoggerFactory.DEFAULT); }
public SFTPEngine(SessionFactory ssh, String pathSep) throws SSHException { sub = ssh.startSession().startSubsystem("sftp"); out = sub.getOutputStream(); reader = new PacketReader(this); pathHelper = new PathHelper(new PathHelper.Canonicalizer() { @Override public String canonicalize(String path) throws IOException { return SFTPEngine.this.canonicalize(path); } }, pathSep); }
public SFTPEngine(SessionFactory ssh, String pathSep) throws SSHException { Session session = ssh.startSession(); loggerFactory = session.getLoggerFactory(); log = loggerFactory.getLogger(getClass()); sub = session.startSubsystem("sftp"); out = sub.getOutputStream(); reader = new PacketReader(this); pathHelper = new PathHelper(new PathHelper.Canonicalizer() { @Override public String canonicalize(String path) throws IOException { return SFTPEngine.this.canonicalize(path); } }, pathSep); }