Author: gnodet
Date: Fri Dec  5 04:17:04 2008
New Revision: 723720

URL: http://svn.apache.org/viewvc?rev=723720&view=rev
Log:
Add some javadocs

Modified:
    mina/sshd/trunk/pom.xml
    mina/sshd/trunk/src/main/java/org/apache/sshd/ClientChannel.java
    mina/sshd/trunk/src/main/java/org/apache/sshd/ClientSession.java
    mina/sshd/trunk/src/main/java/org/apache/sshd/SshClient.java
    mina/sshd/trunk/src/main/java/org/apache/sshd/SshServer.java
    
mina/sshd/trunk/src/main/java/org/apache/sshd/common/session/AbstractSession.java
    mina/sshd/trunk/src/main/java/org/apache/sshd/server/UserAuth.java
    
mina/sshd/trunk/src/main/java/org/apache/sshd/server/pam/PAMPasswordAuthenticator.java
    
mina/sshd/trunk/src/main/java/org/apache/sshd/server/session/ServerSession.java

Modified: mina/sshd/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/mina/sshd/trunk/pom.xml?rev=723720&r1=723719&r2=723720&view=diff
==============================================================================
--- mina/sshd/trunk/pom.xml (original)
+++ mina/sshd/trunk/pom.xml Fri Dec  5 04:17:04 2008
@@ -45,11 +45,11 @@
 
     <mailingLists>
       <mailingList>
-        <name>FtpServer Users mailing list</name>
-        <subscribe>[EMAIL PROTECTED]</subscribe>
-        <unsubscribe>[EMAIL PROTECTED]</unsubscribe>
-        <post>[EMAIL PROTECTED]</post>
-        
<archive>http://mail-archives.apache.org/mod_mbox/mina-ftpserver-users/</archive>
+        <name>Users mailing list</name>
+        <subscribe>[EMAIL PROTECTED]</subscribe>
+        <unsubscribe>[EMAIL PROTECTED]</unsubscribe>
+        <post>[EMAIL PROTECTED]</post>
+        <archive>http://mail-archives.apache.org/mod_mbox/mina-users/</archive>
       </mailingList>
       <mailingList>
         <name>MINA Development mailing list</name>

Modified: mina/sshd/trunk/src/main/java/org/apache/sshd/ClientChannel.java
URL: 
http://svn.apache.org/viewvc/mina/sshd/trunk/src/main/java/org/apache/sshd/ClientChannel.java?rev=723720&r1=723719&r2=723720&view=diff
==============================================================================
--- mina/sshd/trunk/src/main/java/org/apache/sshd/ClientChannel.java (original)
+++ mina/sshd/trunk/src/main/java/org/apache/sshd/ClientChannel.java Fri Dec  5 
04:17:04 2008
@@ -23,7 +23,9 @@
 import java.io.InputStream;
 
 /**
- * TODO Add javadoc
+ * A client channel used to communicate with
+ * the SSH server.  Client cannels can be shells,
+ * simple commands or subsystems
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Apache MINA SSHD Project</a>
  * @version $Rev$, $Date$

Modified: mina/sshd/trunk/src/main/java/org/apache/sshd/ClientSession.java
URL: 
http://svn.apache.org/viewvc/mina/sshd/trunk/src/main/java/org/apache/sshd/ClientSession.java?rev=723720&r1=723719&r2=723720&view=diff
==============================================================================
--- mina/sshd/trunk/src/main/java/org/apache/sshd/ClientSession.java (original)
+++ mina/sshd/trunk/src/main/java/org/apache/sshd/ClientSession.java Fri Dec  5 
04:17:04 2008
@@ -23,7 +23,23 @@
 import java.io.IOException;
 
 /**
- * TODO Add javadoc
+ * An authenticated session to a given SSH server
+ *
+ * A client session is established using the [EMAIL PROTECTED] SshClient}.
+ * Once the session has been created, the user has to authenticate
+ * using either [EMAIL PROTECTED] #authPassword(String, String)} or
+ * [EMAIL PROTECTED] #authPublicKey(String, java.security.PublicKey)}.
+ *
+ * From this session, channels can be created using the
+ * [EMAIL PROTECTED] #createChannel(String)} method.  Multiple channels can
+ * be created on a given session concurrently.
+ *
+ * When using the client in an interactive mode, the
+ * [EMAIL PROTECTED] #waitFor(int, long)} method can be used to listen to 
specific
+ * events such as the session being established, authenticated or closed.
+ *
+ * When a given session is no longer used, it must be closed using the
+ * [EMAIL PROTECTED] #close()} method.
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Apache MINA SSHD Project</a>
  * @version $Rev$, $Date$

Modified: mina/sshd/trunk/src/main/java/org/apache/sshd/SshClient.java
URL: 
http://svn.apache.org/viewvc/mina/sshd/trunk/src/main/java/org/apache/sshd/SshClient.java?rev=723720&r1=723719&r2=723720&view=diff
==============================================================================
--- mina/sshd/trunk/src/main/java/org/apache/sshd/SshClient.java (original)
+++ mina/sshd/trunk/src/main/java/org/apache/sshd/SshClient.java Fri Dec  5 
04:17:04 2008
@@ -66,7 +66,48 @@
 import org.apache.mina.transport.socket.nio.SocketConnector;
 
 /**
- * TODO Add javadoc
+ * Entry point for the client side of the SSH protocol.
+ *
+ * The default configured client can be created using
+ * the [EMAIL PROTECTED] #setUpDefaultClient()}.  The next step is to
+ * start the client using the [EMAIL PROTECTED] #start()} method.
+ *
+ * Sessions can then be created using on of the
+ * [EMAIL PROTECTED] #connect(String, int)} or [EMAIL PROTECTED] 
#connect(java.net.SocketAddress)}
+ * methods.
+ *
+ * The client can be stopped at anytime using the [EMAIL PROTECTED] #stop()} 
method.
+ *
+ * Following is an example of using the SshClient:
+ * <pre>
+ *    SshClient client = SshClient.setUpDefaultClient();
+ *    client.start();
+ *    try {
+ *        ClientSession session = client.connect(host, port);
+ *
+ *        int ret = ClientSession.WAIT_AUTH;
+ *        while ((ret & ClientSession.WAIT_AUTH) != 0) {
+ *            System.out.print("Password:");
+ *            BufferedReader r = new BufferedReader(new 
InputStreamReader(System.in));
+ *            String password = r.readLine();
+ *            session.authPassword(login, password);
+ *            ret = session.waitFor(ClientSession.WAIT_AUTH | 
ClientSession.CLOSED | ClientSession.AUTHED, 0);
+ *        }
+ *        if ((ret & ClientSession.CLOSED) != 0) {
+ *            System.err.println("error");
+ *            System.exit(-1);
+ *        }
+ *        ClientChannel channel = session.createChannel("shell");
+ *        channel.setIn(new NoCloseInputStream(System.in));
+ *        channel.setOut(new NoCloseOutputStream(System.out));
+ *        channel.setErr(new NoCloseOutputStream(System.err));
+ *        channel.open();
+ *        channel.waitFor(ClientChannel.CLOSED, 0);
+ *        session.close();
+ *    } finally {
+ *        client.stop();
+ *    }
+ * </pre>
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Apache MINA SSHD Project</a>
  * @version $Rev$, $Date$

Modified: mina/sshd/trunk/src/main/java/org/apache/sshd/SshServer.java
URL: 
http://svn.apache.org/viewvc/mina/sshd/trunk/src/main/java/org/apache/sshd/SshServer.java?rev=723720&r1=723719&r2=723720&view=diff
==============================================================================
--- mina/sshd/trunk/src/main/java/org/apache/sshd/SshServer.java (original)
+++ mina/sshd/trunk/src/main/java/org/apache/sshd/SshServer.java Fri Dec  5 
04:17:04 2008
@@ -69,7 +69,25 @@
 import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
 
 /**
- * TODO Add javadoc
+ * The SshServer class is the main entry point for the server side of the SSH 
protocol.
+ *
+ * The SshServer has to be configured before being started.  Such 
configuration can be
+ * done either using a dependency injection mechanism (such as the Spring 
framework)
+ * or programmatically. Basic setup is usually done using the [EMAIL 
PROTECTED] #setUpDefaultServer()}
+ * method, which will known ciphers, macs, channels, etc...
+ * Besides this basic setup, a few things have to be manually configured such 
as the
+ * port number, [EMAIL PROTECTED] ShellFactory}, the [EMAIL PROTECTED] 
org.apache.sshd.common.KeyPairProvider}
+ * and the [EMAIL PROTECTED] PasswordAuthenticator}.
+ *
+ * Some properties can also be configured using the [EMAIL PROTECTED] 
#setProperties(java.util.Map)}
+ * method.
+ *
+ * Once the SshServer instance has been configured, it can be started using the
+ * [EMAIL PROTECTED] #start()} method and stopped using the [EMAIL PROTECTED] 
#stop()} method.
+ *
+ * @see ServerFactoryManager
+ * @see org.apache.sshd.common.FactoryManager
+ *
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Apache MINA SSHD Project</a>
  * @version $Rev$, $Date$
@@ -92,6 +110,11 @@
         return port;
     }
 
+    /**
+     * Configure the port number to use for this SSH server.
+     *
+     * @param port the port number for this SSH server
+     */
     public void setPort(int port) {
         this.port = port;
     }

