Apache

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Commons-vfs: disconnect

    1 answers - 1866 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    hello,
    i use commons-vfs for connect to a server in SSH and SFTP:
    this is my code:
    //connect to client server and return repository who contains flow
    public FileObject connect() {
    logger.debug("SSHReceiverConnect connect to : " + hostname);
    ResourceBundle myConfig = ResourceBundle.getBundle("SSHReceiver");
    String pass = (password == null ? "" : password);
    FileSystemOptions opts = new FileSystemOptions();
    try {
    SftpFileSystemConfigBuilder.getInstance().setStric tHostKeyChecking(opts, "no");
    // identities contains public Key client
    File[] identities = new File[1];
    identities[0] = new File(myConfig.getString(SSHConfigKeys.keyfile.name ()));
    SftpFileSystemConfigBuilder.getInstance().setIdent ities(opts, identities);
    StaticUserAuthenticator auth = new StaticUserAuthenticator(hostname, username, pass);
    // we stock user infos in opts
    DefaultFileSystemConfigBuilder.getInstance().setUs erAuthenticator(opts, auth);
    // create connection with client server
    // if no error we are connected to the server
    logger.info("SSHReceiverConnect connect: CONNECTED to " + hostname);
    FileSystemManager fsManager = VFS.getManager();
    // we go to the flow path
    String uriConnection = (password == null ? "sftp://" + username : "sftp://" + username + ":" + password);
    uriConnection = (port == null ? uriConnection + "@" + hostname + path : "@" + hostname + ":" + port + path);
    flowRepository = fsManager.resolveFile(uriConnection, opts);
    return flowRepository;
    } catch (FileSystemException e) {
    logger.error("SSHReceiverConnect connect: FileSystemException -> NOT CONNECTED");
    e.printStackTrace();
    return null;
    }
    }
    do you know what i have to do for disconnect?
    because i don't use session to connect!!
    thanks ;)
  • No.1 | | 23 bytes | |

    up
    thanks

Re: Commons-vfs: disconnect


max 4000 letters.
Your nickname that display:
In order to stop the spam: 5 + 4 =
QUESTION ON "Apache"

EMSDN.COM