Using the NntpSsh class |
The NntpSsh class is a subclass of the com.jscape.inet.nntp.Nntp class. It provides access to all the same features as the Nntp class with the exception that all data is securely tunneled thru an SSH server. To use the NntpSsh class create a new NntpSsh instance providing a com.jscape.inet.ssh.util.SshParameters instance as an argument to the constructor.
Example
// SSH connection parameters String sshHostname = "news.myserver.com"; String sshUsername = "jsmith"; String sshPassword = "secret";
// create new SshParameters instance SshParameters sshParams = new SshParameters(sshHostname,sshUsername,sshPassword);
// create new NntpSsh instance NntpSsh nntp = new NntpSsh(sshParams,"news.myserver.com");
// establish connection and read headers try { nntp.connect(); nntp.setNewsgroup("comp.lang.java.programmer"); // get all headers and print out subject Enumeration headers = nntp.getArticleHeaders(); while(headers.hasMoreElements()) { NntpArticleHeader header = (NntpArticleHeader)headers.nextElement(); System.out.println(header.getSubject()); } // disconnect nntp.disconnect(); } catch(Exception e) { System.out.println(e); }
See also
|