Modified: 
mina/sshd/trunk/src/main/java/org/apache/sshd/common/session/AbstractSession.java
URL: 
http://svn.apache.org/viewvc/mina/sshd/trunk/src/main/java/org/apache/sshd/common/session/AbstractSession.java?rev=723720&r1=723719&r2=723720&view=diff
==============================================================================
--- 
mina/sshd/trunk/src/main/java/org/apache/sshd/common/session/AbstractSession.java
 (original)
+++ 
mina/sshd/trunk/src/main/java/org/apache/sshd/common/session/AbstractSession.java
 Fri Dec  5 04:17:04 2008
@@ -45,26 +45,44 @@
 import org.slf4j.LoggerFactory;
 
 /**
+ * The AbstractSession handles all the basic SSH protocol such as key 
exchange, authentication,
+ * encoding and decoding. Both server side and client side sessions should 
inherit from this
+ * abstract class. Some basic packet processing methods are defined but the 
actual call to these
+ * methods should be done from the [EMAIL PROTECTED] 
#handleMessage(org.apache.sshd.common.util.Buffer)}
+ * method, which is dependant on the state and side of this session.
+ *
  * TODO: if there is any very big packet, decoderBuffer and uncompressBuffer 
will get quite big
  *        and they won't be resized down at any time. Though the packet size 
is really limited
  *        by the channel max packet size
- * TODO Add javadoc
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Apache MINA SSHD Project</a>
  * @version $Rev$, $Date$
  */
 public abstract class AbstractSession implements Closeable {
 
+    /**
+     * Name of the property where this session is stored in the attributes of 
the
+     * underlying MINA session. See [EMAIL PROTECTED] 
#getSession(org.apache.mina.common.IoSession, boolean)}
+     * and [EMAIL PROTECTED] #attachSession(org.apache.mina.common.IoSession, 
AbstractSession)}.
+     */
     public static final String SESSION = "com.google.code.sshd.session";
-
+    /** Our logger */
     protected final Logger log = LoggerFactory.getLogger(getClass());
+    /** The factory manager used to retrieve factories of Ciphers, Macs and 
other objects */
     protected final FactoryManager factoryManager;
+    /** The underlying MINA session */
     protected final IoSession ioSession;
+    /** The pseudo random generator */
     protected final Random random;
+    /** Lock object for this session state */
     protected final Object lock = new Object();
+    /** Boolean indicating if this session has been closed or not */
     protected boolean closed;
+    /** Boolean indicating if this session has been authenticated or not */
     protected boolean authed;
+    /** Map of channels keyed by the identifier */
     protected final Map<Integer, Channel> channels = new 
ConcurrentHashMap<Integer, Channel>();
+    /** Next channel identifier */
     protected int nextChannelId;
 
     //
@@ -101,17 +119,41 @@
     protected final Object encodeLock = new Object();
     protected final Object decodeLock = new Object();
 
-
+    /**
+     * Create a new session.
+     *
+     * @param factoryManager the factory manager
+     * @param ioSession the underlying MINA session
+     */
     public AbstractSession(FactoryManager factoryManager, IoSession ioSession) 
{
         this.factoryManager = factoryManager;
         this.ioSession = ioSession;
         this.random = factoryManager.getRandomFactory().create();
     }
 
+    /**
+     * Retrieve the session from the MINA session.
+     * If the session has not been attached, an IllegalStateException
+     * will be thrown
+     *
+     * @param ioSession the MINA session
+     * @return the session attached to the MINA session
+     */
     public static final AbstractSession getSession(IoSession ioSession) {
         return getSession(ioSession, false);
     }
 
+    /**
+     * Retrieve the session from the MINA session.
+     * If the session has not been attached and allowNull is 
<code>false</code>,
+     * an IllegalStateException will be thrown, else a <code>null</code> will
+     * be returned
+     *
+     * @param ioSession the MINA session
+     * @param allowNull if <code>true</code>, a <code>null</code> value may be
+     *        returned if no session is attached
+     * @return the session attached to the MINA session or <code>null</code>
+     */
     public static final AbstractSession getSession(IoSession ioSession, 
boolean allowNull) {
         AbstractSession session = (AbstractSession) 
ioSession.getAttribute(SESSION);
         if (!allowNull && session == null) {
@@ -120,19 +162,34 @@
         return session;
     }
 
+    /**
+     * Attach a session to the MINA session
+     *
+     * @param ioSession the MINA session
+     * @param session the session to attach
+     */
     public static final void attachSession(IoSession ioSession, 
AbstractSession session) {
         ioSession.setAttribute(SESSION, session);
     }
 
+    /**
+     * Retrieve the factory manager
+     *
+     * @return the factory manager for this session
+     */
     public FactoryManager getFactoryManager() {
         return factoryManager;
     }
 
     /**
-     * Main input point for the MINA framework
+     * Main input point for the MINA framework.
+     *
+     * This method will be called each time new data is received on
+     * the socket and will append it to the input buffer before
+     * calling the [EMAIL PROTECTED] #decode()} method.
      *
      * @param buffer the new buffer received
-     * @throws Exception
+     * @throws Exception if an error occurs while decoding or handling the data
      */
     public void messageReceived(ByteBuffer buffer) throws Exception {
         synchronized (decodeLock) {
@@ -151,9 +208,29 @@
     }
 
 
+    /**
+     * Abstract method for processing incoming decoded packets.
+     * The given buffer will hold the decoded packet, starting from
+     * the command byte at the read position.
+     * Packets must be processed within this call or be copied because
+     * the given buffer is meant to be changed and updated when this
+     * method returns.
+     *
+     * @param buffer the buffer containing the packet
+     * @throws Exception if an exeption occurs while handling this packet.
+     */
     protected abstract void handleMessage(Buffer buffer) throws Exception;
 
-    public void exceptionCaught(Throwable t) throws IOException {
+    /**
+     * Handle any exceptions that occured on this session.
+     * The session will be closed and a disconnect packet will be
+     * sent before if the given exception is an
+     * [EMAIL PROTECTED] org.apache.sshd.common.SshException}.
+     * 
+     * @param t the exception to process
+     * @throws IOException
+     */
+    public void exceptionCaught(Throwable t) {
         log.warn("Exception caught", t);
         try {
             if (t instanceof SshException) {
@@ -168,6 +245,11 @@
         close();
     }
 
+    /**
+     * Close this session.
+     * This method will close all channels, then close the underlying MINA 
session.
+     * The call will block until the mina session is actually closed.
+     */
     public void close() {
         if (!closed) {
             synchronized (lock) {
@@ -199,9 +281,9 @@
      * The buffer has to have 5 bytes free at the beginning to allow the 
encoding to take place.
      * Also, the write position of the buffer has to be set to the position of 
the last byte to write.
      *
-     * @param buffer
-     * @return
-     * @throws java.io.IOException
+     * @param buffer the buffer to encode and send
+     * @return a future that can be used to check when the packet has actually 
been sent
+     * @throws java.io.IOException if an error occured when encoding sending 
the packet
      */
     public WriteFuture writePacket(Buffer buffer) throws IOException {
         // Synchronize all write requests as needed by the encoding algorithm
@@ -215,8 +297,8 @@
     }
 
     /**
-     * Create a new buffer for the specified SSH packet and reserve the needed 
space for
-     * the packet header.
+     * Create a new buffer for the specified SSH packet and reserve the needed 
space
+     * (5 bytes) for the packet header.
      *
      * @param cmd the SSH command
      * @return a new buffer ready for write
@@ -240,7 +322,8 @@
         try {
             // Check that the packet has some free space for the header
             if (buffer.rpos() < 5) {
-                log.warn("Performance cost: when sending a packet, ensure that 
5 bytes are available in front of the buffer");
+                log.warn("Performance cost: when sending a packet, ensure that 
"
+                           + "5 bytes are available in front of the buffer");
                 Buffer nb = new Buffer();
                 nb.wpos(5);
                 nb.putBuffer(buffer);
@@ -298,6 +381,11 @@
         }
     }
 
+    /**
+     * Decode the incoming buffer and handle packets as needed.
+     *
+     * @throws Exception
+     */
     protected void decode() throws Exception {
         // Decoding loop
         for (;;) {
@@ -351,11 +439,13 @@
                                                    "MAC Error");
                         }
                     }
+                    // Increment incoming packet sequence number
                     seqi++;
-
+                    // Get padding
                     byte pad = decoderBuffer.getByte();
                     Buffer buf;
                     int wpos = decoderBuffer.wpos();
+                    // Decompress if needed
                     if (inCompression != null && (authed || 
!inCompression.isDelayed())) {
                         if (uncompressBuffer == null) {
                             uncompressBuffer = new Buffer();
@@ -372,7 +462,9 @@
                     if (log.isTraceEnabled()) {
                         log.trace("Received packet #{}: {}", seqi, 
buf.printHex());
                     }
+                    // Process decoded packet
                     handleMessage(buf);
+                    // Set ready to handle next packet
                     decoderBuffer.rpos(decoderLength + 4 + macSize);
                     decoderBuffer.wpos(wpos);
                     decoderBuffer.compact();
@@ -385,6 +477,11 @@
         }
     }
 
+    /**
+     * Send our identification.
+     *
+     * @param ident our identification to send
+     */
     protected void sendIdentification(String ident) {
         ByteBuffer buffer = ByteBuffer.allocate(32);
         buffer.setAutoExpand(true);
@@ -393,8 +490,28 @@
         ioSession.write(buffer);
     }
 
+    /**
+     * Read the other side identification.
+     * This method is specific to the client or server side, but both should 
call
+     * [EMAIL PROTECTED] 
#doReadIdentification(org.apache.sshd.common.util.Buffer)} and
+     * store the result in the needed property.
+     *
+     * @param buffer the buffer containing the remote identification
+     * @return <code>true</code> if the identification has been fully read or
+     *         <code>false</code> if more data is needed
+     * @throws IOException if an error occurs such as a bad protocol version
+     */
     protected abstract boolean readIdentification(Buffer buffer) throws 
IOException;
 
+    /**
+     * Read the remote identification from this buffer.
+     * If more data is needed, the buffer will be reset to its original state
+     * and a <code>null</code> value will be returned.  Else the identification
+     * string will be returned and the data read will be consumed from the 
buffer.
+     *
+     * @param buffer the buffer containing the identification string
+     * @return the remote identification or <code>null</code> if more data is 
needed
+     */
     protected String doReadIdentification(Buffer buffer) {
         byte[] data = new byte[256];
         for (;;) {
@@ -433,6 +550,12 @@
         }
     }
 
+    /**
+     * Create our proposal for SSH negociation
+     *
+     * @param hostKeyTypes the list of supported host key types
+     * @return an array of 10 strings holding this proposal
+     */
     protected String[] createProposal(String hostKeyTypes) {
         return new String[] {
                 
NamedFactory.Utils.getNames(factoryManager.getKeyExchangeFactories()),
@@ -448,6 +571,14 @@
         };
     }
 
+    /**
+     * Send the key exchange initialization packet.
+     * This packet contains random data along with our proposal.
+     *
+     * @param proposal our proposal for key exchange negociation
+     * @return the sent packet which must be kept for later use
+     * @throws IOException if an error occured sending the packet
+     */
     protected byte[] sendKexInit(String[] proposal) throws IOException {
         Buffer buffer = createBuffer(SshConstants.Message.SSH_MSG_KEXINIT);
         int p = buffer.wpos();
@@ -463,7 +594,15 @@
         return data;
     }
 
-    protected byte[] receiveKexInit(Buffer buffer, String[] proposal) throws 
IOException {
+    /**
+     * Receive the remote key exchange init message.
+     * The packet data is returned for later use.
+     *
+     * @param buffer the buffer containing the key exchange init packet
+     * @param proposal the remote proposal to fill
+     * @return the packet data
+     */
+    protected byte[] receiveKexInit(Buffer buffer, String[] proposal) {
         // Recreate the packet payload which will be needed at a later time
         byte[] d = buffer.array();
         byte[] data = new byte[buffer.available() + 1];
@@ -482,12 +621,25 @@
         return data;
     }
 
+    /**
+     * Send a message to put new keys into use.
+     *
+     * @throws IOException if an error occurs sending the message
+     */
     protected void sendNewKeys() throws IOException {
         log.info("Send SSH_MSG_NEWKEYS");
         Buffer buffer = createBuffer(SshConstants.Message.SSH_MSG_NEWKEYS);
         writePacket(buffer);
     }
 
+    /**
+     * Put new keys into use.
+     * This method will intialize the ciphers, digests, macs and compression
+     * according to the negociated server and client proposals.
+     *
+     * @param isServer boolean indicating if this session is on the server or 
the client side
+     * @throws Exception if an error occurs
+     */
     protected void receiveNewKeys(boolean isServer) throws Exception {
         byte[] IVc2s;
         byte[] IVs2c;
@@ -543,14 +695,14 @@
         MACs2c = hash.digest();
 
         s2ccipher = 
NamedFactory.Utils.create(factoryManager.getCipherFactories(), 
negociated[SshConstants.PROPOSAL_ENC_ALGS_STOC]);
-        Es2c = resizeIfNeeded(Es2c, s2ccipher, hash, K, H);
+        Es2c = resizeKey(Es2c, s2ccipher.getBlockSize(), hash, K, H);
         s2ccipher.init(isServer ? Cipher.Mode.Encrypt : Cipher.Mode.Decrypt, 
Es2c, IVs2c);
 
         s2cmac = NamedFactory.Utils.create(factoryManager.getMacFactories(), 
negociated[SshConstants.PROPOSAL_MAC_ALGS_STOC]);
         s2cmac.init(MACs2c);
 
         c2scipher = 
NamedFactory.Utils.create(factoryManager.getCipherFactories(), 
negociated[SshConstants.PROPOSAL_ENC_ALGS_CTOS]);
-        Ec2s = resizeIfNeeded(Ec2s, c2scipher, hash, K, H);
+        Ec2s = resizeKey(Ec2s, c2scipher.getBlockSize(), hash, K, H);
         c2scipher.init(isServer ? Cipher.Mode.Decrypt : Cipher.Mode.Encrypt, 
Ec2s, IVc2s);
 
         c2smac = NamedFactory.Utils.create(factoryManager.getMacFactories(), 
negociated[SshConstants.PROPOSAL_MAC_ALGS_CTOS]);
@@ -585,8 +737,20 @@
         }
     }
 
-    private byte[] resizeIfNeeded(byte[] E, Cipher cipher, Digest hash, byte[] 
K, byte[] H) throws Exception {
-        while (cipher.getBlockSize() > E.length) {
+    /**
+     * Private method used while putting new keys into use that will resize 
the key used to
+     * initialize the cipher to the needed length.
+     *
+     * @param E the key to resize
+     * @param blockSize the cipher block size
+     * @param hash the hash algorithm
+     * @param K the key exchange K parameter
+     * @param H the key exchange H parameter
+     * @return the resize key
+     * @throws Exception if a problem occur while resizing the key
+     */
+    private byte[] resizeKey(byte[] E, int blockSize, Digest hash, byte[] K, 
byte[] H) throws Exception {
+        while (blockSize > E.length) {
             Buffer buffer = new Buffer();
             buffer.putMPInt(K);
             buffer.putRawBytes(H);
@@ -601,6 +765,13 @@
         return E;
     }
 
+    /**
+     * Send a disconnect packet with the given reason and message
+     *
+     * @param reason the reason code for this disconnect
+     * @param msg the text message
+     * @throws IOException if an error occured sending the packet
+     */
     public void disconnect(int reason, String msg) throws IOException {
         Buffer buffer = createBuffer(SshConstants.Message.SSH_MSG_DISCONNECT);
         buffer.putInt(reason);
@@ -611,12 +782,24 @@
         close();
     }
 
+    /**
+     * Send an unimplemented packet.  This packet should contain the
+     * sequence id of the usupported packet: this number is assumed to
+     * be the last packet received.
+     *
+     * @throws IOException if an error occured sending the packet
+     */
     protected void notImplemented() throws IOException {
         Buffer buffer = 
createBuffer(SshConstants.Message.SSH_MSG_UNIMPLEMENTED);
         buffer.putInt(seqi - 1);
         writePacket(buffer);
     }
 
+    /**
+     * Compute the negociated proposals by merging the client and
+     * server proposal.  The negocatiated proposal will be stored in
+     * the [EMAIL PROTECTED] #negociated} property.
+     */
     protected void negociate() {
         String[] guess = new String[SshConstants.PROPOSAL_MAX];
         for (int i = 0; i < SshConstants.PROPOSAL_MAX; i++) {
@@ -640,16 +823,34 @@
         negociated = guess;
     }
 
+    /**
+     * Process incoming data on a channel
+     *
+     * @param buffer the buffer containing the data
+     * @throws Exception if an error occurs
+     */
     protected void channelData(Buffer buffer) throws Exception {
         Channel channel = getChannel(buffer);
         channel.handleData(buffer);
     }
 
+    /**
+     * Process incoming extended data on a channel
+     *
+     * @param buffer the buffer containing the data
+     * @throws Exception if an error occurs
+     */
     protected void channelExtendedData(Buffer buffer) throws Exception {
         Channel channel = getChannel(buffer);
         channel.handleExtendedData(buffer);
     }
 
+    /**
+     * Process a window adjust packet on a channel
+     *
+     * @param buffer the buffer containing the window adjustement parameters
+     * @throws Exception if an error occurs
+     */
     protected void channelWindowAdjust(Buffer buffer) throws Exception {
         try {
             Channel channel = getChannel(buffer);
@@ -659,27 +860,58 @@
         }
     }
 
+    /**
+     * Process end of file on a channel
+     *
+     * @param buffer the buffer containing the packet
+     * @throws Exception if an error occurs
+     */
     protected void channelEof(Buffer buffer) throws Exception {
         Channel channel = getChannel(buffer);
         channel.handleEof();
     }
 
+    /**
+     * Close a channel due to a close packet received
+     *
+     * @param buffer the buffer containing the packet
+     * @throws Exception if an error occurs
+     */
     protected void channelClose(Buffer buffer) throws Exception {
         Channel channel = getChannel(buffer);
         channel.close();
         channels.remove(channel.getId());
     }
 
+    /**
+     * Service a request on a channel
+     *
+     * @param buffer the buffer containing the request
+     * @throws Exception if an error occurs
+     */
     protected void channelRequest(Buffer buffer) throws IOException {
         Channel channel = getChannel(buffer);
         channel.handleRequest(buffer);
     }
 
+    /**
+     * Process a failure on a channel
+     *
+     * @param buffer the buffer containing the packet
+     * @throws Exception if an error occurs
+     */
     protected void channelFailure(Buffer buffer) throws Exception {
         Channel channel = getChannel(buffer);
         channel.handleFailure();
     }
 
+    /**
+     * Retrieve the channel designated by the given packet
+     *
+     * @param buffer the incoming packet
+     * @return the target channel
+     * @throws IOException if the channel does not exists
+     */
     protected Channel getChannel(Buffer buffer) throws IOException {
         int recipient = buffer.getInt();
         Channel channel = channels.get(recipient);
@@ -691,6 +923,13 @@
         return channel;
     }
 
+    /**
+     * Retrieve a configuration property as an integer
+     *
+     * @param name the name of the property
+     * @param defaultValue the default value
+     * @return the value of the configuration property or the default value if 
not found
+     */
     public int getIntProperty(String name, int defaultValue) {
         try {
             String v = factoryManager.getProperties().get(name);

Modified: mina/sshd/trunk/src/main/java/org/apache/sshd/server/UserAuth.java
URL: 
http://svn.apache.org/viewvc/mina/sshd/trunk/src/main/java/org/apache/sshd/server/UserAuth.java?rev=723720&r1=723719&r2=723720&view=diff
==============================================================================
--- mina/sshd/trunk/src/main/java/org/apache/sshd/server/UserAuth.java 
(original)
+++ mina/sshd/trunk/src/main/java/org/apache/sshd/server/UserAuth.java Fri Dec  
5 04:17:04 2008
@@ -22,7 +22,7 @@
 import org.apache.sshd.server.session.ServerSession;
 
 /**
- * TODO Add javadoc
+ * Server side authentication mechanism.
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Apache MINA SSHD Project</a>
  * @version $Rev$, $Date$

Modified: 
mina/sshd/trunk/src/main/java/org/apache/sshd/server/pam/PAMPasswordAuthenticator.java
URL: 
http://svn.apache.org/viewvc/mina/sshd/trunk/src/main/java/org/apache/sshd/server/pam/PAMPasswordAuthenticator.java?rev=723720&r1=723719&r2=723720&view=diff
==============================================================================
--- 
mina/sshd/trunk/src/main/java/org/apache/sshd/server/pam/PAMPasswordAuthenticator.java
 (original)
+++ 
mina/sshd/trunk/src/main/java/org/apache/sshd/server/pam/PAMPasswordAuthenticator.java
 Fri Dec  5 04:17:04 2008
@@ -25,7 +25,9 @@
 import org.slf4j.LoggerFactory;
 
 /**
- * TODO Add javadoc
+ * A password authenticator using PAM (Pluggable Authentication Module).
+ * Such an authenticator can be used to integrate into an Unix operating
+ * system. 
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Apache MINA SSHD Project</a>
  * @version $Rev$, $Date$

Modified: 
mina/sshd/trunk/src/main/java/org/apache/sshd/server/session/ServerSession.java
URL: 
http://svn.apache.org/viewvc/mina/sshd/trunk/src/main/java/org/apache/sshd/server/session/ServerSession.java?rev=723720&r1=723719&r2=723720&view=diff
==============================================================================
--- 
mina/sshd/trunk/src/main/java/org/apache/sshd/server/session/ServerSession.java 
(original)
+++ 
mina/sshd/trunk/src/main/java/org/apache/sshd/server/session/ServerSession.java 
Fri Dec  5 04:17:04 2008
@@ -50,6 +50,8 @@
  *
  * TODO: use a single Timer for on the server for all sessions
  *
+ * TODO: save the identity of the user so that the shell can access it if 
needed
+ *
  * TODO Add javadoc
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Apache MINA SSHD Project</a>


Reply via email to