Secure iNet Factory

com.jscape.inet.nntpssh
Class NntpSsh

java.lang.Object
  extended by com.jscape.inet.nntp.Nntp
      extended by com.jscape.inet.nntpssh.NntpSsh
All Implemented Interfaces:
java.io.Serializable

public class NntpSsh
extends Nntp

Implements the basic functionality of a NNTP client tunnelling data through a secure SSH connection.

Example Usage:

 //
 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:
Serialized Form

Field Summary
 
Fields inherited from class com.jscape.inet.nntp.Nntp
CMD_ARTICLE, CMD_AUTHPASS, CMD_AUTHUSER, CMD_BODY, CMD_GROUP, CMD_HEAD, CMD_HELP, CMD_LAST, CMD_LIST, CMD_NEWGROUPS, CMD_NEWNEWS, CMD_NEXT, CMD_POST, CMD_QUIT, CMD_STAT, MODE, RESPONSE_ARTICLE_LIST_BY_MESSAGE_ID_FOLLOWS, RESPONSE_ARTICLE_NOT_WANTED, RESPONSE_ARTICLE_POSTED_OK, RESPONSE_ARTICLE_REJECTED, RESPONSE_ARTICLE_RETRIEVED_BODY_FOLLOWS, RESPONSE_ARTICLE_RETRIEVED_HEAD_AND_BODY_FOLLOW, RESPONSE_ARTICLE_RETRIEVED_HEAD_FOLLOWS, RESPONSE_ARTICLE_RETRIEVED_REQUEST_TEXT_SEPARATELY, RESPONSE_ARTICLE_TRANSFERRED_OK, RESPONSE_AUTH_FAILED, RESPONSE_AUTH_FAILED_OLD, RESPONSE_AUTH_FAILED_OLD2, RESPONSE_AUTH_OK, RESPONSE_AUTH_OK_OLD, RESPONSE_CLOSING_CONNECTION, RESPONSE_COMMAND_NOT_RECOGNIZED, RESPONSE_COMMAND_SYNTAX_ERROR, RESPONSE_CONTINUE_AUTH, RESPONSE_DEBUG, RESPONSE_GROUP_SELECTED, RESPONSE_HELP, RESPONSE_NEW_NEWSGROUP_LIST_FOLLOWS, RESPONSE_NO_CURRENT_ARTICLE_SELECTED, RESPONSE_NO_NEWSGROUP_SELECTED, RESPONSE_NO_NEXT_ARTICLE, RESPONSE_NO_PREVIOUS_ARTICLE, RESPONSE_NO_SUCH_ARTICLE_FOUND, RESPONSE_NO_SUCH_ARTICLE_NUMBER, RESPONSE_NO_SUCH_NEWSGROUP, RESPONSE_OK_POSTING_ALLOWED, RESPONSE_OK_POSTING_NOT_ALLOWED, RESPONSE_PERMISSION_DENIED, RESPONSE_POSTING_FAILED, RESPONSE_POSTING_NOT_ALLOWED, RESPONSE_POSTING_REJECTED, RESPONSE_POSTING_REJECTED_OLD, RESPONSE_PROGRAM_FAULT, RESPONSE_SEND_ARTICLE_TO_POST, RESPONSE_SEND_ARTICLE_TO_TRANSFER, RESPONSE_SERVICE_DISCONTINUED, RESPONSE_SLAVE_NOTED, RESPONSE_TRANSFER_FAILED, SCMD_IHAVE, SCMD_SLAVE, XOVER
 
Constructor Summary
NntpSsh()
          Creates a new NntpSsh instance.
NntpSsh(SshParameters sshParameters, java.lang.String hostname)
          Creates a new NntpSsh instance.
 
Method Summary
 void connect()
          Connects to NNTP server tunnelling all data through SSH server.
 void disconnect()
          Disconnects from NNTP server and closes tunnel with SSH server.
 SshParameters getSshParameters()
          Gets SSH parameters used in establishing connection with SSH server.
 void setSshParameters(SshParameters parameters)
          Sets SSH parameters used in establishing connection with SSH server.
 
Methods inherited from class com.jscape.inet.nntp.Nntp
addNntpListener, clearProxySettings, getArticle, getArticle, getArticleHeader, getArticleHeaders, getArticleHeaders, getArticleHeaders, getArticleHeaders, getArticleHeaders, getCurrentNewsgroup, getDebug, getDebugStream, getHostname, getNewsgroup, getNewsgroups, getNewsgroups, getNextArticle, getNextHeader, getPort, getPreviousArticle, getPreviousHeader, getProxyHost, getProxyPort, getResponseString, getResponseStrings, getTimeout, getUsername, issueCommand, postArticle, removeNntpListener, setDebug, setDebugStream, setHostname, setNewsgroup, setNewsgroup, setPassword, setPort, setProxyAuthentication, setProxyHost, setProxyHost, setProxyPort, setProxyType, setTimeout, setUsername
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NntpSsh

public NntpSsh()
Creates a new NntpSsh instance.


NntpSsh

public NntpSsh(SshParameters sshParameters,
               java.lang.String hostname)
Creates a new NntpSsh instance.

Parameters:
sshParameters - the SSH parameters used in establishing a secure connection
hostname - the hostname of NNTP server
Method Detail

connect

public void connect()
             throws NntpException
Connects to NNTP server tunnelling all data through SSH server.

Overrides:
connect in class Nntp
Throws:
NntpException - if I/O or NNTP related error occurs

disconnect

public void disconnect()
Disconnects from NNTP server and closes tunnel with SSH server.

Overrides:
disconnect in class Nntp

getSshParameters

public SshParameters getSshParameters()
Gets SSH parameters used in establishing connection with SSH server.

Returns:
the SSH parameters
See Also:
SshParameters

setSshParameters

public void setSshParameters(SshParameters parameters)
Sets SSH parameters used in establishing connection with SSH server.

Parameters:
parameters - the SSH parameters
See Also:
SshParameters

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved