diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b274fa6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+/nbproject/private/target
+target/**
+nbproject
+nbproject/**
diff --git a/build.bat b/build.bat
deleted file mode 100644
index a741e9f..0000000
--- a/build.bat
+++ /dev/null
@@ -1,17 +0,0 @@
-@echo off
-
-echo.
-echo JSch Build System
-echo -----------------
-
-set OLD_ANT_HOME=%ANT_HOME%
-set ANT_HOME=tools
-
-set OLD_CLASSPATH=%CLASSPATH%
-
-%ANT_HOME%\bin\ant.bat -emacs %1 %2 %3 %4 %5 %6 %7 %8
-goto cleanup
-
-:cleanup
-set ANT_HOME=%OLD_ANT_HOME%
-set CLASSPATH=%OLD_CLASSPATH%
diff --git a/build.sh b/build.sh
deleted file mode 100644
index 9435a67..0000000
--- a/build.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-
-echo
-echo "JSch Build System"
-echo "-----------------"
-
-export OLD_ANT_HOME=$ANT_HOME
-ANT_HOME=./tools
-
-export OLD_CLASSPATH=$CLASSPATH
-
-
-
-export CLASSPATH
-
-chmod u+x ${ANT_HOME}/bin/antRun
-chmod u+x ${ANT_HOME}/bin/ant
-
-export PROPOSAL=""
-
-
-${ANT_HOME}/bin/ant -emacs $@
-
-export CLASSPATH=$OLD_CLASSPATH
-export ANT_HOME=$OLD_ANT_HOME
diff --git a/build.xml b/build.xml
deleted file mode 100644
index 4c4b8a3..0000000
--- a/build.xml
+++ /dev/null
@@ -1,77 +0,0 @@
-name and value are needed to be passed
- * to the remote in your faivorite encoding,use
- * {@link #setEnv(byte[], byte[])}.
- *
- * @param name A name for environment variable.
- * @param value A value for environment variable.
- * @see RFC4254 6.4 Environment Variable Passing
- */
- public void setEnv(String name, String value){
- setEnv(Util.str2byte(name), Util.str2byte(value));
- }
-
- /**
- * Set the environment variable.
- *
- * @param name A name of environment variable.
- * @param value A value of environment variable.
- * @see #setEnv(String, String)
- * @see RFC4254 6.4 Environment Variable Passing
- */
- public void setEnv(byte[] name, byte[] value){
- synchronized(this){
- getEnv().put(name, value);
- }
- }
-
- private Hashtable getEnv(){
- if(env==null)
- env=new Hashtable();
- return env;
- }
-
- /**
- * Allocate a Pseudo-Terminal.
- *
- * @param enable
- * @see RFC4254 6.2. Requesting a Pseudo-Terminal
- */
- public void setPty(boolean enable){
- pty=enable;
- }
-
- /**
- * Set the terminal mode.
- *
- * @param terminal_mode
- */
- public void setTerminalMode(byte[] terminal_mode){
- this.terminal_mode=terminal_mode;
- }
-
- /**
- * Change the window dimension interactively.
- *
- * @param col terminal width, columns
- * @param row terminal height, rows
- * @param wp terminal width, pixels
- * @param hp terminal height, pixels
- * @see RFC4254 6.7. Window Dimension Change Message
- */
- public void setPtySize(int col, int row, int wp, int hp){
- setPtyType(this.ttype, col, row, wp, hp);
- if(!pty || !isConnected()){
- return;
- }
- try{
- RequestWindowChange request=new RequestWindowChange();
- request.setSize(col, row, wp, hp);
- request.request(getSession(), this);
- }
- catch(Exception e){
- //System.err.println("ChannelSessio.setPtySize: "+e);
- }
- }
-
- /**
- * Set the terminal type.
- * This method is not effective after Channel#connect().
- *
- * @param ttype terminal type(for example, "vt100")
- * @see #setPtyType(String, int, int, int, int)
- */
- public void setPtyType(String ttype){
- setPtyType(ttype, 80, 24, 640, 480);
- }
-
- /**
- * Set the terminal type.
- * This method is not effective after Channel#connect().
- *
- * @param ttype terminal type(for example, "vt100")
- * @param col terminal width, columns
- * @param row terminal height, rows
- * @param wp terminal width, pixels
- * @param hp terminal height, pixels
- */
- public void setPtyType(String ttype, int col, int row, int wp, int hp){
- this.ttype=ttype;
- this.tcol=col;
- this.trow=row;
- this.twp=wp;
- this.thp=hp;
- }
-
- protected void sendRequests() throws Exception{
- Session _session=getSession();
- Request request;
- if(agent_forwarding){
- request=new RequestAgentForwarding();
- request.request(_session, this);
- }
-
- if(xforwading){
- request=new RequestX11();
- request.request(_session, this);
- }
-
- if(pty){
- request=new RequestPtyReq();
- ((RequestPtyReq)request).setTType(ttype);
- ((RequestPtyReq)request).setTSize(tcol, trow, twp, thp);
- if(terminal_mode!=null){
- ((RequestPtyReq)request).setTerminalMode(terminal_mode);
- }
- request.request(_session, this);
- }
-
- if(env!=null){
- for(Enumeration _env=env.keys(); _env.hasMoreElements();){
- Object name=_env.nextElement();
- Object value=env.get(name);
- request=new RequestEnv();
- ((RequestEnv)request).setEnv(toByteArray(name),
- toByteArray(value));
- request.request(_session, this);
- }
- }
- }
-
- private byte[] toByteArray(Object o){
- if(o instanceof String){
- return Util.str2byte((String)o);
- }
- return (byte[])o;
- }
-
- public void run(){
- //System.err.println(this+":run >");
-
- Buffer buf=new Buffer(rmpsize);
- Packet packet=new Packet(buf);
- int i=-1;
- try{
- while(isConnected() &&
- thread!=null &&
- io!=null &&
- io.in!=null){
- i=io.in.read(buf.buffer,
- 14,
- buf.buffer.length-14
- -32 -20 // padding and mac
- );
- if(i==0)continue;
- if(i==-1){
- eof();
- break;
- }
- if(close)break;
- //System.out.println("write: "+i);
- packet.reset();
- buf.putByte((byte)Session.SSH_MSG_CHANNEL_DATA);
- buf.putInt(recipient);
- buf.putInt(i);
- buf.skip(i);
- getSession().write(packet, this, i);
- }
- }
- catch(Exception e){
- //System.err.println("# ChannelExec.run");
- //e.printStackTrace();
- }
- Thread _thread=thread;
- if(_thread!=null){
- synchronized(_thread){ _thread.notifyAll(); }
- }
- thread=null;
- //System.err.println(this+":run <");
- }
-}
diff --git a/src/com/jcraft/jsch/Request.java b/src/com/jcraft/jsch/Request.java
deleted file mode 100644
index 7584819..0000000
--- a/src/com/jcraft/jsch/Request.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
-/*
-Copyright (c) 2002-2010 ymnk, JCraft,Inc. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the distribution.
-
- 3. The names of the authors may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
-INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
-OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package com.jcraft.jsch;
-
-abstract class Request{
- private boolean reply=false;
- private Session session=null;
- private Channel channel=null;
- void request(Session session, Channel channel) throws Exception{
- this.session=session;
- this.channel=channel;
- if(channel.connectTimeout>0){
- setReply(true);
- }
- }
- boolean waitForReply(){ return reply; }
- void setReply(boolean reply){ this.reply=reply; }
- void write(Packet packet) throws Exception{
- if(reply){
- channel.reply=-1;
- }
- session.write(packet);
- if(reply){
- long start=System.currentTimeMillis();
- long timeout=channel.connectTimeout;
- while(channel.isConnected() && channel.reply==-1){
- try{Thread.sleep(10);}
- catch(Exception ee){
- }
- if(timeout>0L &&
- (System.currentTimeMillis()-start)>timeout){
- channel.reply=0;
- throw new JSchException("channel request: timeout");
- }
- }
-
- if(channel.reply==0){
- throw new JSchException("failed to send channel request");
- }
- }
- }
-}
diff --git a/src/com/jcraft/jsch/Buffer.java b/src/main/java/com/jcraft/jsch/Buffer.java
similarity index 78%
rename from src/com/jcraft/jsch/Buffer.java
rename to src/main/java/com/jcraft/jsch/Buffer.java
index ff221e8..94784b1 100644
--- a/src/com/jcraft/jsch/Buffer.java
+++ b/src/main/java/com/jcraft/jsch/Buffer.java
@@ -29,39 +29,92 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
package com.jcraft.jsch;
+/**
+ *
Buffer class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class Buffer{ final byte[] tmp=new byte[4]; byte[] buffer; int index; int s; + /** + *Constructor for Buffer.
+ * + * @param size a int. + */ public Buffer(int size){ buffer=new byte[size]; index=0; s=0; } + /** + *Constructor for Buffer.
+ * + * @param buffer an array of byte. + */ public Buffer(byte[] buffer){ this.buffer=buffer; index=0; s=0; } + /** + *Constructor for Buffer.
+ */ public Buffer(){ this(1024*10*2); } + /** + *putByte.
+ * + * @param foo a byte. + */ public void putByte(byte foo){ buffer[index++]=foo; } + /** + *putByte.
+ * + * @param foo an array of byte. + */ public void putByte(byte[] foo) { putByte(foo, 0, foo.length); } + /** + *putByte.
+ * + * @param foo an array of byte. + * @param begin a int. + * @param length a int. + */ public void putByte(byte[] foo, int begin, int length) { System.arraycopy(foo, begin, buffer, index, length); index+=length; } + /** + *putString.
+ * + * @param foo an array of byte. + */ public void putString(byte[] foo){ putString(foo, 0, foo.length); } + /** + *putString.
+ * + * @param foo an array of byte. + * @param begin a int. + * @param length a int. + */ public void putString(byte[] foo, int begin, int length) { putInt(length); putByte(foo, begin, length); } + /** + *putInt.
+ * + * @param val a int. + */ public void putInt(int val) { tmp[0]=(byte)(val >>> 24); tmp[1]=(byte)(val >>> 16); @@ -70,6 +123,11 @@ public void putInt(int val) { System.arraycopy(tmp, 0, buffer, index, 4); index+=4; } + /** + *putLong.
+ * + * @param val a long. + */ public void putLong(long val) { tmp[0]=(byte)(val >>> 56); tmp[1]=(byte)(val >>> 48); @@ -92,6 +150,11 @@ void putPad(int n) { n--; } } + /** + *putMPInt.
+ * + * @param foo an array of byte. + */ public void putMPInt(byte[] foo){ int i=foo.length; if((foo[0]&0x80)!=0){ @@ -104,25 +167,55 @@ public void putMPInt(byte[] foo){ } putByte(foo); } + /** + *getLength.
+ * + * @return a int. + */ public int getLength(){ return index-s; } + /** + *getOffSet.
+ * + * @return a int. + */ public int getOffSet(){ return s; } + /** + *setOffSet.
+ * + * @param s a int. + */ public void setOffSet(int s){ this.s=s; } + /** + *getLong.
+ * + * @return a long. + */ public long getLong(){ long foo = getInt()&0xffffffffL; foo = ((foo<<32)) | (getInt()&0xffffffffL); return foo; } + /** + *getInt.
+ * + * @return a int. + */ public int getInt(){ int foo = getShort(); foo = ((foo<<16)&0xffff0000) | (getShort()&0xffff); return foo; } + /** + *getUInt.
+ * + * @return a long. + */ public long getUInt(){ long foo = 0L; long bar = 0L; @@ -138,9 +231,19 @@ int getShort() { foo = ((foo<<8)&0xff00)|(getByte()&0xff); return foo; } + /** + *getByte.
+ * + * @return a int. + */ public int getByte() { return (buffer[s++]&0xff); } + /** + *getByte.
+ * + * @param foo an array of byte. + */ public void getByte(byte[] foo) { getByte(foo, 0, foo.length); } @@ -148,11 +251,22 @@ void getByte(byte[] foo, int start, int len) { System.arraycopy(buffer, s, foo, start, len); s+=len; } + /** + *getByte.
+ * + * @param len a int. + * @return a int. + */ public int getByte(int len) { int foo=s; s+=len; return foo; } + /** + *getMPInt.
+ * + * @return an array of byte. + */ public byte[] getMPInt() { int i=getInt(); // uint32 if(i<0 || // bigger than 0x7fffffff @@ -164,6 +278,11 @@ public byte[] getMPInt() { getByte(foo, 0, i); return foo; } + /** + *getMPIntBits.
+ * + * @return an array of byte. + */ public byte[] getMPIntBits() { int bits=getInt(); int bytes=(bits+7)/8; @@ -177,6 +296,11 @@ public byte[] getMPIntBits() { } return foo; } + /** + *getString.
+ * + * @return an array of byte. + */ public byte[] getString() { int i = getInt(); // uint32 if(i<0 || // bigger than 0x7fffffff @@ -194,10 +318,16 @@ byte[] getString(int[]start, int[]len) { len[0]=i; return buffer; } + /** + *reset.
+ */ public void reset(){ index=0; s=0; } + /** + *shift.
+ */ public void shift(){ if(s==0)return; System.arraycopy(buffer, s, buffer, 0, index-s); diff --git a/src/com/jcraft/jsch/Channel.java b/src/main/java/com/jcraft/jsch/Channel.java similarity index 87% rename from src/com/jcraft/jsch/Channel.java rename to src/main/java/com/jcraft/jsch/Channel.java index 0e58bcf..7917799 100644 --- a/src/com/jcraft/jsch/Channel.java +++ b/src/main/java/com/jcraft/jsch/Channel.java @@ -36,6 +36,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.io.IOException; +/** + *Abstract Channel class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public abstract class Channel implements Runnable{ static final int SSH_MSG_CHANNEL_OPEN_CONFIRMATION= 91; @@ -140,10 +146,21 @@ int getRecipient(){ void init() throws JSchException { } + /** + *connect.
+ * + * @throws com.jcraft.jsch.JSchException if any. + */ public void connect() throws JSchException{ connect(0); } + /** + *connect.
+ * + * @param connectTimeout a int. + * @throws com.jcraft.jsch.JSchException if any. + */ public void connect(int connectTimeout) throws JSchException{ Session _session=getSession(); if(!_session.isConnected()){ @@ -208,11 +225,26 @@ public void connect(int connectTimeout) throws JSchException{ } } + /** + *setXForwarding.
+ * + * @param foo a boolean. + */ public void setXForwarding(boolean foo){ } + /** + *start.
+ * + * @throws com.jcraft.jsch.JSchException if any. + */ public void start() throws JSchException{} + /** + *isEOF.
+ * + * @return a boolean. + */ public boolean isEOF() {return eof_remote;} void getData(Buffer buf){ @@ -221,24 +253,63 @@ void getData(Buffer buf){ setRemotePacketSize(buf.getInt()); } + /** + *setInputStream.
+ * + * @param in a {@link java.io.InputStream} object. + */ public void setInputStream(InputStream in){ io.setInputStream(in, false); } + /** + *setInputStream.
+ * + * @param in a {@link java.io.InputStream} object. + * @param dontclose a boolean. + */ public void setInputStream(InputStream in, boolean dontclose){ io.setInputStream(in, dontclose); } + /** + *setOutputStream.
+ * + * @param out a {@link java.io.OutputStream} object. + */ public void setOutputStream(OutputStream out){ io.setOutputStream(out, false); } + /** + *setOutputStream.
+ * + * @param out a {@link java.io.OutputStream} object. + * @param dontclose a boolean. + */ public void setOutputStream(OutputStream out, boolean dontclose){ io.setOutputStream(out, dontclose); } + /** + *setExtOutputStream.
+ * + * @param out a {@link java.io.OutputStream} object. + */ public void setExtOutputStream(OutputStream out){ io.setExtOutputStream(out, false); } + /** + *setExtOutputStream.
+ * + * @param out a {@link java.io.OutputStream} object. + * @param dontclose a boolean. + */ public void setExtOutputStream(OutputStream out, boolean dontclose){ io.setExtOutputStream(out, dontclose); } + /** + *getInputStream.
+ * + * @return a {@link java.io.InputStream} object. + * @throws java.io.IOException if any. + */ public InputStream getInputStream() throws IOException { PipedInputStream in= new MyPipedInputStream( @@ -247,6 +318,12 @@ public InputStream getInputStream() throws IOException { io.setOutputStream(new PassiveOutputStream(in), false); return in; } + /** + *getExtInputStream.
+ * + * @return a {@link java.io.InputStream} object. + * @throws java.io.IOException if any. + */ public InputStream getExtInputStream() throws IOException { PipedInputStream in= new MyPipedInputStream( @@ -255,6 +332,12 @@ public InputStream getExtInputStream() throws IOException { io.setExtOutputStream(new PassiveOutputStream(in), false); return in; } + /** + *getOutputStream.
+ * + * @return a {@link java.io.OutputStream} object. + * @throws java.io.IOException if any. + */ public OutputStream getOutputStream() throws IOException { /* PipedOutputStream out=new PipedOutputStream(); @@ -384,6 +467,9 @@ synchronized void addRemoteWindowSize(int foo){ } void setRemotePacketSize(int foo){ this.rmpsize=foo; } + /** + *run.
+ */ public void run(){ } @@ -488,6 +574,11 @@ void close(){ //e.printStackTrace(); } } + /** + *isClosed.
+ * + * @return a boolean. + */ public boolean isClosed(){ return close; } @@ -512,6 +603,9 @@ static void disconnect(Session session){ } } + /** + *disconnect.
+ */ public void disconnect(){ //System.err.println(this+":disconnect "+io+" "+connected); //Thread.dumpStack(); @@ -546,6 +640,11 @@ public void disconnect(){ } } + /** + *isConnected.
+ * + * @return a boolean. + */ public boolean isConnected(){ Session _session=this.session; if(_session!=null){ @@ -554,6 +653,12 @@ public boolean isConnected(){ return false; } + /** + *sendSignal.
+ * + * @param signal a {@link java.lang.String} object. + * @throws java.lang.Exception if any. + */ public void sendSignal(String signal) throws Exception { RequestSignal request=new RequestSignal(); request.setSignal(signal); @@ -596,12 +701,23 @@ class PassiveOutputStream extends PipedOutputStream{ } void setExitStatus(int status){ exitstatus=status; } + /** + *getExitStatus.
+ * + * @return a int. + */ public int getExitStatus(){ return exitstatus; } void setSession(Session session){ this.session=session; } + /** + *Getter for the field session.
Getter for the field id.
sendOpenConfirmation.
+ * + * @throws java.lang.Exception if any. + */ protected void sendOpenConfirmation() throws Exception{ Buffer buf=new Buffer(100); Packet packet=new Packet(buf); @@ -623,6 +749,11 @@ protected void sendOpenConfirmation() throws Exception{ getSession().write(packet); } + /** + *sendOpenFailure.
+ * + * @param reasoncode a int. + */ protected void sendOpenFailure(int reasoncode){ try{ Buffer buf=new Buffer(100); diff --git a/src/com/jcraft/jsch/ChannelAgentForwarding.java b/src/main/java/com/jcraft/jsch/ChannelAgentForwarding.java similarity index 99% rename from src/com/jcraft/jsch/ChannelAgentForwarding.java rename to src/main/java/com/jcraft/jsch/ChannelAgentForwarding.java index 9fb8cb0..1581842 100644 --- a/src/com/jcraft/jsch/ChannelAgentForwarding.java +++ b/src/main/java/com/jcraft/jsch/ChannelAgentForwarding.java @@ -69,6 +69,9 @@ class ChannelAgentForwarding extends Channel{ connected=true; } + /** + *run.
+ */ public void run(){ try{ sendOpenConfirmation(); diff --git a/src/com/jcraft/jsch/ChannelDirectTCPIP.java b/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java similarity index 89% rename from src/com/jcraft/jsch/ChannelDirectTCPIP.java rename to src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java index 12ad8d5..8c5fa7f 100644 --- a/src/com/jcraft/jsch/ChannelDirectTCPIP.java +++ b/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java @@ -31,6 +31,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.io.*; +/** + *ChannelDirectTCPIP class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class ChannelDirectTCPIP extends Channel{ static private final int LOCAL_WINDOW_SIZE_MAX=0x20000; @@ -58,6 +64,11 @@ void init (){ } } + /** + *connect.
+ * + * @throws com.jcraft.jsch.JSchException if any. + */ public void connect() throws JSchException{ try{ Session _session=getSession(); @@ -132,6 +143,9 @@ public void connect() throws JSchException{ } } + /** + *run.
+ */ public void run(){ Buffer buf=new Buffer(rmpsize); @@ -169,15 +183,37 @@ public void run(){ //System.err.println("connect end"); } + @Override public void setInputStream(InputStream in){ io.setInputStream(in); } + @Override public void setOutputStream(OutputStream out){ io.setOutputStream(out); } + /** + *Setter for the field host.
Setter for the field port.
setOrgIPAddress.
+ * + * @param foo a {@link java.lang.String} object. + */ public void setOrgIPAddress(String foo){this.originator_IP_address=foo;} + /** + *setOrgPort.
+ * + * @param foo a int. + */ public void setOrgPort(int foo){this.originator_port=foo;} } diff --git a/src/com/jcraft/jsch/ChannelExec.java b/src/main/java/com/jcraft/jsch/ChannelExec.java similarity index 78% rename from src/com/jcraft/jsch/ChannelExec.java rename to src/main/java/com/jcraft/jsch/ChannelExec.java index df8869c..dd8787e 100644 --- a/src/com/jcraft/jsch/ChannelExec.java +++ b/src/main/java/com/jcraft/jsch/ChannelExec.java @@ -31,10 +31,21 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.util.*; +/** + *ChannelExec class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class ChannelExec extends ChannelSession{ byte[] command=new byte[0]; + /** + *start.
+ * + * @throws com.jcraft.jsch.JSchException if any. + */ public void start() throws JSchException{ Session _session=getSession(); try{ @@ -59,9 +70,19 @@ public void start() throws JSchException{ } } + /** + *Setter for the field command.
Setter for the field command.
setErrStream.
+ * + * @param out a {@link java.io.OutputStream} object. + */ public void setErrStream(java.io.OutputStream out){ setExtOutputStream(out); } + /** + *setErrStream.
+ * + * @param out a {@link java.io.OutputStream} object. + * @param dontclose a boolean. + */ public void setErrStream(java.io.OutputStream out, boolean dontclose){ setExtOutputStream(out, dontclose); } + /** + *getErrStream.
+ * + * @return a {@link java.io.InputStream} object. + * @throws java.io.IOException if any. + */ public java.io.InputStream getErrStream() throws java.io.IOException { return getExtInputStream(); } diff --git a/src/com/jcraft/jsch/ChannelForwardedTCPIP.java b/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java similarity index 97% rename from src/com/jcraft/jsch/ChannelForwardedTCPIP.java rename to src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java index faafa17..ad39f90 100644 --- a/src/com/jcraft/jsch/ChannelForwardedTCPIP.java +++ b/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java @@ -32,6 +32,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.net.*; import java.io.*; +/** + *ChannelForwardedTCPIP class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class ChannelForwardedTCPIP extends Channel{ static java.util.Vector pool=new java.util.Vector(); @@ -58,6 +64,9 @@ public class ChannelForwardedTCPIP extends Channel{ connected=true; } + /** + *run.
+ */ public void run(){ try{ if(lport==-1){ @@ -304,6 +313,11 @@ static void delPort(Session session){ } } + /** + *getRemotePort.
+ * + * @return a int. + */ public int getRemotePort(){return rport;} void setSocketFactory(SocketFactory factory){ this.factory=factory; diff --git a/src/main/java/com/jcraft/jsch/ChannelSession.java b/src/main/java/com/jcraft/jsch/ChannelSession.java new file mode 100644 index 0000000..55631cc --- /dev/null +++ b/src/main/java/com/jcraft/jsch/ChannelSession.java @@ -0,0 +1,294 @@ +/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ +/* + Copyright (c) 2002-2010 ymnk, JCraft,Inc. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, + INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jcraft.jsch; + +import java.util.*; + +class ChannelSession extends Channel { + + private static byte[] _session = Util.str2byte("session"); + + protected boolean agent_forwarding = false; + protected boolean xforwading = false; + protected Hashtable env = null; + + protected boolean pty = false; + + protected String ttype = "vt100"; + protected int tcol = 80; + protected int trow = 24; + protected int twp = 640; + protected int thp = 480; + protected byte[] terminal_mode = null; + + ChannelSession() { + super(); + type = _session; + io = new IO(); + } + + /** + * Enable the agent forwarding. + * + * @param enable a boolean. + */ + public void setAgentForwarding(boolean enable) { + agent_forwarding = enable; + } + + /** + * {@inheritDoc} + * + * Enable the X11 forwarding. + * + * @see RFC 4254 - 6.3.1 + */ + public void setXForwarding(boolean enable) { + xforwading = enable; + } + + /** + *
+ * Setter for the field env.
name and value are needed to be passed to the remote in
+ * your faivorite encoding,use {@link #setEnv(byte[], byte[])}.
+ *
+ * @param name A name for environment variable.
+ * @param value A value for environment variable.
+ * @see RFC 4254 - 6.4
+ */
+ public void setEnv(String name, String value) {
+ setEnv(Util.str2byte(name), Util.str2byte(value));
+ }
+
+ /**
+ * Set the environment variable.
+ *
+ * @param name A name of environment variable.
+ * @param value A value of environment variable.
+ * @see #setEnv(String, String)
+ * @see RFC 4254 - 6.4 Environment Variable Passing
+ */
+ public void setEnv(byte[] name, byte[] value) {
+ synchronized (this) {
+ getEnv().put(name, value);
+ }
+ }
+
+ private Hashtable getEnv() {
+ if (env == null) {
+ env = new Hashtable();
+ }
+ return env;
+ }
+
+ /**
+ * Allocate a Pseudo-Terminal.
+ *
+ * @param enable a boolean.
+ * @see RFC 4254 - 6.2
+ */
+ public void setPty(boolean enable) {
+ pty = enable;
+ }
+
+ /**
+ * Set the terminal mode.
+ *
+ * @param terminal_mode an array of byte.
+ */
+ public void setTerminalMode(byte[] terminal_mode) {
+ this.terminal_mode = terminal_mode;
+ }
+
+ /**
+ * Change the window dimension interactively.
+ *
+ * @param col terminal width, columns
+ * @param row terminal height, rows
+ * @param wp terminal width, pixels
+ * @param hp terminal height, pixels
+ * @see RFC 4254 - 6.7
+ */
+ public void setPtySize(int col, int row, int wp, int hp) {
+ setPtyType(this.ttype, col, row, wp, hp);
+ if (!pty || !isConnected()) {
+ return;
+ }
+ try {
+ RequestWindowChange request = new RequestWindowChange();
+ request.setSize(col, row, wp, hp);
+ request.request(getSession(), this);
+ } catch (Exception e) {
+ //System.err.println("ChannelSessio.setPtySize: "+e);
+ }
+ }
+
+ /**
+ * Set the terminal type. This method is not effective after Channel#connect().
+ *
+ * @param ttype terminal type(for example, "vt100")
+ * @see #setPtyType(String, int, int, int, int)
+ */
+ public void setPtyType(String ttype) {
+ setPtyType(ttype, 80, 24, 640, 480);
+ }
+
+ /**
+ * Set the terminal type. This method is not effective after Channel#connect().
+ *
+ * @param ttype terminal type(for example, "vt100")
+ * @param col terminal width, columns
+ * @param row terminal height, rows
+ * @param wp terminal width, pixels
+ * @param hp terminal height, pixels
+ */
+ public void setPtyType(String ttype, int col, int row, int wp, int hp) {
+ this.ttype = ttype;
+ this.tcol = col;
+ this.trow = row;
+ this.twp = wp;
+ this.thp = hp;
+ }
+
+ /**
+ * + * sendRequests.
+ * + * @throws java.lang.Exception if any. + */ + protected void sendRequests() throws Exception { + Session _session = getSession(); + Request request; + if (agent_forwarding) { + request = new RequestAgentForwarding(); + request.request(_session, this); + } + + if (xforwading) { + request = new RequestX11(); + request.request(_session, this); + } + + if (pty) { + request = new RequestPtyReq(); + ((RequestPtyReq) request).setTType(ttype); + ((RequestPtyReq) request).setTSize(tcol, trow, twp, thp); + if (terminal_mode != null) { + ((RequestPtyReq) request).setTerminalMode(terminal_mode); + } + request.request(_session, this); + } + + if (env != null) { + for (Enumeration _env = env.keys(); _env.hasMoreElements();) { + Object name = _env.nextElement(); + Object value = env.get(name); + request = new RequestEnv(); + ((RequestEnv) request).setEnv(toByteArray(name), + toByteArray(value)); + request.request(_session, this); + } + } + } + + private byte[] toByteArray(Object o) { + if (o instanceof String) { + return Util.str2byte((String) o); + } + return (byte[]) o; + } + + /** + *+ * run.
+ */ + public void run() { + //System.err.println(this+":run >"); + + Buffer buf = new Buffer(rmpsize); + Packet packet = new Packet(buf); + int i = -1; + try { + while (isConnected() + && thread != null + && io != null + && io.in != null) { + i = io.in.read(buf.buffer, + 14, + buf.buffer.length - 14 + - 32 - 20 // padding and mac + ); + if (i == 0) { + continue; + } + if (i == -1) { + eof(); + break; + } + if (close) { + break; + } + //System.out.println("write: "+i); + packet.reset(); + buf.putByte((byte) Session.SSH_MSG_CHANNEL_DATA); + buf.putInt(recipient); + buf.putInt(i); + buf.skip(i); + getSession().write(packet, this, i); + } + } catch (Exception e) { + //System.err.println("# ChannelExec.run"); + //e.printStackTrace(); + } + Thread _thread = thread; + if (_thread != null) { + synchronized (_thread) { + _thread.notifyAll(); + } + } + thread = null; + //System.err.println(this+":run <"); + } +} diff --git a/src/com/jcraft/jsch/ChannelSftp.java b/src/main/java/com/jcraft/jsch/ChannelSftp.java similarity index 85% rename from src/com/jcraft/jsch/ChannelSftp.java rename to src/main/java/com/jcraft/jsch/ChannelSftp.java index b575f90..18051ad 100644 --- a/src/com/jcraft/jsch/ChannelSftp.java +++ b/src/main/java/com/jcraft/jsch/ChannelSftp.java @@ -33,6 +33,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.util.Vector; +/** + *ChannelSftp class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class ChannelSftp extends ChannelSession{ private static final byte SSH_FXP_INIT= 1; @@ -77,14 +83,23 @@ public class ChannelSftp extends ChannelSession{ private static final int SSH_FILEXFER_ATTR_ACMODTIME= 0x00000008; private static final int SSH_FILEXFER_ATTR_EXTENDED= 0x80000000; + /** ConstantSSH_FX_OK=0 */
public static final int SSH_FX_OK= 0;
+ /** Constant SSH_FX_EOF=1 */
public static final int SSH_FX_EOF= 1;
+ /** Constant SSH_FX_NO_SUCH_FILE=2 */
public static final int SSH_FX_NO_SUCH_FILE= 2;
+ /** Constant SSH_FX_PERMISSION_DENIED=3 */
public static final int SSH_FX_PERMISSION_DENIED= 3;
+ /** Constant SSH_FX_FAILURE=4 */
public static final int SSH_FX_FAILURE= 4;
+ /** Constant SSH_FX_BAD_MESSAGE=5 */
public static final int SSH_FX_BAD_MESSAGE= 5;
+ /** Constant SSH_FX_NO_CONNECTION=6 */
public static final int SSH_FX_NO_CONNECTION= 6;
+ /** Constant SSH_FX_CONNECTION_LOST=7 */
public static final int SSH_FX_CONNECTION_LOST= 7;
+ /** Constant SSH_FX_OP_UNSUPPORTED=8 */
public static final int SSH_FX_OP_UNSUPPORTED= 8;
/*
SSH_FX_OK
@@ -124,8 +139,11 @@ is not supported for the server (it may be generated locally by
*/
private static final int MAX_MSG_LENGTH = 256* 1024;
+ /** Constant OVERWRITE=0 */
public static final int OVERWRITE=0;
+ /** Constant RESUME=1 */
public static final int RESUME=1;
+ /** Constant APPEND=2 */
public static final int APPEND=2;
private boolean interactive=false;
@@ -172,6 +190,11 @@ is not supported for the server (it may be generated locally by
void init(){
}
+ /**
+ * start.
+ * + * @throws com.jcraft.jsch.JSchException if any. + */ public void start() throws JSchException{ try{ @@ -244,8 +267,20 @@ public void start() throws JSchException{ } } + /** + *quit.
+ */ public void quit(){ disconnect();} + /** + *exit.
+ */ public void exit(){ disconnect();} + /** + *lcd.
+ * + * @param path a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void lcd(String path) throws SftpException{ path=localAbsolutePath(path); if((new File(path)).isDirectory()){ @@ -259,6 +294,12 @@ public void lcd(String path) throws SftpException{ throw new SftpException(SSH_FX_NO_SUCH_FILE, "No such directory"); } + /** + *cd.
+ * + * @param path a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void cd(String path) throws SftpException{ try{ path=remoteAbsolutePath(path); @@ -287,16 +328,48 @@ public void cd(String path) throws SftpException{ } } + /** + *put.
+ * + * @param src a {@link java.lang.String} object. + * @param dst a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void put(String src, String dst) throws SftpException{ put(src, dst, null, OVERWRITE); } + /** + *put.
+ * + * @param src a {@link java.lang.String} object. + * @param dst a {@link java.lang.String} object. + * @param mode a int. + * @throws com.jcraft.jsch.SftpException if any. + */ public void put(String src, String dst, int mode) throws SftpException{ put(src, dst, null, mode); } + /** + *put.
+ * + * @param src a {@link java.lang.String} object. + * @param dst a {@link java.lang.String} object. + * @param monitor a {@link com.jcraft.jsch.SftpProgressMonitor} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void put(String src, String dst, SftpProgressMonitor monitor) throws SftpException{ put(src, dst, monitor, OVERWRITE); } + /** + *put.
+ * + * @param src a {@link java.lang.String} object. + * @param dst a {@link java.lang.String} object. + * @param monitor a {@link com.jcraft.jsch.SftpProgressMonitor} object. + * @param mode a int. + * @throws com.jcraft.jsch.SftpException if any. + */ public void put(String src, String dst, SftpProgressMonitor monitor, int mode) throws SftpException{ src=localAbsolutePath(src); @@ -401,16 +474,48 @@ else if(vsize>1){ throw new SftpException(SSH_FX_FAILURE, e.toString()); } } + /** + *put.
+ * + * @param src a {@link java.io.InputStream} object. + * @param dst a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void put(InputStream src, String dst) throws SftpException{ put(src, dst, null, OVERWRITE); } + /** + *put.
+ * + * @param src a {@link java.io.InputStream} object. + * @param dst a {@link java.lang.String} object. + * @param mode a int. + * @throws com.jcraft.jsch.SftpException if any. + */ public void put(InputStream src, String dst, int mode) throws SftpException{ put(src, dst, null, mode); } + /** + *put.
+ * + * @param src a {@link java.io.InputStream} object. + * @param dst a {@link java.lang.String} object. + * @param monitor a {@link com.jcraft.jsch.SftpProgressMonitor} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void put(InputStream src, String dst, SftpProgressMonitor monitor) throws SftpException{ put(src, dst, monitor, OVERWRITE); } + /** + *put.
+ * + * @param src a {@link java.io.InputStream} object. + * @param dst a {@link java.lang.String} object. + * @param monitor a {@link com.jcraft.jsch.SftpProgressMonitor} object. + * @param mode a int. + * @throws com.jcraft.jsch.SftpException if any. + */ public void put(InputStream src, String dst, SftpProgressMonitor monitor, int mode) throws SftpException{ try{ @@ -445,6 +550,15 @@ public void put(InputStream src, String dst, } } + /** + *_put.
+ * + * @param src a {@link java.io.InputStream} object. + * @param dst a {@link java.lang.String} object. + * @param monitor a {@link com.jcraft.jsch.SftpProgressMonitor} object. + * @param mode a int. + * @throws com.jcraft.jsch.SftpException if any. + */ public void _put(InputStream src, String dst, SftpProgressMonitor monitor, int mode) throws SftpException{ try{ @@ -579,15 +693,49 @@ public void _put(InputStream src, String dst, } } + /** + *put.
+ * + * @param dst a {@link java.lang.String} object. + * @return a {@link java.io.OutputStream} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public OutputStream put(String dst) throws SftpException{ return put(dst, (SftpProgressMonitor)null, OVERWRITE); } + /** + *put.
+ * + * @param dst a {@link java.lang.String} object. + * @param mode a int. + * @return a {@link java.io.OutputStream} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public OutputStream put(String dst, final int mode) throws SftpException{ return put(dst, (SftpProgressMonitor)null, mode); } + /** + *put.
+ * + * @param dst a {@link java.lang.String} object. + * @param monitor a {@link com.jcraft.jsch.SftpProgressMonitor} object. + * @param mode a int. + * @return a {@link java.io.OutputStream} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public OutputStream put(String dst, final SftpProgressMonitor monitor, final int mode) throws SftpException{ return put(dst, monitor, mode, 0); } + /** + *put.
+ * + * @param dst a {@link java.lang.String} object. + * @param monitor a {@link com.jcraft.jsch.SftpProgressMonitor} object. + * @param mode a int. + * @param offset a long. + * @return a {@link java.io.OutputStream} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public OutputStream put(String dst, final SftpProgressMonitor monitor, final int mode, long offset) throws SftpException{ dst=remoteAbsolutePath(dst); try{ @@ -745,13 +893,37 @@ public void close() throws java.io.IOException{ } } + /** + *get.
+ * + * @param src a {@link java.lang.String} object. + * @param dst a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void get(String src, String dst) throws SftpException{ get(src, dst, null, OVERWRITE); } + /** + *get.
+ * + * @param src a {@link java.lang.String} object. + * @param dst a {@link java.lang.String} object. + * @param monitor a {@link com.jcraft.jsch.SftpProgressMonitor} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void get(String src, String dst, SftpProgressMonitor monitor) throws SftpException{ get(src, dst, monitor, OVERWRITE); } + /** + *get.
+ * + * @param src a {@link java.lang.String} object. + * @param dst a {@link java.lang.String} object. + * @param monitor a {@link com.jcraft.jsch.SftpProgressMonitor} object. + * @param mode a int. + * @throws com.jcraft.jsch.SftpException if any. + */ public void get(String src, String dst, SftpProgressMonitor monitor, int mode) throws SftpException{ // System.out.println("get: "+src+" "+dst); @@ -854,13 +1026,38 @@ else if(vsize>1){ throw new SftpException(SSH_FX_FAILURE, ""); } } + /** + *get.
+ * + * @param src a {@link java.lang.String} object. + * @param dst a {@link java.io.OutputStream} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void get(String src, OutputStream dst) throws SftpException{ get(src, dst, null, OVERWRITE, 0); } + /** + *get.
+ * + * @param src a {@link java.lang.String} object. + * @param dst a {@link java.io.OutputStream} object. + * @param monitor a {@link com.jcraft.jsch.SftpProgressMonitor} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void get(String src, OutputStream dst, SftpProgressMonitor monitor) throws SftpException{ get(src, dst, monitor, OVERWRITE, 0); } + /** + *get.
+ * + * @param src a {@link java.lang.String} object. + * @param dst a {@link java.io.OutputStream} object. + * @param monitor a {@link com.jcraft.jsch.SftpProgressMonitor} object. + * @param mode a int. + * @param skip a long. + * @throws com.jcraft.jsch.SftpException if any. + */ public void get(String src, OutputStream dst, SftpProgressMonitor monitor, int mode, long skip) throws SftpException{ //System.err.println("get: "+src+", "+dst); @@ -991,25 +1188,62 @@ private void _get(String src, OutputStream dst, } } + /** + *get.
+ * + * @param src a {@link java.lang.String} object. + * @return a {@link java.io.InputStream} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public InputStream get(String src) throws SftpException{ return get(src, null, 0L); } + /** + *get.
+ * + * @param src a {@link java.lang.String} object. + * @param monitor a {@link com.jcraft.jsch.SftpProgressMonitor} object. + * @return a {@link java.io.InputStream} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public InputStream get(String src, SftpProgressMonitor monitor) throws SftpException{ return get(src, monitor, 0L); } /** + *get.
+ * * @deprecated This method will be deleted in the future. + * @param src a {@link java.lang.String} object. + * @param mode a int. + * @return a {@link java.io.InputStream} object. + * @throws com.jcraft.jsch.SftpException if any. */ public InputStream get(String src, int mode) throws SftpException{ return get(src, null, 0L); } /** + *get.
+ * * @deprecated This method will be deleted in the future. + * @param src a {@link java.lang.String} object. + * @param monitor a {@link com.jcraft.jsch.SftpProgressMonitor} object. + * @param mode a int. + * @return a {@link java.io.InputStream} object. + * @throws com.jcraft.jsch.SftpException if any. */ public InputStream get(String src, final SftpProgressMonitor monitor, final int mode) throws SftpException{ return get(src, monitor, 0L); } + /** + *get.
+ * + * @param src a {@link java.lang.String} object. + * @param monitor a {@link com.jcraft.jsch.SftpProgressMonitor} object. + * @param skip a long. + * @return a {@link java.io.InputStream} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public InputStream get(String src, final SftpProgressMonitor monitor, final long skip) throws SftpException{ src=remoteAbsolutePath(src); try{ @@ -1179,6 +1413,13 @@ public void close() throws IOException{ } } + /** + *ls.
+ * + * @param path a {@link java.lang.String} object. + * @return a java$util$Vector object. + * @throws com.jcraft.jsch.SftpException if any. + */ public java.util.Vector ls(String path) throws SftpException{ //System.out.println("ls: "+path); try{ @@ -1354,6 +1595,13 @@ else if(!pattern_has_wildcard){ throw new SftpException(SSH_FX_FAILURE, ""); } } + /** + *readlink.
+ * + * @param path a {@link java.lang.String} object. + * @return a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public String readlink(String path) throws SftpException{ try{ @@ -1402,6 +1650,13 @@ public String readlink(String path) throws SftpException{ } return null; } + /** + *symlink.
+ * + * @param oldpath a {@link java.lang.String} object. + * @param newpath a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void symlink(String oldpath, String newpath) throws SftpException{ if(server_version<3){ throw new SftpException(SSH_FX_OP_UNSUPPORTED, @@ -1445,6 +1700,13 @@ public void symlink(String oldpath, String newpath) throws SftpException{ } } + /** + *rename.
+ * + * @param oldpath a {@link java.lang.String} object. + * @param newpath a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void rename(String oldpath, String newpath) throws SftpException{ if(server_version<2){ throw new SftpException(SSH_FX_OP_UNSUPPORTED, @@ -1496,6 +1758,12 @@ public void rename(String oldpath, String newpath) throws SftpException{ throw new SftpException(SSH_FX_FAILURE, ""); } } + /** + *rm.
+ * + * @param path a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void rm(String path) throws SftpException{ try{ path=remoteAbsolutePath(path); @@ -1553,6 +1821,13 @@ private boolean isRemoteDir(String path){ return false; } + /** + *chgrp.
+ * + * @param gid a int. + * @param path a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void chgrp(int gid, String path) throws SftpException{ try{ path=remoteAbsolutePath(path); @@ -1577,6 +1852,13 @@ public void chgrp(int gid, String path) throws SftpException{ } } + /** + *chown.
+ * + * @param uid a int. + * @param path a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void chown(int uid, String path) throws SftpException{ try{ path=remoteAbsolutePath(path); @@ -1601,6 +1883,13 @@ public void chown(int uid, String path) throws SftpException{ } } + /** + *chmod.
+ * + * @param permissions a int. + * @param path a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void chmod(int permissions, String path) throws SftpException{ try{ path=remoteAbsolutePath(path); @@ -1625,6 +1914,13 @@ public void chmod(int permissions, String path) throws SftpException{ } } + /** + *setMtime.
+ * + * @param path a {@link java.lang.String} object. + * @param mtime a int. + * @throws com.jcraft.jsch.SftpException if any. + */ public void setMtime(String path, int mtime) throws SftpException{ try{ path=remoteAbsolutePath(path); @@ -1649,6 +1945,12 @@ public void setMtime(String path, int mtime) throws SftpException{ } } + /** + *rmdir.
+ * + * @param path a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void rmdir(String path) throws SftpException{ try{ path=remoteAbsolutePath(path); @@ -1686,6 +1988,12 @@ public void rmdir(String path) throws SftpException{ } } + /** + *mkdir.
+ * + * @param path a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void mkdir(String path) throws SftpException{ try{ path=remoteAbsolutePath(path); @@ -1715,6 +2023,13 @@ public void mkdir(String path) throws SftpException{ } } + /** + *stat.
+ * + * @param path a {@link java.lang.String} object. + * @return a {@link com.jcraft.jsch.SftpATTRS} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public SftpATTRS stat(String path) throws SftpException{ try{ path=remoteAbsolutePath(path); @@ -1767,6 +2082,13 @@ private SftpATTRS _stat(String path) throws SftpException{ return _stat(Util.str2byte(path, fEncoding)); } + /** + *lstat.
+ * + * @param path a {@link java.lang.String} object. + * @return a {@link com.jcraft.jsch.SftpATTRS} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public SftpATTRS lstat(String path) throws SftpException{ try{ path=remoteAbsolutePath(path); @@ -1843,6 +2165,13 @@ private byte[] _realpath(String path) throws SftpException, IOException, Excepti return str; } + /** + *setStat.
+ * + * @param path a {@link java.lang.String} object. + * @param attr a {@link com.jcraft.jsch.SftpATTRS} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void setStat(String path, SftpATTRS attr) throws SftpException{ try{ path=remoteAbsolutePath(path); @@ -1888,9 +2217,31 @@ private void _setStat(String path, SftpATTRS attr) throws SftpException{ } } + /** + *pwd.
+ * + * @return a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public String pwd() throws SftpException{ return getCwd(); } + /** + *lpwd.
+ * + * @return a {@link java.lang.String} object. + */ public String lpwd(){ return lcwd; } + /** + *version.
+ * + * @return a {@link java.lang.String} object. + */ public String version(){ return version; } + /** + *Getter for the field home.
disconnect.
+ */ public void disconnect(){ super.disconnect(); } @@ -2391,6 +2745,12 @@ private String isUnique(String path) throws SftpException, Exception{ return (String)(v.elementAt(0)); } + /** + *getServerVersion.
+ * + * @return a int. + * @throws com.jcraft.jsch.SftpException if any. + */ public int getServerVersion() throws SftpException{ if(!isConnected()){ throw new SftpException(SSH_FX_FAILURE, "The channel is not connected."); @@ -2398,6 +2758,12 @@ public int getServerVersion() throws SftpException{ return server_version; } + /** + *setFilenameEncoding.
+ * + * @param encoding a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public void setFilenameEncoding(String encoding) throws SftpException{ int sversion=getServerVersion(); if(sversion > 3 && @@ -2412,12 +2778,25 @@ public void setFilenameEncoding(String encoding) throws SftpException{ fEncoding_is_utf8=fEncoding.equals(UTF8); } + /** + *getExtension.
+ * + * @param key a {@link java.lang.String} object. + * @return a {@link java.lang.String} object. + */ public String getExtension(String key){ if(extensions==null) return null; return (String)extensions.get(key); } + /** + *realpath.
+ * + * @param path a {@link java.lang.String} object. + * @return a {@link java.lang.String} object. + * @throws com.jcraft.jsch.SftpException if any. + */ public String realpath(String path) throws SftpException{ try{ byte[] _path=_realpath(remoteAbsolutePath(path)); @@ -2431,6 +2810,9 @@ public String realpath(String path) throws SftpException{ } } + /** + * Filesystem listing class + */ public class LsEntry implements Comparable{ private String filename; private String longname; @@ -2440,13 +2822,56 @@ public class LsEntry implements Comparable{ setLongname(longname); setAttrs(attrs); } + + /** + * Get the file name from the listing entry + * @return A string representing the file name. + */ public String getFilename(){return filename;}; + + /** + * Set the file name for the listing entry + * @param filename The filename to be set on the listing entry + */ void setFilename(String filename){this.filename = filename;}; + + /** + * Get long version of the file name for the listing entry + * @return A String containing the long name of the listing entry + */ public String getLongname(){return longname;}; + + /** + * Set the long file name for the listing entry + * @param longname The long file name to be set on the listing entry + */ void setLongname(String longname){this.longname = longname;}; + + /** + * Get file attributes for this listing entry + * @return The file attributes as a {@link SftpATTRS} object + */ public SftpATTRS getAttrs(){return attrs;}; + + /** + * Set the file attributes for this listing entry + * @param attrs An instance of {@link SftpATTRS} with the attributes to be set + */ void setAttrs(SftpATTRS attrs) {this.attrs = attrs;}; + + /** + * Return the long version of the file name for this listing entry + * @return The long file name + */ public String toString(){ return longname; } + + /** + * Compare 2 listing entries and return the differential value + * @param o The object with which to compare this listing entry + * @return An integer which is less-than-zero for items sorted higher than this entry, greater-than-zero for items + * to be sorted lower than this entry, and 0 if the items are equal + * @throws ClassCastException If the provided object is not of type {@link LsEntry} + */ public int compareTo(Object o) throws ClassCastException{ if(o instanceof LsEntry){ return filename.compareTo(((LsEntry)o).getFilename()); diff --git a/src/com/jcraft/jsch/ChannelShell.java b/src/main/java/com/jcraft/jsch/ChannelShell.java similarity index 91% rename from src/com/jcraft/jsch/ChannelShell.java rename to src/main/java/com/jcraft/jsch/ChannelShell.java index b956e1d..4aed5a0 100644 --- a/src/com/jcraft/jsch/ChannelShell.java +++ b/src/main/java/com/jcraft/jsch/ChannelShell.java @@ -31,6 +31,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.util.*; +/** + *ChannelShell class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class ChannelShell extends ChannelSession{ ChannelShell(){ @@ -38,6 +44,11 @@ public class ChannelShell extends ChannelSession{ pty=true; } + /** + *start.
+ * + * @throws com.jcraft.jsch.JSchException if any. + */ public void start() throws JSchException{ Session _session=getSession(); try{ diff --git a/src/com/jcraft/jsch/ChannelSubsystem.java b/src/main/java/com/jcraft/jsch/ChannelSubsystem.java similarity index 82% rename from src/com/jcraft/jsch/ChannelSubsystem.java rename to src/main/java/com/jcraft/jsch/ChannelSubsystem.java index e485177..b3674ea 100644 --- a/src/com/jcraft/jsch/ChannelSubsystem.java +++ b/src/main/java/com/jcraft/jsch/ChannelSubsystem.java @@ -29,15 +29,39 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *ChannelSubsystem class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class ChannelSubsystem extends ChannelSession{ boolean xforwading=false; boolean pty=false; boolean want_reply=true; String subsystem=""; + @Override public void setXForwarding(boolean foo){ xforwading=true; } + + @Override public void setPty(boolean foo){ pty=foo; } + /** + *setWantReply.
+ * + * @param foo a boolean. + */ public void setWantReply(boolean foo){ want_reply=foo; } + /** + *Setter for the field subsystem.
start.
+ * + * @throws com.jcraft.jsch.JSchException if any. + */ public void start() throws JSchException{ Session _session=getSession(); try{ @@ -74,9 +98,20 @@ void init() throws JSchException { io.setOutputStream(getSession().out); } + /** + *setErrStream.
+ * + * @param out a {@link java.io.OutputStream} object. + */ public void setErrStream(java.io.OutputStream out){ setExtOutputStream(out); } + /** + *getErrStream.
+ * + * @return a {@link java.io.InputStream} object. + * @throws java.io.IOException if any. + */ public java.io.InputStream getErrStream() throws java.io.IOException { return getExtInputStream(); } diff --git a/src/com/jcraft/jsch/ChannelX11.java b/src/main/java/com/jcraft/jsch/ChannelX11.java similarity index 99% rename from src/com/jcraft/jsch/ChannelX11.java rename to src/main/java/com/jcraft/jsch/ChannelX11.java index e469a73..0d10004 100644 --- a/src/com/jcraft/jsch/ChannelX11.java +++ b/src/main/java/com/jcraft/jsch/ChannelX11.java @@ -123,6 +123,9 @@ static byte[] getFakedCookie(Session session){ */ } + /** + *run.
+ */ public void run(){ try{ diff --git a/src/com/jcraft/jsch/Cipher.java b/src/main/java/com/jcraft/jsch/Cipher.java similarity index 70% rename from src/com/jcraft/jsch/Cipher.java rename to src/main/java/com/jcraft/jsch/Cipher.java index b7ac84c..727b699 100644 --- a/src/com/jcraft/jsch/Cipher.java +++ b/src/main/java/com/jcraft/jsch/Cipher.java @@ -29,12 +29,53 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *Cipher interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface Cipher{ + /** ConstantENCRYPT_MODE=0 */
static int ENCRYPT_MODE=0;
+ /** Constant DECRYPT_MODE=1 */
static int DECRYPT_MODE=1;
+ /**
+ * getIVSize.
+ * + * @return a int. + */ int getIVSize(); + /** + *getBlockSize.
+ * + * @return a int. + */ int getBlockSize(); + /** + *init.
+ * + * @param mode a int. + * @param key an array of byte. + * @param iv an array of byte. + * @throws java.lang.Exception if any. + */ void init(int mode, byte[] key, byte[] iv) throws Exception; + /** + *update.
+ * + * @param foo an array of byte. + * @param s1 a int. + * @param len a int. + * @param bar an array of byte. + * @param s2 a int. + * @throws java.lang.Exception if any. + */ void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception; + /** + *isCBC.
+ * + * @return a boolean. + */ boolean isCBC(); } diff --git a/src/com/jcraft/jsch/CipherNone.java b/src/main/java/com/jcraft/jsch/CipherNone.java similarity index 79% rename from src/com/jcraft/jsch/CipherNone.java rename to src/main/java/com/jcraft/jsch/CipherNone.java index ff50c5b..c5a3429 100644 --- a/src/com/jcraft/jsch/CipherNone.java +++ b/src/main/java/com/jcraft/jsch/CipherNone.java @@ -29,14 +29,44 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *CipherNone class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class CipherNone implements Cipher{ private static final int ivsize=8; private static final int bsize=16; + /** + *getIVSize.
+ * + * @return a int. + */ public int getIVSize(){return ivsize;} + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return bsize;} + /** + *init.
+ * + * @param mode a int. + * @param key an array of byte. + * @param iv an array of byte. + * @throws java.lang.Exception if any. + */ public void init(int mode, byte[] key, byte[] iv) throws Exception{ } + @Override public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ } + /** + *isCBC.
+ * + * @return a boolean. + */ public boolean isCBC(){return false; } } diff --git a/src/com/jcraft/jsch/Compression.java b/src/main/java/com/jcraft/jsch/Compression.java similarity index 74% rename from src/com/jcraft/jsch/Compression.java rename to src/main/java/com/jcraft/jsch/Compression.java index 091073c..96d17f8 100644 --- a/src/com/jcraft/jsch/Compression.java +++ b/src/main/java/com/jcraft/jsch/Compression.java @@ -29,10 +29,40 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *Compression interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface Compression{ + /** ConstantINFLATER=0 */
static public final int INFLATER=0;
+ /** Constant DEFLATER=1 */
static public final int DEFLATER=1;
+ /**
+ * init.
+ * + * @param type a int. + * @param level a int. + */ void init(int type, int level); + /** + *compress.
+ * + * @param buf an array of byte. + * @param start a int. + * @param len a int. + * @return a int. + */ int compress(byte[] buf, int start, int len); + /** + *uncompress.
+ * + * @param buf an array of byte. + * @param start a int. + * @param len an array of int. + * @return an array of byte. + */ byte[] uncompress(byte[] buf, int start, int[] len); } diff --git a/src/com/jcraft/jsch/DH.java b/src/main/java/com/jcraft/jsch/DH.java similarity index 73% rename from src/com/jcraft/jsch/DH.java rename to src/main/java/com/jcraft/jsch/DH.java index 8e43021..755cf07 100644 --- a/src/com/jcraft/jsch/DH.java +++ b/src/main/java/com/jcraft/jsch/DH.java @@ -29,11 +29,49 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *DH interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface DH{ + /** + *init.
+ * + * @throws java.lang.Exception if any. + */ void init() throws Exception; + /** + *setP.
+ * + * @param p an array of byte. + */ void setP(byte[] p); + /** + *setG.
+ * + * @param g an array of byte. + */ void setG(byte[] g); + /** + *getE.
+ * + * @return an array of byte. + * @throws java.lang.Exception if any. + */ byte[] getE() throws Exception; + /** + *setF.
+ * + * @param f an array of byte. + */ void setF(byte[] f); + /** + *getK.
+ * + * @return an array of byte. + * @throws java.lang.Exception if any. + */ byte[] getK() throws Exception; } diff --git a/src/com/jcraft/jsch/DHG1.java b/src/main/java/com/jcraft/jsch/DHG1.java similarity index 94% rename from src/com/jcraft/jsch/DHG1.java rename to src/main/java/com/jcraft/jsch/DHG1.java index 3e8b807..dff8210 100644 --- a/src/com/jcraft/jsch/DHG1.java +++ b/src/main/java/com/jcraft/jsch/DHG1.java @@ -29,6 +29,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *DHG1 class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class DHG1 extends KeyExchange{ static final byte[] g={ 2 }; @@ -79,6 +85,16 @@ public class DHG1 extends KeyExchange{ private Buffer buf; private Packet packet; + /** + *init.
+ * + * @param session a {@link com.jcraft.jsch.Session} object. + * @param V_S an array of byte. + * @param V_C an array of byte. + * @param I_S an array of byte. + * @param I_C an array of byte. + * @throws java.lang.Exception if any. + */ public void init(Session session, byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C) throws Exception{ this.session=session; @@ -136,6 +152,7 @@ public void init(Session session, state=SSH_MSG_KEXDH_REPLY; } + @Override public boolean next(Buffer _buf) throws Exception{ int i,j; @@ -301,10 +318,21 @@ else if(alg.equals("ssh-dss")){ return false; } + /** + *getKeyType.
+ * + * @return a {@link java.lang.String} object. + * @since 0.1.53 + */ public String getKeyType(){ if(type==DSS) return "DSA"; return "RSA"; } + /** + *Getter for the field state.
DHGEX class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class DHGEX extends KeyExchange{ private static final int SSH_MSG_KEX_DH_GEX_GROUP= 31; @@ -67,6 +73,16 @@ public class DHGEX extends KeyExchange{ private byte[] e; //private byte[] f; + /** + *init.
+ * + * @param session a {@link com.jcraft.jsch.Session} object. + * @param V_S an array of byte. + * @param V_C an array of byte. + * @param I_S an array of byte. + * @param I_C an array of byte. + * @throws java.lang.Exception if any. + */ public void init(Session session, byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C) throws Exception{ this.session=session; @@ -114,6 +130,7 @@ public void init(Session session, state=SSH_MSG_KEX_DH_GEX_GROUP; } + @Override public boolean next(Buffer _buf) throws Exception{ int i,j; switch(state){ @@ -331,10 +348,21 @@ else if(alg.equals("ssh-dss")){ return false; } + /** + *getKeyType.
+ * + * @return a {@link java.lang.String} object. + * @since 0.1.53 + */ public String getKeyType(){ if(type==DSS) return "DSA"; return "RSA"; } + /** + *Getter for the field state.
ForwardedTCPIPDaemon interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface ForwardedTCPIPDaemon extends Runnable{ + /** + *setChannel.
+ * + * @param channel a {@link com.jcraft.jsch.ChannelForwardedTCPIP} object. + * @param in a {@link java.io.InputStream} object. + * @param out a {@link java.io.OutputStream} object. + */ void setChannel(ChannelForwardedTCPIP channel, InputStream in, OutputStream out); + /** + *setArg.
+ * + * @param arg an array of {@link java.lang.Object} objects. + */ void setArg(Object[] arg); } diff --git a/src/com/jcraft/jsch/GSSContext.java b/src/main/java/com/jcraft/jsch/GSSContext.java similarity index 70% rename from src/com/jcraft/jsch/GSSContext.java rename to src/main/java/com/jcraft/jsch/GSSContext.java index 42edb8d..5c765ef 100644 --- a/src/com/jcraft/jsch/GSSContext.java +++ b/src/main/java/com/jcraft/jsch/GSSContext.java @@ -29,10 +29,48 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *GSSContext interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface GSSContext{ + /** + *create.
+ * + * @param user a {@link java.lang.String} object. + * @param host a {@link java.lang.String} object. + * @throws com.jcraft.jsch.JSchException if any. + */ public void create(String user, String host) throws JSchException; + /** + *isEstablished.
+ * + * @return a boolean. + */ public boolean isEstablished(); + /** + *init.
+ * + * @param token an array of byte. + * @param s a int. + * @param l a int. + * @return an array of byte. + * @throws com.jcraft.jsch.JSchException if any. + */ public byte[] init(byte[] token, int s, int l) throws JSchException; + /** + *getMIC.
+ * + * @param message an array of byte. + * @param s a int. + * @param l a int. + * @return an array of byte. + */ public byte[] getMIC(byte[] message, int s, int l); + /** + *dispose.
+ */ public void dispose(); } diff --git a/src/com/jcraft/jsch/HASH.java b/src/main/java/com/jcraft/jsch/HASH.java similarity index 76% rename from src/com/jcraft/jsch/HASH.java rename to src/main/java/com/jcraft/jsch/HASH.java index c29c341..46b7041 100644 --- a/src/com/jcraft/jsch/HASH.java +++ b/src/main/java/com/jcraft/jsch/HASH.java @@ -29,9 +29,39 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *HASH interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface HASH{ + /** + *init.
+ * + * @throws java.lang.Exception if any. + */ void init() throws Exception; + /** + *getBlockSize.
+ * + * @return a int. + */ int getBlockSize(); + /** + *update.
+ * + * @param foo an array of byte. + * @param start a int. + * @param len a int. + * @throws java.lang.Exception if any. + */ void update(byte[] foo, int start, int len) throws Exception; + /** + *digest.
+ * + * @return an array of byte. + * @throws java.lang.Exception if any. + */ byte[] digest() throws Exception; } diff --git a/src/com/jcraft/jsch/HostKey.java b/src/main/java/com/jcraft/jsch/HostKey.java similarity index 73% rename from src/com/jcraft/jsch/HostKey.java rename to src/main/java/com/jcraft/jsch/HostKey.java index b847045..6ed1150 100644 --- a/src/com/jcraft/jsch/HostKey.java +++ b/src/main/java/com/jcraft/jsch/HostKey.java @@ -29,23 +29,58 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *HostKey class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class HostKey{ private static final byte[] sshdss=Util.str2byte("ssh-dss"); private static final byte[] sshrsa=Util.str2byte("ssh-rsa"); + /** ConstantGUESS=0 */
protected static final int GUESS=0;
+ /** Constant SSHDSS=1 */
public static final int SSHDSS=1;
+ /** Constant SSHRSA=2 */
public static final int SSHRSA=2;
static final int UNKNOWN=3;
+ /**
+ * The name of the host
+ */
protected String host;
+
+ /**
+ * The type of key
+ */
protected int type;
+
+ /**
+ * The bytes of the host key
+ */
protected byte[] key;
+ /**
+ * Constructor for HostKey.
+ * + * @param host a {@link java.lang.String} object. + * @param key an array of byte. + * @throws com.jcraft.jsch.JSchException if any. + */ public HostKey(String host, byte[] key) throws JSchException { this(host, GUESS, key); } + /** + *Constructor for HostKey.
+ * + * @param host a {@link java.lang.String} object. + * @param type a int. + * @param key an array of byte. + * @throws com.jcraft.jsch.JSchException if any. + */ public HostKey(String host, int type, byte[] key) throws JSchException { this.host=host; if(type==GUESS){ @@ -59,15 +94,36 @@ public HostKey(String host, int type, byte[] key) throws JSchException { this.key=key; } + /** + *Getter for the field host.
Getter for the field type.
Getter for the field key.
getFingerPrint.
+ * + * @param jsch a {@link com.jcraft.jsch.JSch} object. + * @return a {@link java.lang.String} object. + */ public String getFingerPrint(JSch jsch){ HASH hash=null; try{ diff --git a/src/com/jcraft/jsch/HostKeyRepository.java b/src/main/java/com/jcraft/jsch/HostKeyRepository.java similarity index 59% rename from src/com/jcraft/jsch/HostKeyRepository.java rename to src/main/java/com/jcraft/jsch/HostKeyRepository.java index aae6c98..c9a23f3 100644 --- a/src/com/jcraft/jsch/HostKeyRepository.java +++ b/src/main/java/com/jcraft/jsch/HostKeyRepository.java @@ -29,16 +29,68 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *HostKeyRepository interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface HostKeyRepository{ + /** ConstantOK=0 */
final int OK=0;
+ /** Constant NOT_INCLUDED=1 */
final int NOT_INCLUDED=1;
+ /** Constant CHANGED=2 */
final int CHANGED=2;
+ /**
+ * check.
+ * + * @param host a {@link java.lang.String} object. + * @param key an array of byte. + * @return a int. + */ int check(String host, byte[] key); + /** + *add.
+ * + * @param hostkey a {@link com.jcraft.jsch.HostKey} object. + * @param ui a {@link com.jcraft.jsch.UserInfo} object. + */ void add(HostKey hostkey, UserInfo ui); + /** + *remove.
+ * + * @param host a {@link java.lang.String} object. + * @param type a {@link java.lang.String} object. + */ void remove(String host, String type); + /** + *remove.
+ * + * @param host a {@link java.lang.String} object. + * @param type a {@link java.lang.String} object. + * @param key an array of byte. + */ void remove(String host, String type, byte[] key); + /** + *getKnownHostsRepositoryID.
+ * + * @return a {@link java.lang.String} object. + */ String getKnownHostsRepositoryID(); + /** + *getHostKey.
+ * + * @return an array of {@link com.jcraft.jsch.HostKey} objects. + */ HostKey[] getHostKey(); + /** + *getHostKey.
+ * + * @param host a {@link java.lang.String} object. + * @param type a {@link java.lang.String} object. + * @return an array of {@link com.jcraft.jsch.HostKey} objects. + */ HostKey[] getHostKey(String host, String type); } diff --git a/src/com/jcraft/jsch/IO.java b/src/main/java/com/jcraft/jsch/IO.java similarity index 92% rename from src/com/jcraft/jsch/IO.java rename to src/main/java/com/jcraft/jsch/IO.java index 87ef8ad..a2eee11 100644 --- a/src/com/jcraft/jsch/IO.java +++ b/src/main/java/com/jcraft/jsch/IO.java @@ -31,6 +31,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.io.*; +/** + *IO class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class IO{ InputStream in; OutputStream out; @@ -56,6 +62,13 @@ void setInputStream(InputStream in, boolean dontclose){ setInputStream(in); } + /** + *put.
+ * + * @param p a {@link com.jcraft.jsch.Packet} object. + * @throws java.io.IOException if any. + * @throws java.net.SocketException if any. + */ public void put(Packet p) throws IOException, java.net.SocketException { out.write(p.buffer.buffer, 0, p.buffer.index); out.flush(); @@ -97,6 +110,9 @@ void out_close(){ catch(Exception ee){} } + /** + *close.
+ */ public void close(){ try{ if(in!=null && !in_dontclose) in.close(); diff --git a/src/com/jcraft/jsch/Identity.java b/src/main/java/com/jcraft/jsch/Identity.java similarity index 69% rename from src/com/jcraft/jsch/Identity.java rename to src/main/java/com/jcraft/jsch/Identity.java index 099fabf..bb2b654 100644 --- a/src/com/jcraft/jsch/Identity.java +++ b/src/main/java/com/jcraft/jsch/Identity.java @@ -29,13 +29,60 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *Identity interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface Identity{ + /** + *setPassphrase.
+ * + * @param passphrase an array of byte. + * @return a boolean. + * @throws com.jcraft.jsch.JSchException if any. + */ public boolean setPassphrase(byte[] passphrase) throws JSchException; + /** + *getPublicKeyBlob.
+ * + * @return an array of byte. + */ public byte[] getPublicKeyBlob(); + /** + *getSignature.
+ * + * @param data an array of byte. + * @return an array of byte. + */ public byte[] getSignature(byte[] data); + /** + *decrypt.
+ * + * @return a boolean. + */ public boolean decrypt(); + /** + *getAlgName.
+ * + * @return a {@link java.lang.String} object. + */ public String getAlgName(); + /** + *getName.
+ * + * @return a {@link java.lang.String} object. + */ public String getName(); + /** + *isEncrypted.
+ * + * @return a boolean. + */ public boolean isEncrypted(); + /** + *clear.
+ */ public void clear(); } diff --git a/src/com/jcraft/jsch/IdentityFile.java b/src/main/java/com/jcraft/jsch/IdentityFile.java similarity index 97% rename from src/com/jcraft/jsch/IdentityFile.java rename to src/main/java/com/jcraft/jsch/IdentityFile.java index 3543602..72a412b 100644 --- a/src/com/jcraft/jsch/IdentityFile.java +++ b/src/main/java/com/jcraft/jsch/IdentityFile.java @@ -389,11 +389,23 @@ else if(publickeyblob[8]=='r'){ } } + /** + *getAlgName.
+ * + * @return a {@link java.lang.String} object. + */ public String getAlgName(){ if(type==RSA) return "ssh-rsa"; return "ssh-dss"; } + /** + *setPassphrase.
+ * + * @param _passphrase an array of byte. + * @return a boolean. + * @throws com.jcraft.jsch.JSchException if any. + */ public boolean setPassphrase(byte[] _passphrase) throws JSchException{ /* hash is MD5 @@ -447,6 +459,11 @@ else if(keytype==FSECURE){ } } + /** + *getPublicKeyBlob.
+ * + * @return an array of byte. + */ public byte[] getPublicKeyBlob(){ if(publickeyblob!=null) return publickeyblob; if(type==RSA) return getPublicKeyBlob_rsa(); @@ -479,6 +496,12 @@ byte[] getPublicKeyBlob_dss(){ return buf.buffer; } + /** + *getSignature.
+ * + * @param data an array of byte. + * @return an array of byte. + */ public byte[] getSignature(byte[] data){ if(type==RSA) return getSignature_rsa(data); return getSignature_dss(data); @@ -549,6 +572,11 @@ byte[] getSignature_dss(byte[] data){ return null; } + /** + *decrypt.
+ * + * @return a boolean. + */ public boolean decrypt(){ if(type==RSA) return decrypt_rsa(); return decrypt_dss(); @@ -880,10 +908,20 @@ else if(keytype==FSECURE){ return true; } + /** + *isEncrypted.
+ * + * @return a boolean. + */ public boolean isEncrypted(){ return encrypted; } + /** + *getName.
+ * + * @return a {@link java.lang.String} object. + */ public String getName(){ return identity; } @@ -894,12 +932,16 @@ private byte a2b(byte c){ return (byte)(c-'A'+10); } + @Override public boolean equals(Object o){ if(!(o instanceof IdentityFile)) return super.equals(o); IdentityFile foo=(IdentityFile)o; return getName().equals(foo.getName()); } + /** + *clear.
+ */ public void clear(){ Util.bzero(encoded_data); Util.bzero(prv_array); @@ -908,6 +950,9 @@ public void clear(){ Util.bzero(iv); } + /** + *finalize.
+ */ public void finalize (){ clear(); } diff --git a/src/com/jcraft/jsch/JSch.java b/src/main/java/com/jcraft/jsch/JSch.java similarity index 74% rename from src/com/jcraft/jsch/JSch.java rename to src/main/java/com/jcraft/jsch/JSch.java index 5c80a89..53eb8c9 100644 --- a/src/com/jcraft/jsch/JSch.java +++ b/src/main/java/com/jcraft/jsch/JSch.java @@ -32,6 +32,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.io.InputStream; import java.util.Vector; +/** + *JSch class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class JSch{ static java.util.Hashtable config=new java.util.Hashtable(); static{ @@ -118,6 +124,9 @@ public void log(int level, String message){} }; static Logger logger=DEVNULL; + /** + *Constructor for JSch.
+ */ public JSch(){ try{ @@ -134,7 +143,24 @@ public JSch(){ } + /** + *getSession.
+ * + * @param username a {@link java.lang.String} object. + * @param host a {@link java.lang.String} object. + * @return a {@link com.jcraft.jsch.Session} object. + * @throws com.jcraft.jsch.JSchException if any. + */ public Session getSession(String username, String host) throws JSchException { return getSession(username, host, 22); } + /** + *getSession.
+ * + * @param username a {@link java.lang.String} object. + * @param host a {@link java.lang.String} object. + * @param port a int. + * @return a {@link com.jcraft.jsch.Session} object. + * @throws com.jcraft.jsch.JSchException if any. + */ public Session getSession(String username, String host, int port) throws JSchException { if(username==null){ throw new JSchException("username must not be null."); @@ -150,21 +176,43 @@ public Session getSession(String username, String host, int port) throws JSchExc return s; } + /** + *addSession.
+ * + * @param session a {@link com.jcraft.jsch.Session} object. + */ protected void addSession(Session session){ synchronized(pool){ pool.addElement(session); } } + /** + *removeSession.
+ * + * @param session a {@link com.jcraft.jsch.Session} object. + * @return a boolean. + */ protected boolean removeSession(Session session){ synchronized(pool){ return pool.remove(session); } } + /** + *setHostKeyRepository.
+ * + * @param hkrepo a {@link com.jcraft.jsch.HostKeyRepository} object. + */ public void setHostKeyRepository(HostKeyRepository hkrepo){ known_hosts=hkrepo; } + /** + *setKnownHosts.
+ * + * @param filename a {@link java.lang.String} object. + * @throws com.jcraft.jsch.JSchException if any. + */ public void setKnownHosts(String filename) throws JSchException{ if(known_hosts==null) known_hosts=new KnownHosts(this); if(known_hosts instanceof KnownHosts){ @@ -174,6 +222,12 @@ public void setKnownHosts(String filename) throws JSchException{ } } + /** + *setKnownHosts.
+ * + * @param stream a {@link java.io.InputStream} object. + * @throws com.jcraft.jsch.JSchException if any. + */ public void setKnownHosts(InputStream stream) throws JSchException{ if(known_hosts==null) known_hosts=new KnownHosts(this); if(known_hosts instanceof KnownHosts){ @@ -183,15 +237,33 @@ public void setKnownHosts(InputStream stream) throws JSchException{ } } + /** + *getHostKeyRepository.
+ * + * @return a {@link com.jcraft.jsch.HostKeyRepository} object. + */ public HostKeyRepository getHostKeyRepository(){ if(known_hosts==null) known_hosts=new KnownHosts(this); return known_hosts; } + /** + *addIdentity.
+ * + * @param prvkey a {@link java.lang.String} object. + * @throws com.jcraft.jsch.JSchException if any. + */ public void addIdentity(String prvkey) throws JSchException{ addIdentity(prvkey, (byte[])null); } + /** + *addIdentity.
+ * + * @param prvkey a {@link java.lang.String} object. + * @param passphrase a {@link java.lang.String} object. + * @throws com.jcraft.jsch.JSchException if any. + */ public void addIdentity(String prvkey, String passphrase) throws JSchException{ byte[] _passphrase=null; if(passphrase!=null){ @@ -202,20 +274,51 @@ public void addIdentity(String prvkey, String passphrase) throws JSchException{ Util.bzero(_passphrase); } + /** + *addIdentity.
+ * + * @param prvkey a {@link java.lang.String} object. + * @param passphrase an array of byte. + * @throws com.jcraft.jsch.JSchException if any. + */ public void addIdentity(String prvkey, byte[] passphrase) throws JSchException{ Identity identity=IdentityFile.newInstance(prvkey, null, this); addIdentity(identity, passphrase); } + /** + *addIdentity.
+ * + * @param prvkey a {@link java.lang.String} object. + * @param pubkey a {@link java.lang.String} object. + * @param passphrase an array of byte. + * @throws com.jcraft.jsch.JSchException if any. + */ public void addIdentity(String prvkey, String pubkey, byte[] passphrase) throws JSchException{ Identity identity=IdentityFile.newInstance(prvkey, pubkey, this); addIdentity(identity, passphrase); } + /** + *addIdentity.
+ * + * @param name a {@link java.lang.String} object. + * @param prvkey an array of byte. + * @param pubkey an array of byte. + * @param passphrase an array of byte. + * @throws com.jcraft.jsch.JSchException if any. + */ public void addIdentity(String name, byte[]prvkey, byte[]pubkey, byte[] passphrase) throws JSchException{ Identity identity=IdentityFile.newInstance(name, prvkey, pubkey, this); addIdentity(identity, passphrase); } + /** + *addIdentity.
+ * + * @param identity a {@link com.jcraft.jsch.Identity} object. + * @param passphrase an array of byte. + * @throws com.jcraft.jsch.JSchException if any. + */ public void addIdentity(Identity identity, byte[] passphrase) throws JSchException{ if(passphrase!=null){ try{ @@ -235,6 +338,12 @@ public void addIdentity(Identity identity, byte[] passphrase) throws JSchExcepti } } + /** + *removeIdentity.
+ * + * @param name a {@link java.lang.String} object. + * @throws com.jcraft.jsch.JSchException if any. + */ public void removeIdentity(String name) throws JSchException{ synchronized(identities){ for(int i=0; iremoveAllIdentity.
+ * + * @throws com.jcraft.jsch.JSchException if any. + */ public void removeAllIdentity() throws JSchException{ synchronized(identities){ Vector foo=getIdentityNames(); @@ -269,12 +389,23 @@ public void removeAllIdentity() throws JSchException{ } } + /** + *Getter for the field config.
Setter for the field config.
Setter for the field config.
Setter for the field logger.
Getter for the field method.
JSchException class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class JSchException extends Exception{ //private static final long serialVersionUID=-1319309923966731989L; private Throwable cause=null; + /** + *Constructor for JSchException.
+ */ public JSchException () { super(); } + /** + *Constructor for JSchException.
+ * + * @param s a {@link java.lang.String} object. + */ public JSchException (String s) { super(s); } + /** + *Constructor for JSchException.
+ * + * @param s a {@link java.lang.String} object. + * @param e a {@link java.lang.Throwable} object. + */ public JSchException (String s, Throwable e) { super(s); this.cause=e; } + /** + *Getter for the field cause.
Constructor for JSchPartialAuthException.
+ */ public JSchPartialAuthException () { super(); } + /** + *Constructor for JSchPartialAuthException.
+ * + * @param s a {@link java.lang.String} object. + */ public JSchPartialAuthException (String s) { super(s); this.methods=s; } + /** + *Getter for the field methods.
Abstract KeyExchange class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public abstract class KeyExchange{ static final int PROPOSAL_KEX_ALGS=0; @@ -59,18 +65,65 @@ public abstract class KeyExchange{ static String lang_c2s=""; static String lang_s2c=""; + /** ConstantSTATE_END=0 */
public static final int STATE_END=0;
+ /**
+ * A JSch {@link Session} instance
+ */
protected Session session=null;
+
+ /**
+ * The SHA hash for the key
+ */
protected HASH sha=null;
+
+ /**
+ * TODO
+ */
protected byte[] K=null;
+
+ /**
+ * TODO
+ */
protected byte[] H=null;
+
+ /**
+ * TODO
+ */
protected byte[] K_S=null;
+ /**
+ * init.
+ * + * @param session a {@link com.jcraft.jsch.Session} object. + * @param V_S an array of byte. + * @param V_C an array of byte. + * @param I_S an array of byte. + * @param I_C an array of byte. + * @throws java.lang.Exception if any. + */ public abstract void init(Session session, byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C) throws Exception; + /** + *next.
+ * + * @param buf a {@link com.jcraft.jsch.Buffer} object. + * @return a boolean. + * @throws java.lang.Exception if any. + */ public abstract boolean next(Buffer buf) throws Exception; + /** + *getKeyType.
+ * + * @return a {@link java.lang.String} object. + */ public abstract String getKeyType(); + /** + *getState.
+ * + * @return a int. + */ public abstract int getState(); /* @@ -84,6 +137,13 @@ void dump(byte[] foo){ } */ + /** + *guess.
+ * + * @param I_S an array of byte. + * @param I_C an array of byte. + * @return an array of {@link java.lang.String} objects. + */ protected static String[] guess(byte[]I_S, byte[]I_C){ String[] guess=new String[PROPOSAL_MAX]; Buffer sb=new Buffer(I_S); sb.setOffSet(17); @@ -143,6 +203,11 @@ else if(guess[i]==null){ return guess; } + /** + *getFingerPrint.
+ * + * @return a {@link java.lang.String} object. + */ public String getFingerPrint(){ HASH hash=null; try{ diff --git a/src/com/jcraft/jsch/KeyPair.java b/src/main/java/com/jcraft/jsch/KeyPair.java similarity index 83% rename from src/com/jcraft/jsch/KeyPair.java rename to src/main/java/com/jcraft/jsch/KeyPair.java index 5d6392a..18399a6 100644 --- a/src/com/jcraft/jsch/KeyPair.java +++ b/src/main/java/com/jcraft/jsch/KeyPair.java @@ -33,10 +33,20 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.io.FileInputStream; import java.io.File; +/** + *Abstract KeyPair class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public abstract class KeyPair{ + /** ConstantERROR=0 */
public static final int ERROR=0;
+ /** Constant DSA=1 */
public static final int DSA=1;
+ /** Constant RSA=2 */
public static final int RSA=2;
+ /** Constant UNKNOWN=3 */
public static final int UNKNOWN=3;
static final int VENDOR_OPENSSH=0;
@@ -45,9 +55,26 @@ public abstract class KeyPair{
private static final byte[] cr=Util.str2byte("\n");
+ /**
+ * genKeyPair.
+ * + * @param jsch a {@link com.jcraft.jsch.JSch} object. + * @param type a int. + * @return a {@link com.jcraft.jsch.KeyPair} object. + * @throws com.jcraft.jsch.JSchException if any. + */ public static KeyPair genKeyPair(JSch jsch, int type) throws JSchException{ return genKeyPair(jsch, type, 1024); } + /** + *genKeyPair.
+ * + * @param jsch a {@link com.jcraft.jsch.JSch} object. + * @param type a int. + * @param key_size a int. + * @return a {@link com.jcraft.jsch.KeyPair} object. + * @throws com.jcraft.jsch.JSchException if any. + */ public static KeyPair genKeyPair(JSch jsch, int type, int key_size) throws JSchException{ KeyPair kpair=null; if(type==DSA){ kpair=new KeyPairDSA(jsch); } @@ -71,6 +98,11 @@ public static KeyPair genKeyPair(JSch jsch, int type, int key_size) throws JSchE private byte[] passphrase; + /** + *Constructor for KeyPair.
+ * + * @param jsch a {@link com.jcraft.jsch.JSch} object. + */ public KeyPair(JSch jsch){ this.jsch=jsch; } @@ -80,6 +112,11 @@ public KeyPair(JSch jsch){ abstract byte[] getPrivateKey(); + /** + *writePrivateKey.
+ * + * @param out a {@link java.io.OutputStream} object. + */ public void writePrivateKey(java.io.OutputStream out){ byte[] plain=getPrivateKey(); byte[][] _iv=new byte[1][]; @@ -123,10 +160,26 @@ public void writePrivateKey(java.io.OutputStream out){ private static byte[] space=Util.str2byte(" "); abstract byte[] getKeyTypeName(); + /** + *getKeyType.
+ * + * @return a int. + */ public abstract int getKeyType(); + /** + *getPublicKeyBlob.
+ * + * @return an array of byte. + */ public byte[] getPublicKeyBlob(){ return publickeyblob; } + /** + *writePublicKey.
+ * + * @param out a {@link java.io.OutputStream} object. + * @param comment a {@link java.lang.String} object. + */ public void writePublicKey(java.io.OutputStream out, String comment){ byte[] pubblob=getPublicKeyBlob(); byte[] pub=Util.toBase64(pubblob, 0, pubblob.length); @@ -140,12 +193,26 @@ public void writePublicKey(java.io.OutputStream out, String comment){ } } + /** + *writePublicKey.
+ * + * @param name a {@link java.lang.String} object. + * @param comment a {@link java.lang.String} object. + * @throws java.io.FileNotFoundException if any. + * @throws java.io.IOException if any. + */ public void writePublicKey(String name, String comment) throws java.io.FileNotFoundException, java.io.IOException{ FileOutputStream fos=new FileOutputStream(name); writePublicKey(fos, comment); fos.close(); } + /** + *writeSECSHPublicKey.
+ * + * @param out a {@link java.io.OutputStream} object. + * @param comment a {@link java.lang.String} object. + */ public void writeSECSHPublicKey(java.io.OutputStream out, String comment){ byte[] pubblob=getPublicKeyBlob(); byte[] pub=Util.toBase64(pubblob, 0, pubblob.length); @@ -165,6 +232,14 @@ public void writeSECSHPublicKey(java.io.OutputStream out, String comment){ } } + /** + *writeSECSHPublicKey.
+ * + * @param name a {@link java.lang.String} object. + * @param comment a {@link java.lang.String} object. + * @throws java.io.FileNotFoundException if any. + * @throws java.io.IOException if any. + */ public void writeSECSHPublicKey(String name, String comment) throws java.io.FileNotFoundException, java.io.IOException{ FileOutputStream fos=new FileOutputStream(name); writeSECSHPublicKey(fos, comment); @@ -172,12 +247,24 @@ public void writeSECSHPublicKey(String name, String comment) throws java.io.File } + /** + *writePrivateKey.
+ * + * @param name a {@link java.lang.String} object. + * @throws java.io.FileNotFoundException if any. + * @throws java.io.IOException if any. + */ public void writePrivateKey(String name) throws java.io.FileNotFoundException, java.io.IOException{ FileOutputStream fos=new FileOutputStream(name); writePrivateKey(fos); fos.close(); } + /** + *getFingerPrint.
+ * + * @return a {@link java.lang.String} object. + */ public String getFingerPrint(){ if(hash==null) hash=genHash(); byte[] kblob=getPublicKeyBlob(); @@ -359,6 +446,11 @@ else if(vendor==VENDOR_FSECURE){ return key; } + /** + *Setter for the field passphrase.
Setter for the field passphrase.
isEncrypted.
+ * + * @return a boolean. + */ public boolean isEncrypted(){ return encrypted; } + /** + *decrypt.
+ * + * @param _passphrase a {@link java.lang.String} object. + * @return a boolean. + */ public boolean decrypt(String _passphrase){ if(_passphrase==null || _passphrase.length()==0){ return !encrypted; } return decrypt(Util.str2byte(_passphrase)); } + /** + *decrypt.
+ * + * @param _passphrase an array of byte. + * @return a boolean. + */ public boolean decrypt(byte[] _passphrase){ if(!encrypted){ return true; @@ -403,6 +517,14 @@ public boolean decrypt(byte[] _passphrase){ return !encrypted; } + /** + *load.
+ * + * @param jsch a {@link com.jcraft.jsch.JSch} object. + * @param prvkey a {@link java.lang.String} object. + * @return a {@link com.jcraft.jsch.KeyPair} object. + * @throws com.jcraft.jsch.JSchException if any. + */ public static KeyPair load(JSch jsch, String prvkey) throws JSchException{ String pubkey=prvkey+".pub"; if(!new File(pubkey).exists()){ @@ -410,6 +532,15 @@ public static KeyPair load(JSch jsch, String prvkey) throws JSchException{ } return load(jsch, prvkey, pubkey); } + /** + *load.
+ * + * @param jsch a {@link com.jcraft.jsch.JSch} object. + * @param prvkey a {@link java.lang.String} object. + * @param pubkey a {@link java.lang.String} object. + * @return a {@link com.jcraft.jsch.KeyPair} object. + * @throws com.jcraft.jsch.JSchException if any. + */ public static KeyPair load(JSch jsch, String prvkey, String pubkey) throws JSchException{ byte[] iv=new byte[8]; // 8 @@ -655,10 +786,16 @@ static private byte b2a(byte c){ return (byte)(c-10+'A'); } + /** + *dispose.
+ */ public void dispose(){ Util.bzero(passphrase); } + /** + *finalize.
+ */ public void finalize (){ dispose(); } diff --git a/src/com/jcraft/jsch/KeyPairDSA.java b/src/main/java/com/jcraft/jsch/KeyPairDSA.java similarity index 93% rename from src/com/jcraft/jsch/KeyPairDSA.java rename to src/main/java/com/jcraft/jsch/KeyPairDSA.java index ad4f112..bf0fccb 100644 --- a/src/com/jcraft/jsch/KeyPairDSA.java +++ b/src/main/java/com/jcraft/jsch/KeyPairDSA.java @@ -29,6 +29,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *KeyPairDSA class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class KeyPairDSA extends KeyPair{ private byte[] P_array; private byte[] Q_array; @@ -39,6 +45,11 @@ public class KeyPairDSA extends KeyPair{ //private int key_size=0; private int key_size=1024; + /** + *Constructor for KeyPairDSA.
+ * + * @param jsch a {@link com.jcraft.jsch.JSch} object. + */ public KeyPairDSA(JSch jsch){ super(jsch); } @@ -190,6 +201,11 @@ boolean parse(byte[] plain){ return true; } + /** + *getPublicKeyBlob.
+ * + * @return an array of byte. + */ public byte[] getPublicKeyBlob(){ byte[] foo=super.getPublicKeyBlob(); if(foo!=null) return foo; @@ -211,9 +227,22 @@ public byte[] getPublicKeyBlob(){ private static final byte[] sshdss=Util.str2byte("ssh-dss"); byte[] getKeyTypeName(){return sshdss;} + /** + *getKeyType.
+ * + * @return a int. + */ public int getKeyType(){return DSA;} + /** + *getKeySize.
+ * + * @return a int. + */ public int getKeySize(){return key_size; } + /** + *dispose.
+ */ public void dispose(){ super.dispose(); Util.bzero(prv_array); diff --git a/src/com/jcraft/jsch/KeyPairGenDSA.java b/src/main/java/com/jcraft/jsch/KeyPairGenDSA.java similarity index 75% rename from src/com/jcraft/jsch/KeyPairGenDSA.java rename to src/main/java/com/jcraft/jsch/KeyPairGenDSA.java index 1656163..12932ea 100644 --- a/src/com/jcraft/jsch/KeyPairGenDSA.java +++ b/src/main/java/com/jcraft/jsch/KeyPairGenDSA.java @@ -29,11 +29,48 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *KeyPairGenDSA interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface KeyPairGenDSA{ + /** + *init.
+ * + * @param key_size a int. + * @throws java.lang.Exception if any. + */ void init(int key_size) throws Exception; + /** + *getX.
+ * + * @return an array of byte. + */ byte[] getX(); + /** + *getY.
+ * + * @return an array of byte. + */ byte[] getY(); + /** + *getP.
+ * + * @return an array of byte. + */ byte[] getP(); + /** + *getQ.
+ * + * @return an array of byte. + */ byte[] getQ(); + /** + *getG.
+ * + * @return an array of byte. + */ byte[] getG(); } diff --git a/src/com/jcraft/jsch/KeyPairGenRSA.java b/src/main/java/com/jcraft/jsch/KeyPairGenRSA.java similarity index 69% rename from src/com/jcraft/jsch/KeyPairGenRSA.java rename to src/main/java/com/jcraft/jsch/KeyPairGenRSA.java index eb2a5f3..d3848be 100644 --- a/src/com/jcraft/jsch/KeyPairGenRSA.java +++ b/src/main/java/com/jcraft/jsch/KeyPairGenRSA.java @@ -29,15 +29,67 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *KeyPairGenRSA interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface KeyPairGenRSA{ + /** + *init.
+ * + * @param key_size a int. + * @throws java.lang.Exception if any. + */ void init(int key_size) throws Exception; + /** + *getD.
+ * + * @return an array of byte. + */ byte[] getD(); + /** + *getE.
+ * + * @return an array of byte. + */ byte[] getE(); + /** + *getN.
+ * + * @return an array of byte. + */ byte[] getN(); + /** + *getC.
+ * + * @return an array of byte. + */ byte[] getC(); + /** + *getEP.
+ * + * @return an array of byte. + */ byte[] getEP(); + /** + *getEQ.
+ * + * @return an array of byte. + */ byte[] getEQ(); + /** + *getP.
+ * + * @return an array of byte. + */ byte[] getP(); + /** + *getQ.
+ * + * @return an array of byte. + */ byte[] getQ(); } diff --git a/src/com/jcraft/jsch/KeyPairRSA.java b/src/main/java/com/jcraft/jsch/KeyPairRSA.java similarity index 95% rename from src/com/jcraft/jsch/KeyPairRSA.java rename to src/main/java/com/jcraft/jsch/KeyPairRSA.java index 9f52f28..6b4180d 100644 --- a/src/com/jcraft/jsch/KeyPairRSA.java +++ b/src/main/java/com/jcraft/jsch/KeyPairRSA.java @@ -29,6 +29,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *KeyPairRSA class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class KeyPairRSA extends KeyPair{ private byte[] prv_array; private byte[] pub_array; @@ -43,6 +49,11 @@ public class KeyPairRSA extends KeyPair{ //private int key_size=0; private int key_size=1024; + /** + *Constructor for KeyPairRSA.
+ * + * @param jsch a {@link com.jcraft.jsch.JSch} object. + */ public KeyPairRSA(JSch jsch){ super(jsch); } @@ -293,6 +304,11 @@ boolean parse(byte [] plain){ } + /** + *getPublicKeyBlob.
+ * + * @return an array of byte. + */ public byte[] getPublicKeyBlob(){ byte[] foo=super.getPublicKeyBlob(); if(foo!=null) return foo; @@ -310,9 +326,22 @@ public byte[] getPublicKeyBlob(){ private static final byte[] sshrsa=Util.str2byte("ssh-rsa"); byte[] getKeyTypeName(){return sshrsa;} + /** + *getKeyType.
+ * + * @return a int. + */ public int getKeyType(){return RSA;} + /** + *getKeySize.
+ * + * @return a int. + */ public int getKeySize(){return key_size; } + /** + *dispose.
+ */ public void dispose(){ super.dispose(); Util.bzero(prv_array); diff --git a/src/com/jcraft/jsch/KnownHosts.java b/src/main/java/com/jcraft/jsch/KnownHosts.java similarity index 93% rename from src/com/jcraft/jsch/KnownHosts.java rename to src/main/java/com/jcraft/jsch/KnownHosts.java index 88c9feb..e3740c1 100644 --- a/src/com/jcraft/jsch/KnownHosts.java +++ b/src/main/java/com/jcraft/jsch/KnownHosts.java @@ -31,6 +31,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.io.*; +/** + *KnownHosts class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class KnownHosts implements HostKeyRepository{ private static final String _known_hosts="known_hosts"; @@ -177,8 +183,20 @@ private void addInvalidLine(String line) throws JSchException { pool.addElement(hk); } String getKnownHostsFile(){ return known_hosts; } + /** + *getKnownHostsRepositoryID.
+ * + * @return a {@link java.lang.String} object. + */ public String getKnownHostsRepositoryID(){ return known_hosts; } + /** + *check.
+ * + * @param host a {@link java.lang.String} object. + * @param key an array of byte. + * @return a int. + */ public int check(String host, byte[] key){ int result=NOT_INCLUDED; if(host==null){ @@ -211,6 +229,7 @@ public int check(String host, byte[] key){ return result; } + @Override public void add(HostKey hostkey, UserInfo userinfo){ int type=hostkey.type; String host=hostkey.getHost(); @@ -277,9 +296,15 @@ public void add(HostKey hostkey, UserInfo userinfo){ } } + /** + *getHostKey.
+ * + * @return an array of {@link com.jcraft.jsch.HostKey} objects. + */ public HostKey[] getHostKey(){ return getHostKey(null, null); } + @Override public HostKey[] getHostKey(String host, String type){ synchronized(pool){ int count=0; @@ -307,9 +332,17 @@ public HostKey[] getHostKey(String host, String type){ return foo; } } + @Override public void remove(String host, String type){ remove(host, type, null); } + /** + *remove.
+ * + * @param host a {@link java.lang.String} object. + * @param type a {@link java.lang.String} object. + * @param key an array of byte. + */ public void remove(String host, String type, byte[] key){ boolean sync=false; synchronized(pool){ @@ -337,10 +370,21 @@ public void remove(String host, String type, byte[] key){ } } + /** + *sync.
+ * + * @throws java.io.IOException if any. + */ protected void sync() throws IOException { if(known_hosts!=null) sync(known_hosts); } + /** + *sync.
+ * + * @param foo a {@link java.lang.String} object. + * @throws java.io.IOException if any. + */ protected synchronized void sync(String foo) throws IOException { if(foo==null) return; FileOutputStream fos=new FileOutputStream(foo); diff --git a/src/com/jcraft/jsch/Logger.java b/src/main/java/com/jcraft/jsch/Logger.java similarity index 80% rename from src/com/jcraft/jsch/Logger.java rename to src/main/java/com/jcraft/jsch/Logger.java index 6b48b7f..ce9f71c 100644 --- a/src/com/jcraft/jsch/Logger.java +++ b/src/main/java/com/jcraft/jsch/Logger.java @@ -29,16 +29,39 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *Logger interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface Logger{ + /** ConstantDEBUG=0 */
public final int DEBUG=0;
+ /** Constant INFO=1 */
public final int INFO=1;
+ /** Constant WARN=2 */
public final int WARN=2;
+ /** Constant ERROR=3 */
public final int ERROR=3;
+ /** Constant FATAL=4 */
public final int FATAL=4;
+ /**
+ * isEnabled.
+ * + * @param level a int. + * @return a boolean. + */ public boolean isEnabled(int level); + /** + *log.
+ * + * @param level a int. + * @param message a {@link java.lang.String} object. + */ public void log(int level, String message); /* diff --git a/src/com/jcraft/jsch/MAC.java b/src/main/java/com/jcraft/jsch/MAC.java similarity index 72% rename from src/com/jcraft/jsch/MAC.java rename to src/main/java/com/jcraft/jsch/MAC.java index 14884b4..0889d6f 100644 --- a/src/com/jcraft/jsch/MAC.java +++ b/src/main/java/com/jcraft/jsch/MAC.java @@ -29,11 +29,51 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *MAC interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface MAC{ + /** + *getName.
+ * + * @return a {@link java.lang.String} object. + */ String getName(); + /** + *getBlockSize.
+ * + * @return a int. + */ int getBlockSize(); + /** + *init.
+ * + * @param key an array of byte. + * @throws java.lang.Exception if any. + */ void init(byte[] key) throws Exception; + /** + *update.
+ * + * @param foo an array of byte. + * @param start a int. + * @param len a int. + */ void update(byte[] foo, int start, int len); + /** + *update.
+ * + * @param foo a int. + */ void update(int foo); + /** + *doFinal.
+ * + * @param buf an array of byte. + * @param offset a int. + */ void doFinal(byte[] buf, int offset); } diff --git a/src/com/jcraft/jsch/Packet.java b/src/main/java/com/jcraft/jsch/Packet.java similarity index 92% rename from src/com/jcraft/jsch/Packet.java rename to src/main/java/com/jcraft/jsch/Packet.java index 56a2dd9..6951c55 100644 --- a/src/com/jcraft/jsch/Packet.java +++ b/src/main/java/com/jcraft/jsch/Packet.java @@ -29,6 +29,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *Packet class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class Packet{ private static Random random=null; @@ -36,9 +42,17 @@ public class Packet{ Buffer buffer; byte[] ba4=new byte[4]; + /** + *Constructor for Packet.
+ * + * @param buffer a {@link com.jcraft.jsch.Buffer} object. + */ public Packet(Buffer buffer){ this.buffer=buffer; } + /** + *reset.
+ */ public void reset(){ buffer.index=5; } diff --git a/src/com/jcraft/jsch/PortWatcher.java b/src/main/java/com/jcraft/jsch/PortWatcher.java similarity index 99% rename from src/com/jcraft/jsch/PortWatcher.java rename to src/main/java/com/jcraft/jsch/PortWatcher.java index 8f83a0f..3ae2784 100644 --- a/src/com/jcraft/jsch/PortWatcher.java +++ b/src/main/java/com/jcraft/jsch/PortWatcher.java @@ -153,6 +153,9 @@ static void delPort(Session session){ } } + /** + *run.
+ */ public void run(){ thread=this; try{ diff --git a/src/com/jcraft/jsch/Proxy.java b/src/main/java/com/jcraft/jsch/Proxy.java similarity index 72% rename from src/com/jcraft/jsch/Proxy.java rename to src/main/java/com/jcraft/jsch/Proxy.java index 8980d89..7a65e03 100644 --- a/src/com/jcraft/jsch/Proxy.java +++ b/src/main/java/com/jcraft/jsch/Proxy.java @@ -31,10 +31,43 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.io.*; import java.net.Socket; +/** + *Proxy interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface Proxy{ + /** + *connect.
+ * + * @param socket_factory a {@link com.jcraft.jsch.SocketFactory} object. + * @param host a {@link java.lang.String} object. + * @param port a int. + * @param timeout a int. + * @throws java.lang.Exception if any. + */ void connect(SocketFactory socket_factory, String host, int port, int timeout) throws Exception; + /** + *getInputStream.
+ * + * @return a {@link java.io.InputStream} object. + */ InputStream getInputStream(); + /** + *getOutputStream.
+ * + * @return a {@link java.io.OutputStream} object. + */ OutputStream getOutputStream(); + /** + *getSocket.
+ * + * @return a {@link java.net.Socket} object. + */ Socket getSocket(); + /** + *close.
+ */ void close(); } diff --git a/src/com/jcraft/jsch/ProxyHTTP.java b/src/main/java/com/jcraft/jsch/ProxyHTTP.java similarity index 85% rename from src/com/jcraft/jsch/ProxyHTTP.java rename to src/main/java/com/jcraft/jsch/ProxyHTTP.java index ba9eb09..397f3fe 100644 --- a/src/com/jcraft/jsch/ProxyHTTP.java +++ b/src/main/java/com/jcraft/jsch/ProxyHTTP.java @@ -32,6 +32,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.io.*; import java.net.*; +/** + *ProxyHTTP class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class ProxyHTTP implements Proxy{ private static int DEFAULTPORT=80; private String proxy_host; @@ -43,6 +49,11 @@ public class ProxyHTTP implements Proxy{ private String user; private String passwd; + /** + *Constructor for ProxyHTTP.
+ * + * @param proxy_host a {@link java.lang.String} object. + */ public ProxyHTTP(String proxy_host){ int port=DEFAULTPORT; String host=proxy_host; @@ -57,14 +68,27 @@ public ProxyHTTP(String proxy_host){ this.proxy_host=host; this.proxy_port=port; } + /** + *Constructor for ProxyHTTP.
+ * + * @param proxy_host a {@link java.lang.String} object. + * @param proxy_port a int. + */ public ProxyHTTP(String proxy_host, int proxy_port){ this.proxy_host=proxy_host; this.proxy_port=proxy_port; } + /** + *setUserPasswd.
+ * + * @param user a {@link java.lang.String} object. + * @param passwd a {@link java.lang.String} object. + */ public void setUserPasswd(String user, String passwd){ this.user=user; this.passwd=passwd; } + @Override public void connect(SocketFactory socket_factory, String host, int port, int timeout) throws JSchException{ try{ if(socket_factory==null){ @@ -159,9 +183,27 @@ public void connect(SocketFactory socket_factory, String host, int port, int tim throw new JSchException(message); } } + /** + *getInputStream.
+ * + * @return a {@link java.io.InputStream} object. + */ public InputStream getInputStream(){ return in; } + /** + *getOutputStream.
+ * + * @return a {@link java.io.OutputStream} object. + */ public OutputStream getOutputStream(){ return out; } + /** + *Getter for the field socket.
close.
+ */ public void close(){ try{ if(in!=null)in.close(); @@ -174,6 +216,11 @@ public void close(){ out=null; socket=null; } + /** + *getDefaultPort.
+ * + * @return a int. + */ public static int getDefaultPort(){ return DEFAULTPORT; } diff --git a/src/com/jcraft/jsch/ProxySOCKS4.java b/src/main/java/com/jcraft/jsch/ProxySOCKS4.java similarity index 88% rename from src/com/jcraft/jsch/ProxySOCKS4.java rename to src/main/java/com/jcraft/jsch/ProxySOCKS4.java index d3d0e8d..78c96b4 100644 --- a/src/com/jcraft/jsch/ProxySOCKS4.java +++ b/src/main/java/com/jcraft/jsch/ProxySOCKS4.java @@ -38,6 +38,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.io.*; import java.net.*; +/** + *ProxySOCKS4 class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class ProxySOCKS4 implements Proxy{ private static int DEFAULTPORT=1080; private String proxy_host; @@ -48,6 +54,11 @@ public class ProxySOCKS4 implements Proxy{ private String user; private String passwd; + /** + *Constructor for ProxySOCKS4.
+ * + * @param proxy_host a {@link java.lang.String} object. + */ public ProxySOCKS4(String proxy_host){ int port=DEFAULTPORT; String host=proxy_host; @@ -62,14 +73,27 @@ public ProxySOCKS4(String proxy_host){ this.proxy_host=host; this.proxy_port=port; } + /** + *Constructor for ProxySOCKS4.
+ * + * @param proxy_host a {@link java.lang.String} object. + * @param proxy_port a int. + */ public ProxySOCKS4(String proxy_host, int proxy_port){ this.proxy_host=proxy_host; this.proxy_port=proxy_port; } + /** + *setUserPasswd.
+ * + * @param user a {@link java.lang.String} object. + * @param passwd a {@link java.lang.String} object. + */ public void setUserPasswd(String user, String passwd){ this.user=user; this.passwd=passwd; } + @Override public void connect(SocketFactory socket_factory, String host, int port, int timeout) throws JSchException{ try{ if(socket_factory==null){ @@ -191,9 +215,27 @@ public void connect(SocketFactory socket_factory, String host, int port, int tim throw new JSchException("ProxySOCKS4: "+e.toString()); } } + /** + *getInputStream.
+ * + * @return a {@link java.io.InputStream} object. + */ public InputStream getInputStream(){ return in; } + /** + *getOutputStream.
+ * + * @return a {@link java.io.OutputStream} object. + */ public OutputStream getOutputStream(){ return out; } + /** + *Getter for the field socket.
close.
+ */ public void close(){ try{ if(in!=null)in.close(); @@ -206,6 +248,11 @@ public void close(){ out=null; socket=null; } + /** + *getDefaultPort.
+ * + * @return a int. + */ public static int getDefaultPort(){ return DEFAULTPORT; } diff --git a/src/com/jcraft/jsch/ProxySOCKS5.java b/src/main/java/com/jcraft/jsch/ProxySOCKS5.java similarity index 91% rename from src/com/jcraft/jsch/ProxySOCKS5.java rename to src/main/java/com/jcraft/jsch/ProxySOCKS5.java index 295e76a..c689de8 100644 --- a/src/com/jcraft/jsch/ProxySOCKS5.java +++ b/src/main/java/com/jcraft/jsch/ProxySOCKS5.java @@ -38,6 +38,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.io.*; import java.net.*; +/** + *ProxySOCKS5 class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class ProxySOCKS5 implements Proxy{ private static int DEFAULTPORT=1080; private String proxy_host; @@ -48,6 +54,11 @@ public class ProxySOCKS5 implements Proxy{ private String user; private String passwd; + /** + *Constructor for ProxySOCKS5.
+ * + * @param proxy_host a {@link java.lang.String} object. + */ public ProxySOCKS5(String proxy_host){ int port=DEFAULTPORT; String host=proxy_host; @@ -62,14 +73,27 @@ public ProxySOCKS5(String proxy_host){ this.proxy_host=host; this.proxy_port=port; } + /** + *Constructor for ProxySOCKS5.
+ * + * @param proxy_host a {@link java.lang.String} object. + * @param proxy_port a int. + */ public ProxySOCKS5(String proxy_host, int proxy_port){ this.proxy_host=proxy_host; this.proxy_port=proxy_port; } + /** + *setUserPasswd.
+ * + * @param user a {@link java.lang.String} object. + * @param passwd a {@link java.lang.String} object. + */ public void setUserPasswd(String user, String passwd){ this.user=user; this.passwd=passwd; } + @Override public void connect(SocketFactory socket_factory, String host, int port, int timeout) throws JSchException{ try{ if(socket_factory==null){ @@ -318,9 +342,27 @@ public void connect(SocketFactory socket_factory, String host, int port, int tim throw new JSchException(message); } } + /** + *getInputStream.
+ * + * @return a {@link java.io.InputStream} object. + */ public InputStream getInputStream(){ return in; } + /** + *getOutputStream.
+ * + * @return a {@link java.io.OutputStream} object. + */ public OutputStream getOutputStream(){ return out; } + /** + *Getter for the field socket.
close.
+ */ public void close(){ try{ if(in!=null)in.close(); @@ -333,6 +375,11 @@ public void close(){ out=null; socket=null; } + /** + *getDefaultPort.
+ * + * @return a int. + */ public static int getDefaultPort(){ return DEFAULTPORT; } diff --git a/src/com/jcraft/jsch/Random.java b/src/main/java/com/jcraft/jsch/Random.java similarity index 86% rename from src/com/jcraft/jsch/Random.java rename to src/main/java/com/jcraft/jsch/Random.java index 59e5e73..0a11d1e 100644 --- a/src/com/jcraft/jsch/Random.java +++ b/src/main/java/com/jcraft/jsch/Random.java @@ -29,6 +29,19 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *Random interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface Random{ + /** + *fill.
+ * + * @param foo an array of byte. + * @param start a int. + * @param len a int. + */ void fill(byte[] foo, int start, int len); } diff --git a/src/main/java/com/jcraft/jsch/Request.java b/src/main/java/com/jcraft/jsch/Request.java new file mode 100644 index 0000000..fa7fb0e --- /dev/null +++ b/src/main/java/com/jcraft/jsch/Request.java @@ -0,0 +1,98 @@ +/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ +/* + Copyright (c) 2002-2010 ymnk, JCraft,Inc. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, + INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jcraft.jsch; + +abstract class Request { + + private boolean reply = false; + private Session session = null; + private Channel channel = null; + + /** + * Make a request on the given session and channel + * + * @param session The {@link Session} on which to make the request + * @param channel The {@link Channel} on which to make the request + * @throws Exception If there is an error handling the request + */ + void request(Session session, Channel channel) throws Exception { + this.session = session; + this.channel = channel; + if (channel.connectTimeout > 0) { + setReply(true); + } + } + + /** + * Return TRUE if this {@link Request} is set to wait for a reply + */ + boolean waitForReply() { + return reply; + } + + /** + * Set the reply behavior for this {@link Request} + * + * @param reply Set to TRUE if the {@link Request} should wait for a reply + */ + void setReply(boolean reply) { + this.reply = reply; + } + + /** + * Write a packet to the associated session and channel + * + * @param packet The packet to be written to the session/channel + */ + void write(Packet packet) throws Exception { + if (reply) { + channel.reply = -1; + } + session.write(packet); + if (reply) { + long start = System.currentTimeMillis(); + long timeout = channel.connectTimeout; + while (channel.isConnected() && channel.reply == -1) { + try { + Thread.sleep(10); + } catch (Exception ee) { + } + if (timeout > 0L + && (System.currentTimeMillis() - start) > timeout) { + channel.reply = 0; + throw new JSchException("channel request: timeout"); + } + } + + if (channel.reply == 0) { + throw new JSchException("failed to send channel request"); + } + } + } +} diff --git a/src/com/jcraft/jsch/RequestAgentForwarding.java b/src/main/java/com/jcraft/jsch/RequestAgentForwarding.java similarity index 99% rename from src/com/jcraft/jsch/RequestAgentForwarding.java rename to src/main/java/com/jcraft/jsch/RequestAgentForwarding.java index 3e72c21..97cfb02 100644 --- a/src/com/jcraft/jsch/RequestAgentForwarding.java +++ b/src/main/java/com/jcraft/jsch/RequestAgentForwarding.java @@ -30,6 +30,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; class RequestAgentForwarding extends Request{ + @Override public void request(Session session, Channel channel) throws Exception{ super.request(session, channel); diff --git a/src/com/jcraft/jsch/RequestEnv.java b/src/main/java/com/jcraft/jsch/RequestEnv.java similarity index 99% rename from src/com/jcraft/jsch/RequestEnv.java rename to src/main/java/com/jcraft/jsch/RequestEnv.java index a2b1ff0..d3db044 100644 --- a/src/com/jcraft/jsch/RequestEnv.java +++ b/src/main/java/com/jcraft/jsch/RequestEnv.java @@ -36,6 +36,7 @@ void setEnv(byte[] name, byte[] value){ this.name=name; this.value=value; } + @Override public void request(Session session, Channel channel) throws Exception{ super.request(session, channel); diff --git a/src/com/jcraft/jsch/RequestExec.java b/src/main/java/com/jcraft/jsch/RequestExec.java similarity index 99% rename from src/com/jcraft/jsch/RequestExec.java rename to src/main/java/com/jcraft/jsch/RequestExec.java index c2191cd..8a628de 100644 --- a/src/com/jcraft/jsch/RequestExec.java +++ b/src/main/java/com/jcraft/jsch/RequestExec.java @@ -34,6 +34,7 @@ class RequestExec extends Request{ RequestExec(byte[] command){ this.command=command; } + @Override public void request(Session session, Channel channel) throws Exception{ super.request(session, channel); diff --git a/src/com/jcraft/jsch/RequestPtyReq.java b/src/main/java/com/jcraft/jsch/RequestPtyReq.java similarity index 99% rename from src/com/jcraft/jsch/RequestPtyReq.java rename to src/main/java/com/jcraft/jsch/RequestPtyReq.java index 1024158..df299a1 100644 --- a/src/com/jcraft/jsch/RequestPtyReq.java +++ b/src/main/java/com/jcraft/jsch/RequestPtyReq.java @@ -56,6 +56,7 @@ void setTSize(int tcol, int trow, int twp, int thp){ this.thp=thp; } + @Override public void request(Session session, Channel channel) throws Exception{ super.request(session, channel); diff --git a/src/com/jcraft/jsch/RequestSftp.java b/src/main/java/com/jcraft/jsch/RequestSftp.java similarity index 93% rename from src/com/jcraft/jsch/RequestSftp.java rename to src/main/java/com/jcraft/jsch/RequestSftp.java index 3b171f7..cd093d5 100644 --- a/src/com/jcraft/jsch/RequestSftp.java +++ b/src/main/java/com/jcraft/jsch/RequestSftp.java @@ -29,10 +29,17 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *RequestSftp class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class RequestSftp extends Request{ RequestSftp(){ setReply(true); } + @Override public void request(Session session, Channel channel) throws Exception{ super.request(session, channel); diff --git a/src/com/jcraft/jsch/RequestShell.java b/src/main/java/com/jcraft/jsch/RequestShell.java similarity index 99% rename from src/com/jcraft/jsch/RequestShell.java rename to src/main/java/com/jcraft/jsch/RequestShell.java index ffc68d7..6417bcf 100644 --- a/src/com/jcraft/jsch/RequestShell.java +++ b/src/main/java/com/jcraft/jsch/RequestShell.java @@ -30,6 +30,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; class RequestShell extends Request{ + @Override public void request(Session session, Channel channel) throws Exception{ super.request(session, channel); diff --git a/src/com/jcraft/jsch/RequestSignal.java b/src/main/java/com/jcraft/jsch/RequestSignal.java similarity index 94% rename from src/com/jcraft/jsch/RequestSignal.java rename to src/main/java/com/jcraft/jsch/RequestSignal.java index 72baf4e..be99ee5 100644 --- a/src/com/jcraft/jsch/RequestSignal.java +++ b/src/main/java/com/jcraft/jsch/RequestSignal.java @@ -31,7 +31,13 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING class RequestSignal extends Request{ private String signal="KILL"; + /** + *Setter for the field signal.
RequestSubsystem class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class RequestSubsystem extends Request{ private String subsystem=null; + /** + *request.
+ * + * @param session a {@link com.jcraft.jsch.Session} object. + * @param channel a {@link com.jcraft.jsch.Channel} object. + * @param subsystem a {@link java.lang.String} object. + * @param want_reply a boolean. + * @throws java.lang.Exception if any. + */ public void request(Session session, Channel channel, String subsystem, boolean want_reply) throws Exception{ setReply(want_reply); this.subsystem=subsystem; this.request(session, channel); } + + @Override public void request(Session session, Channel channel) throws Exception{ super.request(session, channel); diff --git a/src/com/jcraft/jsch/RequestWindowChange.java b/src/main/java/com/jcraft/jsch/RequestWindowChange.java similarity index 99% rename from src/com/jcraft/jsch/RequestWindowChange.java rename to src/main/java/com/jcraft/jsch/RequestWindowChange.java index 34e6172..090166b 100644 --- a/src/com/jcraft/jsch/RequestWindowChange.java +++ b/src/main/java/com/jcraft/jsch/RequestWindowChange.java @@ -40,6 +40,7 @@ void setSize(int col, int row, int wp, int hp){ this.width_pixels=wp; this.height_pixels=hp; } + @Override public void request(Session session, Channel channel) throws Exception{ super.request(session, channel); diff --git a/src/com/jcraft/jsch/RequestX11.java b/src/main/java/com/jcraft/jsch/RequestX11.java similarity index 96% rename from src/com/jcraft/jsch/RequestX11.java rename to src/main/java/com/jcraft/jsch/RequestX11.java index 748bd32..9d7137a 100644 --- a/src/com/jcraft/jsch/RequestX11.java +++ b/src/main/java/com/jcraft/jsch/RequestX11.java @@ -30,9 +30,15 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; class RequestX11 extends Request{ + /** + *setCookie.
+ * + * @param cookie a {@link java.lang.String} object. + */ public void setCookie(String cookie){ ChannelX11.cookie=Util.str2byte(cookie); } + @Override public void request(Session session, Channel channel) throws Exception{ super.request(session, channel); diff --git a/src/com/jcraft/jsch/ServerSocketFactory.java b/src/main/java/com/jcraft/jsch/ServerSocketFactory.java similarity index 81% rename from src/com/jcraft/jsch/ServerSocketFactory.java rename to src/main/java/com/jcraft/jsch/ServerSocketFactory.java index 3b2d2d7..1fa5d60 100644 --- a/src/com/jcraft/jsch/ServerSocketFactory.java +++ b/src/main/java/com/jcraft/jsch/ServerSocketFactory.java @@ -32,6 +32,21 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.net.*; import java.io.*; +/** + *ServerSocketFactory interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface ServerSocketFactory{ + /** + *createServerSocket.
+ * + * @param port a int. + * @param backlog a int. + * @param bindAddr a {@link java.net.InetAddress} object. + * @return a {@link java.net.ServerSocket} object. + * @throws java.io.IOException if any. + */ public ServerSocket createServerSocket(int port, int backlog, InetAddress bindAddr) throws IOException; } diff --git a/src/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java similarity index 87% rename from src/com/jcraft/jsch/Session.java rename to src/main/java/com/jcraft/jsch/Session.java index 63f1972..f36e1b7 100644 --- a/src/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -32,6 +32,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.io.*; import java.net.*; +/** + *Session class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class Session implements Runnable{ static private final String version="JSCH-0.1.44"; @@ -131,6 +137,9 @@ public class Session implements Runnable{ private int serverAliveInterval=0; private int serverAliveCountMax=1; + /** + * Set daemon behavior for this thread + */ protected boolean daemon_thread=false; private long kex_start_time=0L; @@ -150,10 +159,21 @@ public class Session implements Runnable{ packet=new Packet(buf); } + /** + *connect.
+ * + * @throws com.jcraft.jsch.JSchException if any. + */ public void connect() throws JSchException{ connect(timeout); } + /** + *connect.
+ * + * @param connectTimeout a int. + * @throws com.jcraft.jsch.JSchException if any. + */ public void connect(int connectTimeout) throws JSchException{ if(isConnected){ throw new JSchException("session is already connected"); @@ -549,6 +569,11 @@ private KeyExchange receive_kexinit(Buffer buf) throws Exception { } private boolean in_kex=false; + /** + *rekey.
+ * + * @throws java.lang.Exception if any. + */ public void rekey() throws Exception { send_kexinit(); } @@ -757,6 +782,13 @@ private void checkHost(String chost, int port, KeyExchange kex) throws JSchExcep //public void start(){ (new Thread(this)).start(); } + /** + *openChannel.
+ * + * @param type a {@link java.lang.String} object. + * @return a {@link com.jcraft.jsch.Channel} object. + * @throws com.jcraft.jsch.JSchException if any. + */ public Channel openChannel(String type) throws JSchException{ if(!isConnected){ throw new JSchException("session is down"); @@ -774,6 +806,12 @@ public Channel openChannel(String type) throws JSchException{ } // encode will bin invoked in write with synchronization. + /** + *encode.
+ * + * @param packet a {@link com.jcraft.jsch.Packet} object. + * @throws java.lang.Exception if any. + */ public void encode(Packet packet) throws Exception{ //System.err.println("encode: "+packet.buffer.getCommand()); //System.err.println(" "+packet.buffer.index); @@ -814,6 +852,13 @@ public void encode(Packet packet) throws Exception{ private int s2ccipher_size=8; private int c2scipher_size=8; + /** + *read.
+ * + * @param buf a {@link com.jcraft.jsch.Buffer} object. + * @return a {@link com.jcraft.jsch.Buffer} object. + * @throws java.lang.Exception if any. + */ public Buffer read(Buffer buf) throws Exception{ int j=0; while(true){ @@ -1184,6 +1229,12 @@ private void updateKeys(KeyExchange kex) throws Exception{ _write(packet); } + /** + *write.
+ * + * @param packet a {@link com.jcraft.jsch.Packet} object. + * @throws java.lang.Exception if any. + */ public void write(Packet packet) throws Exception{ // System.err.println("in_kex="+in_kex+" "+(packet.buffer.getCommand())); long t = getTimeout(); @@ -1221,6 +1272,9 @@ private void _write(Packet packet) throws Exception{ } Runnable thread; + /** + *run.
+ */ public void run(){ thread=this; @@ -1542,6 +1596,9 @@ else if(in_kex && stimeoutsetPortForwardingL.
+ * + * @param lport a int. + * @param host a {@link java.lang.String} object. + * @param rport a int. + * @return a int. + * @throws com.jcraft.jsch.JSchException if any. + */ public int setPortForwardingL(int lport, String host, int rport) throws JSchException{ return setPortForwardingL("127.0.0.1", lport, host, rport); } + /** + *setPortForwardingL.
+ * + * @param boundaddress a {@link java.lang.String} object. + * @param lport a int. + * @param host a {@link java.lang.String} object. + * @param rport a int. + * @return a int. + * @throws com.jcraft.jsch.JSchException if any. + */ public int setPortForwardingL(String boundaddress, int lport, String host, int rport) throws JSchException{ return setPortForwardingL(boundaddress, lport, host, rport, null); } + /** + *setPortForwardingL.
+ * + * @param boundaddress a {@link java.lang.String} object. + * @param lport a int. + * @param host a {@link java.lang.String} object. + * @param rport a int. + * @param ssf a {@link com.jcraft.jsch.ServerSocketFactory} object. + * @return a int. + * @throws com.jcraft.jsch.JSchException if any. + */ public int setPortForwardingL(String boundaddress, int lport, String host, int rport, ServerSocketFactory ssf) throws JSchException{ PortWatcher pw=PortWatcher.addPort(this, boundaddress, lport, host, rport, ssf); Thread tmp=new Thread(pw); @@ -1623,36 +1710,115 @@ public int setPortForwardingL(String boundaddress, int lport, String host, int r tmp.start(); return pw.lport; } + /** + *delPortForwardingL.
+ * + * @param lport a int. + * @throws com.jcraft.jsch.JSchException if any. + */ public void delPortForwardingL(int lport) throws JSchException{ delPortForwardingL("127.0.0.1", lport); } + /** + *delPortForwardingL.
+ * + * @param boundaddress a {@link java.lang.String} object. + * @param lport a int. + * @throws com.jcraft.jsch.JSchException if any. + */ public void delPortForwardingL(String boundaddress, int lport) throws JSchException{ PortWatcher.delPort(this, boundaddress, lport); } + /** + *getPortForwardingL.
+ * + * @return an array of {@link java.lang.String} objects. + * @throws com.jcraft.jsch.JSchException if any. + */ public String[] getPortForwardingL() throws JSchException{ return PortWatcher.getPortForwarding(this); } + /** + *setPortForwardingR.
+ * + * @param rport a int. + * @param host a {@link java.lang.String} object. + * @param lport a int. + * @throws com.jcraft.jsch.JSchException if any. + */ public void setPortForwardingR(int rport, String host, int lport) throws JSchException{ setPortForwardingR(null, rport, host, lport, (SocketFactory)null); } + /** + *setPortForwardingR.
+ * + * @param bind_address a {@link java.lang.String} object. + * @param rport a int. + * @param host a {@link java.lang.String} object. + * @param lport a int. + * @throws com.jcraft.jsch.JSchException if any. + */ public void setPortForwardingR(String bind_address, int rport, String host, int lport) throws JSchException{ setPortForwardingR(bind_address, rport, host, lport, (SocketFactory)null); } + /** + *setPortForwardingR.
+ * + * @param rport a int. + * @param host a {@link java.lang.String} object. + * @param lport a int. + * @param sf a {@link com.jcraft.jsch.SocketFactory} object. + * @throws com.jcraft.jsch.JSchException if any. + */ public void setPortForwardingR(int rport, String host, int lport, SocketFactory sf) throws JSchException{ setPortForwardingR(null, rport, host, lport, sf); } + /** + *setPortForwardingR.
+ * + * @param bind_address a {@link java.lang.String} object. + * @param rport a int. + * @param host a {@link java.lang.String} object. + * @param lport a int. + * @param sf a {@link com.jcraft.jsch.SocketFactory} object. + * @throws com.jcraft.jsch.JSchException if any. + */ public void setPortForwardingR(String bind_address, int rport, String host, int lport, SocketFactory sf) throws JSchException{ ChannelForwardedTCPIP.addPort(this, bind_address, rport, host, lport, sf); setPortForwarding(bind_address, rport); } + /** + *setPortForwardingR.
+ * + * @param rport a int. + * @param daemon a {@link java.lang.String} object. + * @throws com.jcraft.jsch.JSchException if any. + */ public void setPortForwardingR(int rport, String daemon) throws JSchException{ setPortForwardingR(null, rport, daemon, null); } + /** + *setPortForwardingR.
+ * + * @param rport a int. + * @param daemon a {@link java.lang.String} object. + * @param arg an array of {@link java.lang.Object} objects. + * @throws com.jcraft.jsch.JSchException if any. + */ public void setPortForwardingR(int rport, String daemon, Object[] arg) throws JSchException{ setPortForwardingR(null, rport, daemon, arg); } + /** + *setPortForwardingR.
+ * + * @param bind_address a {@link java.lang.String} object. + * @param rport a int. + * @param daemon a {@link java.lang.String} object. + * @param arg an array of {@link java.lang.Object} objects. + * @throws com.jcraft.jsch.JSchException if any. + */ public void setPortForwardingR(String bind_address, int rport, String daemon, Object[] arg) throws JSchException{ ChannelForwardedTCPIP.addPort(this, bind_address, rport, daemon, arg); setPortForwarding(bind_address, rport); @@ -1715,6 +1881,12 @@ private void setPortForwarding(String bind_address, int rport) throws JSchExcept } } } + /** + *delPortForwardingR.
+ * + * @param rport a int. + * @throws com.jcraft.jsch.JSchException if any. + */ public void delPortForwardingR(int rport) throws JSchException{ ChannelForwardedTCPIP.delPort(this, rport); } @@ -1769,21 +1941,81 @@ void addChannel(Channel channel){ channel.setSession(this); } + /** + *Setter for the field proxy.
Setter for the field host.
Setter for the field port.
setUserInfo.
+ * + * @param userinfo a {@link com.jcraft.jsch.UserInfo} object. + */ public void setUserInfo(UserInfo userinfo){ this.userinfo=userinfo; } + /** + *getUserInfo.
+ * + * @return a {@link com.jcraft.jsch.UserInfo} object. + */ public UserInfo getUserInfo(){ return userinfo; } + /** + *setInputStream.
+ * + * @param in a {@link java.io.InputStream} object. + */ public void setInputStream(InputStream in){ this.in=in; } + /** + *setOutputStream.
+ * + * @param out a {@link java.io.OutputStream} object. + */ public void setOutputStream(OutputStream out){ this.out=out; } + /** + *setX11Host.
+ * + * @param host a {@link java.lang.String} object. + */ public void setX11Host(String host){ ChannelX11.setHost(host); } + /** + *setX11Port.
+ * + * @param port a int. + */ public void setX11Port(int port){ ChannelX11.setPort(port); } + /** + *setX11Cookie.
+ * + * @param cookie a {@link java.lang.String} object. + */ public void setX11Cookie(String cookie){ ChannelX11.setCookie(cookie); } + /** + *Setter for the field password.
Setter for the field password.
Setter for the field config.
Setter for the field config.
Setter for the field config.
Getter for the field config.
setSocketFactory.
+ * + * @param sfactory a {@link com.jcraft.jsch.SocketFactory} object. + */ public void setSocketFactory(SocketFactory sfactory){ socket_factory=sfactory; } + /** + *isConnected.
+ * + * @return a boolean. + */ public boolean isConnected(){ return isConnected; } + /** + *Getter for the field timeout.
Setter for the field timeout.
getServerVersion.
+ * + * @return a {@link java.lang.String} object. + */ public String getServerVersion(){ return Util.byte2str(V_S); } + /** + *getClientVersion.
+ * + * @return a {@link java.lang.String} object. + */ public String getClientVersion(){ return Util.byte2str(V_C); } + /** + *setClientVersion.
+ * + * @param cv a {@link java.lang.String} object. + */ public void setClientVersion(String cv){ V_C=Util.str2byte(cv); } + /** + *sendIgnore.
+ * + * @throws java.lang.Exception if any. + */ public void sendIgnore() throws Exception{ Buffer buf=new Buffer(); Packet packet=new Packet(buf); @@ -1868,6 +2163,11 @@ public void sendIgnore() throws Exception{ } private static final byte[] keepalivemsg=Util.str2byte("keepalive@jcraft.com"); + /** + *sendKeepAliveMsg.
+ * + * @throws java.lang.Exception if any. + */ public void sendKeepAliveMsg() throws Exception{ Buffer buf=new Buffer(); Packet packet=new Packet(buf); @@ -1879,32 +2179,88 @@ public void sendKeepAliveMsg() throws Exception{ } private HostKey hostkey=null; + /** + *getHostKey.
+ * + * @return a {@link com.jcraft.jsch.HostKey} object. + */ public HostKey getHostKey(){ return hostkey; } + /** + *Getter for the field host.
getUserName.
+ * + * @return a {@link java.lang.String} object. + */ public String getUserName(){return username;} + /** + *Getter for the field port.
Setter for the field hostKeyAlias.
Getter for the field hostKeyAlias.
Setter for the field serverAliveInterval.
Setter for the field serverAliveCountMax.
Getter for the field serverAliveInterval.
Getter for the field serverAliveCountMax.
setDaemonThread.
+ * + * @param enable a boolean. + */ public void setDaemonThread(boolean enable){ this.daemon_thread=enable; } diff --git a/src/com/jcraft/jsch/SftpATTRS.java b/src/main/java/com/jcraft/jsch/SftpATTRS.java similarity index 82% rename from src/com/jcraft/jsch/SftpATTRS.java rename to src/main/java/com/jcraft/jsch/SftpATTRS.java index a779e69..0d58f1b 100644 --- a/src/com/jcraft/jsch/SftpATTRS.java +++ b/src/main/java/com/jcraft/jsch/SftpATTRS.java @@ -46,6 +46,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ... more extended data (extended_type - extended_data pairs), so that number of pairs equals extended_count */ +/** + *SftpATTRS class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class SftpATTRS { static final int S_ISUID = 04000; // set user ID on execution @@ -69,6 +75,11 @@ public class SftpATTRS { private static final int pmask = 0xFFF; + /** + *getPermissionsString.
+ * + * @return a {@link java.lang.String} object. + */ public String getPermissionsString() { StringBuffer buf = new StringBuffer(10); @@ -107,20 +118,35 @@ public String getPermissionsString() { return (buf.toString()); } + /** + *getAtimeString.
+ * + * @return a {@link java.lang.String} object. + */ public String getAtimeString(){ SimpleDateFormat locale=new SimpleDateFormat(); return (locale.format(new Date(atime))); } + /** + *getMtimeString.
+ * + * @return a {@link java.lang.String} object. + */ public String getMtimeString(){ Date date= new Date(((long)mtime)*1000); return (date.toString()); } + /** ConstantSSH_FILEXFER_ATTR_SIZE=0x00000001 */
public static final int SSH_FILEXFER_ATTR_SIZE= 0x00000001;
+ /** Constant SSH_FILEXFER_ATTR_UIDGID=0x00000002 */
public static final int SSH_FILEXFER_ATTR_UIDGID= 0x00000002;
+ /** Constant SSH_FILEXFER_ATTR_PERMISSIONS=0x00000004 */
public static final int SSH_FILEXFER_ATTR_PERMISSIONS= 0x00000004;
+ /** Constant SSH_FILEXFER_ATTR_ACMODTIME=0x00000008 */
public static final int SSH_FILEXFER_ATTR_ACMODTIME= 0x00000008;
+ /** Constant SSH_FILEXFER_ATTR_EXTENDED=0x80000000 */
public static final int SSH_FILEXFER_ATTR_EXTENDED= 0x80000000;
static final int S_IFDIR=0x4000;
@@ -211,43 +237,120 @@ void dump(Buffer buf){
void setFLAGS(int flags){
this.flags=flags;
}
+ /**
+ * setSIZE.
+ * + * @param size a long. + */ public void setSIZE(long size){ flags|=SSH_FILEXFER_ATTR_SIZE; this.size=size; } + /** + *setUIDGID.
+ * + * @param uid a int. + * @param gid a int. + */ public void setUIDGID(int uid, int gid){ flags|=SSH_FILEXFER_ATTR_UIDGID; this.uid=uid; this.gid=gid; } + /** + *setACMODTIME.
+ * + * @param atime a int. + * @param mtime a int. + */ public void setACMODTIME(int atime, int mtime){ flags|=SSH_FILEXFER_ATTR_ACMODTIME; this.atime=atime; this.mtime=mtime; } + /** + *setPERMISSIONS.
+ * + * @param permissions a int. + */ public void setPERMISSIONS(int permissions){ flags|=SSH_FILEXFER_ATTR_PERMISSIONS; permissions=(this.permissions&~pmask)|(permissions&pmask); this.permissions=permissions; } + /** + *isDir.
+ * + * @return a boolean. + */ public boolean isDir(){ return ((flags&SSH_FILEXFER_ATTR_PERMISSIONS)!=0 && ((permissions&S_IFDIR)==S_IFDIR)); } + /** + *isLink.
+ * + * @return a boolean. + */ public boolean isLink(){ return ((flags&SSH_FILEXFER_ATTR_PERMISSIONS)!=0 && ((permissions&S_IFLNK)==S_IFLNK)); } + /** + *Getter for the field flags.
Getter for the field size.
getUId.
+ * + * @return a int. + */ public int getUId() { return uid; } + /** + *getGId.
+ * + * @return a int. + */ public int getGId() { return gid; } + /** + *Getter for the field permissions.
getATime.
+ * + * @return a int. + */ public int getATime() { return atime; } + /** + *getMTime.
+ * + * @return a int. + */ public int getMTime() { return mtime; } + /** + *Getter for the field extended.
toString.
+ * + * @return a {@link java.lang.String} object. + */ public String toString() { return (getPermissionsString()+" "+getUId()+" "+getGId()+" "+getSize()+" "+getMtimeString()); } diff --git a/src/com/jcraft/jsch/SftpException.java b/src/main/java/com/jcraft/jsch/SftpException.java similarity index 73% rename from src/com/jcraft/jsch/SftpException.java rename to src/main/java/com/jcraft/jsch/SftpException.java index 8df0e5d..dfef24e 100644 --- a/src/com/jcraft/jsch/SftpException.java +++ b/src/main/java/com/jcraft/jsch/SftpException.java @@ -29,22 +29,54 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *SftpException class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class SftpException extends Exception{ - //private static final long serialVersionUID=-5616888495583253811L; + + /** + * The ID of this exception + */ public int id; private Throwable cause=null; + /** + *Constructor for SftpException.
+ * + * @param id a int. + * @param message a {@link java.lang.String} object. + */ public SftpException (int id, String message) { super(message); this.id=id; } + /** + *Constructor for SftpException.
+ * + * @param id a int. + * @param message a {@link java.lang.String} object. + * @param e a {@link java.lang.Throwable} object. + */ public SftpException (int id, String message, Throwable e) { super(message); this.id=id; this.cause=e; } + /** + *toString.
+ * + * @return a {@link java.lang.String} object. + */ public String toString(){ return id+": "+getMessage(); } + /** + *Getter for the field cause.
SftpProgressMonitor interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface SftpProgressMonitor{ + /** ConstantPUT=0 */
public static final int PUT=0;
+ /** Constant GET=1 */
public static final int GET=1;
+ /**
+ * init.
+ * + * @param op a int. + * @param src a {@link java.lang.String} object. + * @param dest a {@link java.lang.String} object. + * @param max a long. + */ void init(int op, String src, String dest, long max); + /** + *count.
+ * + * @param count a long. + * @return a boolean. + */ boolean count(long count); + /** + *end.
+ */ void end(); } diff --git a/src/com/jcraft/jsch/SignatureDSA.java b/src/main/java/com/jcraft/jsch/SignatureDSA.java similarity index 65% rename from src/com/jcraft/jsch/SignatureDSA.java rename to src/main/java/com/jcraft/jsch/SignatureDSA.java index f9068eb..55dfb90 100644 --- a/src/com/jcraft/jsch/SignatureDSA.java +++ b/src/main/java/com/jcraft/jsch/SignatureDSA.java @@ -29,11 +29,60 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *SignatureDSA interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface SignatureDSA{ + /** + *init.
+ * + * @throws java.lang.Exception if any. + * @since 0.1.53 + */ void init() throws Exception; + /** + *setPubKey.
+ * + * @param y an array of byte. + * @param p an array of byte. + * @param q an array of byte. + * @param g an array of byte. + * @throws java.lang.Exception if any. + */ void setPubKey(byte[] y, byte[] p, byte[] q, byte[] g) throws Exception; + /** + *setPrvKey.
+ * + * @param x an array of byte. + * @param p an array of byte. + * @param q an array of byte. + * @param g an array of byte. + * @throws java.lang.Exception if any. + */ void setPrvKey(byte[] x, byte[] p, byte[] q, byte[] g) throws Exception; + /** + *update.
+ * + * @param H an array of byte. + * @throws java.lang.Exception if any. + */ void update(byte[] H) throws Exception; + /** + *verify.
+ * + * @param sig an array of byte. + * @return a boolean. + * @throws java.lang.Exception if any. + */ boolean verify(byte[] sig) throws Exception; + /** + *sign.
+ * + * @return an array of byte. + * @throws java.lang.Exception if any. + */ byte[] sign() throws Exception; } diff --git a/src/com/jcraft/jsch/SignatureRSA.java b/src/main/java/com/jcraft/jsch/SignatureRSA.java similarity index 67% rename from src/com/jcraft/jsch/SignatureRSA.java rename to src/main/java/com/jcraft/jsch/SignatureRSA.java index e1e8ed0..c61d681 100644 --- a/src/com/jcraft/jsch/SignatureRSA.java +++ b/src/main/java/com/jcraft/jsch/SignatureRSA.java @@ -29,11 +29,56 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *SignatureRSA interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface SignatureRSA{ + /** + *init.
+ * + * @throws java.lang.Exception if any. + * @since 0.1.53 + */ void init() throws Exception; + /** + *setPubKey.
+ * + * @param e an array of byte. + * @param n an array of byte. + * @throws java.lang.Exception if any. + */ void setPubKey(byte[] e, byte[] n) throws Exception; + /** + *setPrvKey.
+ * + * @param d an array of byte. + * @param n an array of byte. + * @throws java.lang.Exception if any. + */ void setPrvKey(byte[] d, byte[] n) throws Exception; + /** + *update.
+ * + * @param H an array of byte. + * @throws java.lang.Exception if any. + */ void update(byte[] H) throws Exception; + /** + *verify.
+ * + * @param sig an array of byte. + * @return a boolean. + * @throws java.lang.Exception if any. + */ boolean verify(byte[] sig) throws Exception; + /** + *sign.
+ * + * @return an array of byte. + * @throws java.lang.Exception if any. + */ byte[] sign() throws Exception; } diff --git a/src/com/jcraft/jsch/SocketFactory.java b/src/main/java/com/jcraft/jsch/SocketFactory.java similarity index 70% rename from src/com/jcraft/jsch/SocketFactory.java rename to src/main/java/com/jcraft/jsch/SocketFactory.java index 70f922d..4d4674f 100644 --- a/src/com/jcraft/jsch/SocketFactory.java +++ b/src/main/java/com/jcraft/jsch/SocketFactory.java @@ -32,9 +32,38 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.net.*; import java.io.*; +/** + *SocketFactory interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface SocketFactory{ + /** + *createSocket.
+ * + * @param host a {@link java.lang.String} object. + * @param port a int. + * @return a {@link java.net.Socket} object. + * @throws java.io.IOException if any. + * @throws java.net.UnknownHostException if any. + */ public Socket createSocket(String host, int port)throws IOException, UnknownHostException; + /** + *getInputStream.
+ * + * @param socket a {@link java.net.Socket} object. + * @return a {@link java.io.InputStream} object. + * @throws java.io.IOException if any. + */ public InputStream getInputStream(Socket socket)throws IOException; + /** + *getOutputStream.
+ * + * @param socket a {@link java.net.Socket} object. + * @return a {@link java.io.OutputStream} object. + * @throws java.io.IOException if any. + */ public OutputStream getOutputStream(Socket socket)throws IOException; } diff --git a/src/com/jcraft/jsch/UIKeyboardInteractive.java b/src/main/java/com/jcraft/jsch/UIKeyboardInteractive.java similarity index 76% rename from src/com/jcraft/jsch/UIKeyboardInteractive.java rename to src/main/java/com/jcraft/jsch/UIKeyboardInteractive.java index 6ff281d..24ee364 100644 --- a/src/com/jcraft/jsch/UIKeyboardInteractive.java +++ b/src/main/java/com/jcraft/jsch/UIKeyboardInteractive.java @@ -29,7 +29,23 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *UIKeyboardInteractive interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface UIKeyboardInteractive{ + /** + *promptKeyboardInteractive.
+ * + * @param destination a {@link java.lang.String} object. + * @param name a {@link java.lang.String} object. + * @param instruction a {@link java.lang.String} object. + * @param prompt an array of {@link java.lang.String} objects. + * @param echo an array of boolean. + * @return an array of {@link java.lang.String} objects. + */ String[] promptKeyboardInteractive(String destination, String name, String instruction, diff --git a/src/com/jcraft/jsch/UserAuth.java b/src/main/java/com/jcraft/jsch/UserAuth.java similarity index 73% rename from src/com/jcraft/jsch/UserAuth.java rename to src/main/java/com/jcraft/jsch/UserAuth.java index c9a990a..0208294 100644 --- a/src/com/jcraft/jsch/UserAuth.java +++ b/src/main/java/com/jcraft/jsch/UserAuth.java @@ -29,20 +29,55 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *Abstract UserAuth class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public abstract class UserAuth{ + /** ConstantSSH_MSG_USERAUTH_REQUEST=50 */
protected static final int SSH_MSG_USERAUTH_REQUEST= 50;
+ /** Constant SSH_MSG_USERAUTH_FAILURE=51 */
protected static final int SSH_MSG_USERAUTH_FAILURE= 51;
+ /** Constant SSH_MSG_USERAUTH_SUCCESS=52 */
protected static final int SSH_MSG_USERAUTH_SUCCESS= 52;
+ /** Constant SSH_MSG_USERAUTH_BANNER=53 */
protected static final int SSH_MSG_USERAUTH_BANNER= 53;
+ /** Constant SSH_MSG_USERAUTH_INFO_REQUEST=60 */
protected static final int SSH_MSG_USERAUTH_INFO_REQUEST= 60;
+ /** Constant SSH_MSG_USERAUTH_INFO_RESPONSE=61 */
protected static final int SSH_MSG_USERAUTH_INFO_RESPONSE= 61;
+ /** Constant SSH_MSG_USERAUTH_PK_OK=60 */
protected static final int SSH_MSG_USERAUTH_PK_OK= 60;
+ /**
+ * SSH user information
+ */
protected UserInfo userinfo;
+
+ /**
+ * Packet to be sent
+ */
protected Packet packet;
+
+ /**
+ * Buffer of input from the Packet
+ */
protected Buffer buf;
+
+ /**
+ * Username for this SSH session
+ */
protected String username;
+ /**
+ * start.
+ * + * @param session a {@link com.jcraft.jsch.Session} object. + * @return a boolean. + * @throws java.lang.Exception if any. + */ public boolean start(Session session) throws Exception{ this.userinfo=session.getUserInfo(); this.packet=session.packet; diff --git a/src/com/jcraft/jsch/UserAuthGSSAPIWithMIC.java b/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMIC.java similarity index 97% rename from src/com/jcraft/jsch/UserAuthGSSAPIWithMIC.java rename to src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMIC.java index 6b20713..6648705 100644 --- a/src/com/jcraft/jsch/UserAuthGSSAPIWithMIC.java +++ b/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMIC.java @@ -29,6 +29,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING package com.jcraft.jsch; +/** + *UserAuthGSSAPIWithMIC class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class UserAuthGSSAPIWithMIC extends UserAuth { private static final int SSH_MSG_USERAUTH_GSSAPI_RESPONSE= 60; private static final int SSH_MSG_USERAUTH_GSSAPI_TOKEN= 61; @@ -48,6 +54,7 @@ public class UserAuthGSSAPIWithMIC extends UserAuth { "gssapi-with-mic.krb5" }; + @Override public boolean start(Session session)throws Exception{ super.start(session); diff --git a/src/com/jcraft/jsch/UserAuthKeyboardInteractive.java b/src/main/java/com/jcraft/jsch/UserAuthKeyboardInteractive.java similarity index 99% rename from src/com/jcraft/jsch/UserAuthKeyboardInteractive.java rename to src/main/java/com/jcraft/jsch/UserAuthKeyboardInteractive.java index 0334fb2..7ccf6d4 100644 --- a/src/com/jcraft/jsch/UserAuthKeyboardInteractive.java +++ b/src/main/java/com/jcraft/jsch/UserAuthKeyboardInteractive.java @@ -30,6 +30,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; class UserAuthKeyboardInteractive extends UserAuth{ + @Override public boolean start(Session session) throws Exception{ super.start(session); diff --git a/src/com/jcraft/jsch/UserAuthNone.java b/src/main/java/com/jcraft/jsch/UserAuthNone.java similarity index 99% rename from src/com/jcraft/jsch/UserAuthNone.java rename to src/main/java/com/jcraft/jsch/UserAuthNone.java index c5cacd5..59dcdba 100644 --- a/src/com/jcraft/jsch/UserAuthNone.java +++ b/src/main/java/com/jcraft/jsch/UserAuthNone.java @@ -33,6 +33,7 @@ class UserAuthNone extends UserAuth{ private static final int SSH_MSG_SERVICE_ACCEPT= 6; private String methods=null; + @Override public boolean start(Session session) throws Exception{ super.start(session); diff --git a/src/com/jcraft/jsch/UserAuthPassword.java b/src/main/java/com/jcraft/jsch/UserAuthPassword.java similarity index 99% rename from src/com/jcraft/jsch/UserAuthPassword.java rename to src/main/java/com/jcraft/jsch/UserAuthPassword.java index 41b499a..aeb790e 100644 --- a/src/com/jcraft/jsch/UserAuthPassword.java +++ b/src/main/java/com/jcraft/jsch/UserAuthPassword.java @@ -32,6 +32,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING class UserAuthPassword extends UserAuth{ private final int SSH_MSG_USERAUTH_PASSWD_CHANGEREQ=60; + @Override public boolean start(Session session) throws Exception{ super.start(session); diff --git a/src/com/jcraft/jsch/UserAuthPublicKey.java b/src/main/java/com/jcraft/jsch/UserAuthPublicKey.java similarity index 99% rename from src/com/jcraft/jsch/UserAuthPublicKey.java rename to src/main/java/com/jcraft/jsch/UserAuthPublicKey.java index b5866ab..77425d4 100644 --- a/src/com/jcraft/jsch/UserAuthPublicKey.java +++ b/src/main/java/com/jcraft/jsch/UserAuthPublicKey.java @@ -33,6 +33,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING class UserAuthPublicKey extends UserAuth{ + @Override public boolean start(Session session) throws Exception{ super.start(session); diff --git a/src/com/jcraft/jsch/UserInfo.java b/src/main/java/com/jcraft/jsch/UserInfo.java similarity index 69% rename from src/com/jcraft/jsch/UserInfo.java rename to src/main/java/com/jcraft/jsch/UserInfo.java index 6939f22..239e1eb 100644 --- a/src/com/jcraft/jsch/UserInfo.java +++ b/src/main/java/com/jcraft/jsch/UserInfo.java @@ -29,11 +29,50 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package com.jcraft.jsch; +/** + *UserInfo interface.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public interface UserInfo{ + /** + *getPassphrase.
+ * + * @return a {@link java.lang.String} object. + */ String getPassphrase(); + /** + *getPassword.
+ * + * @return a {@link java.lang.String} object. + */ String getPassword(); + /** + *promptPassword.
+ * + * @param message a {@link java.lang.String} object. + * @return a boolean. + */ boolean promptPassword(String message); + /** + *promptPassphrase.
+ * + * @param message a {@link java.lang.String} object. + * @return a boolean. + */ boolean promptPassphrase(String message); + /** + *promptYesNo.
+ * + * @param message a {@link java.lang.String} object. + * @return a boolean. + */ boolean promptYesNo(String message); + /** + *showMessage.
+ * + * @param message a {@link java.lang.String} object. + */ void showMessage(String message); } diff --git a/src/com/jcraft/jsch/Util.java b/src/main/java/com/jcraft/jsch/Util.java similarity index 100% rename from src/com/jcraft/jsch/Util.java rename to src/main/java/com/jcraft/jsch/Util.java diff --git a/src/com/jcraft/jsch/jce/AES128CBC.java b/src/main/java/com/jcraft/jsch/jce/AES128CBC.java similarity index 85% rename from src/com/jcraft/jsch/jce/AES128CBC.java rename to src/main/java/com/jcraft/jsch/jce/AES128CBC.java index d894a7c..80fac7e 100644 --- a/src/com/jcraft/jsch/jce/AES128CBC.java +++ b/src/main/java/com/jcraft/jsch/jce/AES128CBC.java @@ -32,12 +32,36 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import com.jcraft.jsch.Cipher; import javax.crypto.spec.*; +/** + *AES128CBC class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class AES128CBC implements Cipher{ private static final int ivsize=16; private static final int bsize=16; private javax.crypto.Cipher cipher; + /** + *getIVSize.
+ * + * @return a int. + */ public int getIVSize(){return ivsize;} + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return bsize;} + /** + *init.
+ * + * @param mode a int. + * @param key an array of byte. + * @param iv an array of byte. + * @throws java.lang.Exception if any. + */ public void init(int mode, byte[] key, byte[] iv) throws Exception{ String pad="NoPadding"; byte[] tmp; @@ -65,9 +89,15 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception{ throw e; } } + @Override public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ cipher.update(foo, s1, len, bar, s2); } + /** + *isCBC.
+ * + * @return a boolean. + */ public boolean isCBC(){return true; } } diff --git a/src/com/jcraft/jsch/jce/AES128CTR.java b/src/main/java/com/jcraft/jsch/jce/AES128CTR.java similarity index 85% rename from src/com/jcraft/jsch/jce/AES128CTR.java rename to src/main/java/com/jcraft/jsch/jce/AES128CTR.java index 55c8715..81ded3a 100644 --- a/src/com/jcraft/jsch/jce/AES128CTR.java +++ b/src/main/java/com/jcraft/jsch/jce/AES128CTR.java @@ -32,12 +32,36 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import com.jcraft.jsch.Cipher; import javax.crypto.spec.*; +/** + *AES128CTR class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class AES128CTR implements Cipher{ private static final int ivsize=16; private static final int bsize=16; private javax.crypto.Cipher cipher; + /** + *getIVSize.
+ * + * @return a int. + */ public int getIVSize(){return ivsize;} + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return bsize;} + /** + *init.
+ * + * @param mode a int. + * @param key an array of byte. + * @param iv an array of byte. + * @throws java.lang.Exception if any. + */ public void init(int mode, byte[] key, byte[] iv) throws Exception{ String pad="NoPadding"; byte[] tmp; @@ -65,9 +89,15 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception{ throw e; } } + @Override public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ cipher.update(foo, s1, len, bar, s2); } + /** + *isCBC.
+ * + * @return a boolean. + */ public boolean isCBC(){return false; } } diff --git a/src/com/jcraft/jsch/jce/AES192CBC.java b/src/main/java/com/jcraft/jsch/jce/AES192CBC.java similarity index 85% rename from src/com/jcraft/jsch/jce/AES192CBC.java rename to src/main/java/com/jcraft/jsch/jce/AES192CBC.java index 850d207..a7ff128 100644 --- a/src/com/jcraft/jsch/jce/AES192CBC.java +++ b/src/main/java/com/jcraft/jsch/jce/AES192CBC.java @@ -32,12 +32,36 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import com.jcraft.jsch.Cipher; import javax.crypto.spec.*; +/** + *AES192CBC class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class AES192CBC implements Cipher{ private static final int ivsize=16; private static final int bsize=24; private javax.crypto.Cipher cipher; + /** + *getIVSize.
+ * + * @return a int. + */ public int getIVSize(){return ivsize;} + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return bsize;} + /** + *init.
+ * + * @param mode a int. + * @param key an array of byte. + * @param iv an array of byte. + * @throws java.lang.Exception if any. + */ public void init(int mode, byte[] key, byte[] iv) throws Exception{ String pad="NoPadding"; byte[] tmp; @@ -64,8 +88,14 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception{ throw e; } } + @Override public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ cipher.update(foo, s1, len, bar, s2); } + /** + *isCBC.
+ * + * @return a boolean. + */ public boolean isCBC(){return true; } } diff --git a/src/com/jcraft/jsch/jce/AES192CTR.java b/src/main/java/com/jcraft/jsch/jce/AES192CTR.java similarity index 85% rename from src/com/jcraft/jsch/jce/AES192CTR.java rename to src/main/java/com/jcraft/jsch/jce/AES192CTR.java index fe7a310..c441771 100644 --- a/src/com/jcraft/jsch/jce/AES192CTR.java +++ b/src/main/java/com/jcraft/jsch/jce/AES192CTR.java @@ -32,12 +32,36 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import com.jcraft.jsch.Cipher; import javax.crypto.spec.*; +/** + *AES192CTR class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class AES192CTR implements Cipher{ private static final int ivsize=16; private static final int bsize=24; private javax.crypto.Cipher cipher; + /** + *getIVSize.
+ * + * @return a int. + */ public int getIVSize(){return ivsize;} + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return bsize;} + /** + *init.
+ * + * @param mode a int. + * @param key an array of byte. + * @param iv an array of byte. + * @throws java.lang.Exception if any. + */ public void init(int mode, byte[] key, byte[] iv) throws Exception{ String pad="NoPadding"; byte[] tmp; @@ -64,8 +88,14 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception{ throw e; } } + @Override public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ cipher.update(foo, s1, len, bar, s2); } + /** + *isCBC.
+ * + * @return a boolean. + */ public boolean isCBC(){return false; } } diff --git a/src/com/jcraft/jsch/jce/AES256CBC.java b/src/main/java/com/jcraft/jsch/jce/AES256CBC.java similarity index 85% rename from src/com/jcraft/jsch/jce/AES256CBC.java rename to src/main/java/com/jcraft/jsch/jce/AES256CBC.java index 559b41e..b44df1e 100644 --- a/src/com/jcraft/jsch/jce/AES256CBC.java +++ b/src/main/java/com/jcraft/jsch/jce/AES256CBC.java @@ -32,12 +32,36 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import com.jcraft.jsch.Cipher; import javax.crypto.spec.*; +/** + *AES256CBC class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class AES256CBC implements Cipher{ private static final int ivsize=16; private static final int bsize=32; private javax.crypto.Cipher cipher; + /** + *getIVSize.
+ * + * @return a int. + */ public int getIVSize(){return ivsize;} + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return bsize;} + /** + *init.
+ * + * @param mode a int. + * @param key an array of byte. + * @param iv an array of byte. + * @throws java.lang.Exception if any. + */ public void init(int mode, byte[] key, byte[] iv) throws Exception{ String pad="NoPadding"; byte[] tmp; @@ -64,8 +88,14 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception{ throw e; } } + @Override public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ cipher.update(foo, s1, len, bar, s2); } + /** + *isCBC.
+ * + * @return a boolean. + */ public boolean isCBC(){return true; } } diff --git a/src/com/jcraft/jsch/jce/AES256CTR.java b/src/main/java/com/jcraft/jsch/jce/AES256CTR.java similarity index 85% rename from src/com/jcraft/jsch/jce/AES256CTR.java rename to src/main/java/com/jcraft/jsch/jce/AES256CTR.java index 5ff963e..52be3ca 100644 --- a/src/com/jcraft/jsch/jce/AES256CTR.java +++ b/src/main/java/com/jcraft/jsch/jce/AES256CTR.java @@ -32,12 +32,36 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import com.jcraft.jsch.Cipher; import javax.crypto.spec.*; +/** + *AES256CTR class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class AES256CTR implements Cipher{ private static final int ivsize=16; private static final int bsize=32; private javax.crypto.Cipher cipher; + /** + *getIVSize.
+ * + * @return a int. + */ public int getIVSize(){return ivsize;} + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return bsize;} + /** + *init.
+ * + * @param mode a int. + * @param key an array of byte. + * @param iv an array of byte. + * @throws java.lang.Exception if any. + */ public void init(int mode, byte[] key, byte[] iv) throws Exception{ String pad="NoPadding"; byte[] tmp; @@ -64,8 +88,14 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception{ throw e; } } + @Override public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ cipher.update(foo, s1, len, bar, s2); } + /** + *isCBC.
+ * + * @return a boolean. + */ public boolean isCBC(){return false; } } diff --git a/src/com/jcraft/jsch/jce/ARCFOUR.java b/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java similarity index 84% rename from src/com/jcraft/jsch/jce/ARCFOUR.java rename to src/main/java/com/jcraft/jsch/jce/ARCFOUR.java index 8f465f2..67a56b7 100644 --- a/src/com/jcraft/jsch/jce/ARCFOUR.java +++ b/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java @@ -33,12 +33,36 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import javax.crypto.*; import javax.crypto.spec.*; +/** + *ARCFOUR class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class ARCFOUR implements Cipher{ private static final int ivsize=8; private static final int bsize=16; private javax.crypto.Cipher cipher; + /** + *getIVSize.
+ * + * @return a int. + */ public int getIVSize(){return ivsize;} + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return bsize;} + /** + *init.
+ * + * @param mode a int. + * @param key an array of byte. + * @param iv an array of byte. + * @throws java.lang.Exception if any. + */ public void init(int mode, byte[] key, byte[] iv) throws Exception{ String pad="NoPadding"; byte[] tmp; @@ -61,8 +85,14 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception{ throw e; } } + @Override public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ cipher.update(foo, s1, len, bar, s2); } + /** + *isCBC.
+ * + * @return a boolean. + */ public boolean isCBC(){return false; } } diff --git a/src/com/jcraft/jsch/jce/ARCFOUR128.java b/src/main/java/com/jcraft/jsch/jce/ARCFOUR128.java similarity index 84% rename from src/com/jcraft/jsch/jce/ARCFOUR128.java rename to src/main/java/com/jcraft/jsch/jce/ARCFOUR128.java index 501ab35..ae469c5 100644 --- a/src/com/jcraft/jsch/jce/ARCFOUR128.java +++ b/src/main/java/com/jcraft/jsch/jce/ARCFOUR128.java @@ -33,13 +33,37 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import javax.crypto.*; import javax.crypto.spec.*; +/** + *ARCFOUR128 class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class ARCFOUR128 implements Cipher{ private static final int ivsize=8; private static final int bsize=16; private static final int skip=1536; private javax.crypto.Cipher cipher; + /** + *getIVSize.
+ * + * @return a int. + */ public int getIVSize(){return ivsize;} + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return bsize;} + /** + *init.
+ * + * @param mode a int. + * @param key an array of byte. + * @param iv an array of byte. + * @throws java.lang.Exception if any. + */ public void init(int mode, byte[] key, byte[] iv) throws Exception{ byte[] tmp; if(key.length>bsize){ @@ -64,8 +88,14 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception{ throw e; } } + @Override public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ cipher.update(foo, s1, len, bar, s2); } + /** + *isCBC.
+ * + * @return a boolean. + */ public boolean isCBC(){return false; } } diff --git a/src/com/jcraft/jsch/jce/ARCFOUR256.java b/src/main/java/com/jcraft/jsch/jce/ARCFOUR256.java similarity index 84% rename from src/com/jcraft/jsch/jce/ARCFOUR256.java rename to src/main/java/com/jcraft/jsch/jce/ARCFOUR256.java index c6bc6bc..14a99ee 100644 --- a/src/com/jcraft/jsch/jce/ARCFOUR256.java +++ b/src/main/java/com/jcraft/jsch/jce/ARCFOUR256.java @@ -33,13 +33,37 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import javax.crypto.*; import javax.crypto.spec.*; +/** + *ARCFOUR256 class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class ARCFOUR256 implements Cipher{ private static final int ivsize=8; private static final int bsize=32; private static final int skip=1536; private javax.crypto.Cipher cipher; + /** + *getIVSize.
+ * + * @return a int. + */ public int getIVSize(){return ivsize;} + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return bsize;} + /** + *init.
+ * + * @param mode a int. + * @param key an array of byte. + * @param iv an array of byte. + * @throws java.lang.Exception if any. + */ public void init(int mode, byte[] key, byte[] iv) throws Exception{ byte[] tmp; if(key.length>bsize){ @@ -64,8 +88,14 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception{ throw e; } } + @Override public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ cipher.update(foo, s1, len, bar, s2); } + /** + *isCBC.
+ * + * @return a boolean. + */ public boolean isCBC(){return false; } } diff --git a/src/com/jcraft/jsch/jce/BlowfishCBC.java b/src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java similarity index 85% rename from src/com/jcraft/jsch/jce/BlowfishCBC.java rename to src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java index 50fc271..d928403 100644 --- a/src/com/jcraft/jsch/jce/BlowfishCBC.java +++ b/src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java @@ -32,12 +32,36 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import com.jcraft.jsch.Cipher; import javax.crypto.spec.*; +/** + *BlowfishCBC class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class BlowfishCBC implements Cipher{ private static final int ivsize=8; private static final int bsize=16; private javax.crypto.Cipher cipher; + /** + *getIVSize.
+ * + * @return a int. + */ public int getIVSize(){return ivsize;} + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return bsize;} + /** + *init.
+ * + * @param mode a int. + * @param key an array of byte. + * @param iv an array of byte. + * @throws java.lang.Exception if any. + */ public void init(int mode, byte[] key, byte[] iv) throws Exception{ String pad="NoPadding"; // if(padding) pad="PKCS5Padding"; @@ -64,8 +88,14 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception{ throw e; } } + @Override public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ cipher.update(foo, s1, len, bar, s2); } + /** + *isCBC.
+ * + * @return a boolean. + */ public boolean isCBC(){return true; } } diff --git a/src/com/jcraft/jsch/jce/DH.java b/src/main/java/com/jcraft/jsch/jce/DH.java similarity index 83% rename from src/com/jcraft/jsch/jce/DH.java rename to src/main/java/com/jcraft/jsch/jce/DH.java index 19cddd8..d0f4568 100644 --- a/src/com/jcraft/jsch/jce/DH.java +++ b/src/main/java/com/jcraft/jsch/jce/DH.java @@ -34,6 +34,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import javax.crypto.*; import javax.crypto.spec.*; +/** + *DH class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class DH implements com.jcraft.jsch.DH{ BigInteger p; BigInteger g; @@ -45,12 +51,23 @@ public class DH implements com.jcraft.jsch.DH{ private KeyPairGenerator myKpairGen; private KeyAgreement myKeyAgree; + /** + *init.
+ * + * @throws java.lang.Exception if any. + */ public void init() throws Exception{ myKpairGen=KeyPairGenerator.getInstance("DH"); // myKpairGen=KeyPairGenerator.getInstance("DiffieHellman"); myKeyAgree=KeyAgreement.getInstance("DH"); // myKeyAgree=KeyAgreement.getInstance("DiffieHellman"); } + /** + *Getter for the field e.
getK.
+ * + * @return an array of byte. + * @throws java.lang.Exception if any. + */ public byte[] getK() throws Exception{ if(K==null){ KeyFactory myKeyFac=KeyFactory.getInstance("DH"); @@ -82,8 +105,23 @@ public byte[] getK() throws Exception{ } return K_array; } + /** + *Setter for the field p.
Setter for the field g.
Setter for the field f.
HMACMD5 class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class HMACMD5 implements MAC{ private static final String name="hmac-md5"; private static final int BSIZE=16; private Mac mac; + + @Override public int getBlockSize(){return BSIZE;}; + + @Override public void init(byte[] key) throws Exception{ if(key.length>BSIZE){ byte[] tmp=new byte[BSIZE]; @@ -51,6 +61,8 @@ public void init(byte[] key) throws Exception{ } private final byte[] tmp=new byte[4]; + + @Override public void update(int i){ tmp[0]=(byte)(i>>>24); tmp[1]=(byte)(i>>>16); @@ -58,9 +70,13 @@ public void update(int i){ tmp[3]=(byte)i; update(tmp, 0, 4); } + + @Override public void update(byte foo[], int s, int l){ mac.update(foo, s, l); } + + @Override public void doFinal(byte[] buf, int offset){ try{ mac.doFinal(buf, offset); @@ -69,6 +85,7 @@ public void doFinal(byte[] buf, int offset){ } } + @Override public String getName(){ return name; } diff --git a/src/com/jcraft/jsch/jce/HMACMD596.java b/src/main/java/com/jcraft/jsch/jce/HMACMD596.java similarity index 92% rename from src/com/jcraft/jsch/jce/HMACMD596.java rename to src/main/java/com/jcraft/jsch/jce/HMACMD596.java index 992b65c..9f0096d 100644 --- a/src/com/jcraft/jsch/jce/HMACMD596.java +++ b/src/main/java/com/jcraft/jsch/jce/HMACMD596.java @@ -33,11 +33,21 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import javax.crypto.*; import javax.crypto.spec.*; +/** + *HMACMD596 class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class HMACMD596 implements MAC{ private static final String name="hmac-md5-96"; private static final int bsize=12; private Mac mac; + + @Override public int getBlockSize(){return bsize;}; + + @Override public void init(byte[] key) throws Exception{ if(key.length>16){ byte[] tmp=new byte[16]; @@ -49,6 +59,8 @@ public void init(byte[] key) throws Exception{ mac.init(skey); } private final byte[] tmp=new byte[4]; + + @Override public void update(int i){ tmp[0]=(byte)(i>>>24); tmp[1]=(byte)(i>>>16); @@ -57,11 +69,14 @@ public void update(int i){ update(tmp, 0, 4); } + @Override public void update(byte foo[], int s, int l){ mac.update(foo, s, l); } private final byte[] _buf16=new byte[16]; + + @Override public void doFinal(byte[] buf, int offset){ try{ mac.doFinal(_buf16, 0); @@ -71,6 +86,7 @@ public void doFinal(byte[] buf, int offset){ System.arraycopy(_buf16, 0, buf, offset, 12); } + @Override public String getName(){ return name; } diff --git a/src/com/jcraft/jsch/jce/HMACSHA1.java b/src/main/java/com/jcraft/jsch/jce/HMACSHA1.java similarity index 92% rename from src/com/jcraft/jsch/jce/HMACSHA1.java rename to src/main/java/com/jcraft/jsch/jce/HMACSHA1.java index 9b80bb6..d9d3c27 100644 --- a/src/com/jcraft/jsch/jce/HMACSHA1.java +++ b/src/main/java/com/jcraft/jsch/jce/HMACSHA1.java @@ -33,11 +33,21 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import javax.crypto.*; import javax.crypto.spec.*; +/** + *HMACSHA1 class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class HMACSHA1 implements MAC{ private static final String name="hmac-sha1"; private static final int bsize=20; private Mac mac; + + @Override public int getBlockSize(){return bsize;}; + + @Override public void init(byte[] key) throws Exception{ if(key.length>bsize){ byte[] tmp=new byte[bsize]; @@ -49,6 +59,8 @@ public void init(byte[] key) throws Exception{ mac.init(skey); } private final byte[] tmp=new byte[4]; + + @Override public void update(int i){ tmp[0]=(byte)(i>>>24); tmp[1]=(byte)(i>>>16); @@ -57,10 +69,12 @@ public void update(int i){ update(tmp, 0, 4); } + @Override public void update(byte foo[], int s, int l){ mac.update(foo, s, l); } + @Override public void doFinal(byte[] buf, int offset){ try{ mac.doFinal(buf, offset); @@ -69,6 +83,7 @@ public void doFinal(byte[] buf, int offset){ } } + @Override public String getName(){ return name; } diff --git a/src/com/jcraft/jsch/jce/HMACSHA196.java b/src/main/java/com/jcraft/jsch/jce/HMACSHA196.java similarity index 92% rename from src/com/jcraft/jsch/jce/HMACSHA196.java rename to src/main/java/com/jcraft/jsch/jce/HMACSHA196.java index 0cc5731..4a395a7 100644 --- a/src/com/jcraft/jsch/jce/HMACSHA196.java +++ b/src/main/java/com/jcraft/jsch/jce/HMACSHA196.java @@ -33,11 +33,21 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import javax.crypto.*; import javax.crypto.spec.*; +/** + *HMACSHA196 class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class HMACSHA196 implements MAC{ private static final String name="hmac-sha1-96"; private static final int bsize=12; private Mac mac; + + @Override public int getBlockSize(){return bsize;}; + + @Override public void init(byte[] key) throws Exception{ if(key.length>20){ byte[] tmp=new byte[20]; @@ -49,6 +59,8 @@ public void init(byte[] key) throws Exception{ mac.init(skey); } private final byte[] tmp=new byte[4]; + + @Override public void update(int i){ tmp[0]=(byte)(i>>>24); tmp[1]=(byte)(i>>>16); @@ -56,11 +68,15 @@ public void update(int i){ tmp[3]=(byte)i; update(tmp, 0, 4); } + + @Override public void update(byte foo[], int s, int l){ mac.update(foo, s, l); } private final byte[] _buf20=new byte[20]; + + @Override public void doFinal(byte[] buf, int offset){ try{ mac.doFinal(_buf20, 0); @@ -70,6 +86,7 @@ public void doFinal(byte[] buf, int offset){ System.arraycopy(_buf20, 0, buf, offset, 12); } + @Override public String getName(){ return name; } diff --git a/src/com/jcraft/jsch/jce/KeyPairGenDSA.java b/src/main/java/com/jcraft/jsch/jce/KeyPairGenDSA.java similarity index 79% rename from src/com/jcraft/jsch/jce/KeyPairGenDSA.java rename to src/main/java/com/jcraft/jsch/jce/KeyPairGenDSA.java index 79e11c6..bc229f4 100644 --- a/src/com/jcraft/jsch/jce/KeyPairGenDSA.java +++ b/src/main/java/com/jcraft/jsch/jce/KeyPairGenDSA.java @@ -32,6 +32,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.security.*; import java.security.interfaces.*; +/** + *KeyPairGenDSA class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class KeyPairGenDSA implements com.jcraft.jsch.KeyPairGenDSA{ byte[] x; // private byte[] y; // public @@ -39,6 +45,7 @@ public class KeyPairGenDSA implements com.jcraft.jsch.KeyPairGenDSA{ byte[] q; byte[] g; + @Override public void init(int key_size) throws Exception{ KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA"); keyGen.initialize(key_size, new SecureRandom()); @@ -54,9 +61,34 @@ public void init(int key_size) throws Exception{ q=params.getQ().toByteArray(); g=params.getG().toByteArray(); } + /** + *Getter for the field x.
Getter for the field y.
Getter for the field p.
Getter for the field q.
Getter for the field g.
KeyPairGenRSA class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class KeyPairGenRSA implements com.jcraft.jsch.KeyPairGenRSA{ byte[] d; // private byte[] e; // public @@ -43,6 +49,7 @@ public class KeyPairGenRSA implements com.jcraft.jsch.KeyPairGenRSA{ byte[] p; // prime p byte[] q; // prime q + @Override public void init(int key_size) throws Exception{ KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA"); keyGen.initialize(key_size, new SecureRandom()); @@ -61,12 +68,52 @@ public void init(int key_size) throws Exception{ p=((RSAPrivateCrtKey)prvKey).getPrimeP().toByteArray(); q=((RSAPrivateCrtKey)prvKey).getPrimeQ().toByteArray(); } + /** + *Getter for the field d.
Getter for the field e.
Getter for the field n.
Getter for the field c.
getEP.
+ * + * @return an array of byte. + */ public byte[] getEP(){return ep;} + /** + *getEQ.
+ * + * @return an array of byte. + */ public byte[] getEQ(){return eq;} + /** + *Getter for the field p.
Getter for the field q.
MD5 class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class MD5 implements HASH{ MessageDigest md; + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return 16;} + /** + *init.
+ * + * @throws java.lang.Exception if any. + */ public void init() throws Exception{ try{ md=MessageDigest.getInstance("MD5"); } catch(Exception e){ System.err.println(e); } } + @Override public void update(byte[] foo, int start, int len) throws Exception{ md.update(foo, start, len); } + /** + *digest.
+ * + * @return an array of byte. + * @throws java.lang.Exception if any. + */ public byte[] digest() throws Exception{ return md.digest(); } diff --git a/src/com/jcraft/jsch/jce/Random.java b/src/main/java/com/jcraft/jsch/jce/Random.java similarity index 94% rename from src/com/jcraft/jsch/jce/Random.java rename to src/main/java/com/jcraft/jsch/jce/Random.java index e7eda20..11c0c24 100644 --- a/src/com/jcraft/jsch/jce/Random.java +++ b/src/main/java/com/jcraft/jsch/jce/Random.java @@ -31,9 +31,18 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.security.SecureRandom; +/** + *Random class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class Random implements com.jcraft.jsch.Random{ private byte[] tmp=new byte[16]; private SecureRandom random=null; + /** + *Constructor for Random.
+ */ public Random(){ // We hope that 'new SecureRandom()' will use NativePRNG algorithm @@ -66,6 +75,7 @@ public Random(){ } */ } + @Override public void fill(byte[] foo, int start, int len){ /* // This case will not become true in our usage. diff --git a/src/com/jcraft/jsch/jce/SHA1.java b/src/main/java/com/jcraft/jsch/jce/SHA1.java similarity index 84% rename from src/com/jcraft/jsch/jce/SHA1.java rename to src/main/java/com/jcraft/jsch/jce/SHA1.java index b1c571a..bac288e 100644 --- a/src/com/jcraft/jsch/jce/SHA1.java +++ b/src/main/java/com/jcraft/jsch/jce/SHA1.java @@ -33,18 +33,41 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.security.*; +/** + *SHA1 class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class SHA1 implements HASH{ MessageDigest md; + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return 20;} + /** + *init.
+ * + * @throws java.lang.Exception if any. + */ public void init() throws Exception{ try{ md=MessageDigest.getInstance("SHA-1"); } catch(Exception e){ System.err.println(e); } } + @Override public void update(byte[] foo, int start, int len) throws Exception{ md.update(foo, start, len); } + /** + *digest.
+ * + * @return an array of byte. + * @throws java.lang.Exception if any. + */ public byte[] digest() throws Exception{ return md.digest(); } diff --git a/src/com/jcraft/jsch/jce/SignatureDSA.java b/src/main/java/com/jcraft/jsch/jce/SignatureDSA.java similarity index 84% rename from src/com/jcraft/jsch/jce/SignatureDSA.java rename to src/main/java/com/jcraft/jsch/jce/SignatureDSA.java index b33fb9b..476e6ec 100644 --- a/src/com/jcraft/jsch/jce/SignatureDSA.java +++ b/src/main/java/com/jcraft/jsch/jce/SignatureDSA.java @@ -33,15 +33,35 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.security.*; import java.security.spec.*; +/** + *SignatureDSA class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class SignatureDSA implements com.jcraft.jsch.SignatureDSA{ java.security.Signature signature; KeyFactory keyFactory; + /** + *init.
+ * + * @throws java.lang.Exception if any. + */ public void init() throws Exception{ signature=java.security.Signature.getInstance("SHA1withDSA"); keyFactory=KeyFactory.getInstance("DSA"); } + /** + *setPubKey.
+ * + * @param y an array of byte. + * @param p an array of byte. + * @param q an array of byte. + * @param g an array of byte. + * @throws java.lang.Exception if any. + */ public void setPubKey(byte[] y, byte[] p, byte[] q, byte[] g) throws Exception{ DSAPublicKeySpec dsaPubKeySpec = new DSAPublicKeySpec(new BigInteger(y), @@ -51,6 +71,15 @@ public void setPubKey(byte[] y, byte[] p, byte[] q, byte[] g) throws Exception{ PublicKey pubKey=keyFactory.generatePublic(dsaPubKeySpec); signature.initVerify(pubKey); } + /** + *setPrvKey.
+ * + * @param x an array of byte. + * @param p an array of byte. + * @param q an array of byte. + * @param g an array of byte. + * @throws java.lang.Exception if any. + */ public void setPrvKey(byte[] x, byte[] p, byte[] q, byte[] g) throws Exception{ DSAPrivateKeySpec dsaPrivKeySpec = new DSAPrivateKeySpec(new BigInteger(x), @@ -60,6 +89,12 @@ public void setPrvKey(byte[] x, byte[] p, byte[] q, byte[] g) throws Exception{ PrivateKey prvKey = keyFactory.generatePrivate(dsaPrivKeySpec); signature.initSign(prvKey); } + /** + *sign.
+ * + * @return an array of byte. + * @throws java.lang.Exception if any. + */ public byte[] sign() throws Exception{ byte[] sig=signature.sign(); /* @@ -99,9 +134,22 @@ public byte[] sign() throws Exception{ return result; } + /** + *update.
+ * + * @param foo an array of byte. + * @throws java.lang.Exception if any. + */ public void update(byte[] foo) throws Exception{ signature.update(foo); } + /** + *verify.
+ * + * @param sig an array of byte. + * @return a boolean. + * @throws java.lang.Exception if any. + */ public boolean verify(byte[] sig) throws Exception{ int i=0; int j=0; diff --git a/src/com/jcraft/jsch/jce/SignatureRSA.java b/src/main/java/com/jcraft/jsch/jce/SignatureRSA.java similarity index 79% rename from src/com/jcraft/jsch/jce/SignatureRSA.java rename to src/main/java/com/jcraft/jsch/jce/SignatureRSA.java index 1e344b9..2cd6426 100644 --- a/src/com/jcraft/jsch/jce/SignatureRSA.java +++ b/src/main/java/com/jcraft/jsch/jce/SignatureRSA.java @@ -33,15 +33,33 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.security.*; import java.security.spec.*; +/** + *SignatureRSA class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class SignatureRSA implements com.jcraft.jsch.SignatureRSA{ java.security.Signature signature; KeyFactory keyFactory; + /** + *init.
+ * + * @throws java.lang.Exception if any. + */ public void init() throws Exception{ signature=java.security.Signature.getInstance("SHA1withRSA"); keyFactory=KeyFactory.getInstance("RSA"); } + /** + *setPubKey.
+ * + * @param e an array of byte. + * @param n an array of byte. + * @throws java.lang.Exception if any. + */ public void setPubKey(byte[] e, byte[] n) throws Exception{ RSAPublicKeySpec rsaPubKeySpec = new RSAPublicKeySpec(new BigInteger(n), @@ -49,6 +67,13 @@ public void setPubKey(byte[] e, byte[] n) throws Exception{ PublicKey pubKey=keyFactory.generatePublic(rsaPubKeySpec); signature.initVerify(pubKey); } + /** + *setPrvKey.
+ * + * @param d an array of byte. + * @param n an array of byte. + * @throws java.lang.Exception if any. + */ public void setPrvKey(byte[] d, byte[] n) throws Exception{ RSAPrivateKeySpec rsaPrivKeySpec = new RSAPrivateKeySpec(new BigInteger(n), @@ -56,13 +81,32 @@ public void setPrvKey(byte[] d, byte[] n) throws Exception{ PrivateKey prvKey = keyFactory.generatePrivate(rsaPrivKeySpec); signature.initSign(prvKey); } + /** + *sign.
+ * + * @return an array of byte. + * @throws java.lang.Exception if any. + */ public byte[] sign() throws Exception{ byte[] sig=signature.sign(); return sig; } + /** + *update.
+ * + * @param foo an array of byte. + * @throws java.lang.Exception if any. + */ public void update(byte[] foo) throws Exception{ signature.update(foo); } + /** + *verify.
+ * + * @param sig an array of byte. + * @return a boolean. + * @throws java.lang.Exception if any. + */ public boolean verify(byte[] sig) throws Exception{ int i=0; int j=0; diff --git a/src/com/jcraft/jsch/jce/TripleDESCBC.java b/src/main/java/com/jcraft/jsch/jce/TripleDESCBC.java similarity index 86% rename from src/com/jcraft/jsch/jce/TripleDESCBC.java rename to src/main/java/com/jcraft/jsch/jce/TripleDESCBC.java index a5ada9c..97fded2 100644 --- a/src/com/jcraft/jsch/jce/TripleDESCBC.java +++ b/src/main/java/com/jcraft/jsch/jce/TripleDESCBC.java @@ -33,12 +33,36 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import javax.crypto.*; import javax.crypto.spec.*; +/** + *TripleDESCBC class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class TripleDESCBC implements Cipher{ private static final int ivsize=8; private static final int bsize=24; private javax.crypto.Cipher cipher; + /** + *getIVSize.
+ * + * @return a int. + */ public int getIVSize(){return ivsize;} + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return bsize;} + /** + *init.
+ * + * @param mode a int. + * @param key an array of byte. + * @param iv an array of byte. + * @throws java.lang.Exception if any. + */ public void init(int mode, byte[] key, byte[] iv) throws Exception{ String pad="NoPadding"; //if(padding) pad="PKCS5Padding"; @@ -77,8 +101,14 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception{ throw e; } } + @Override public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ cipher.update(foo, s1, len, bar, s2); } + /** + *isCBC.
+ * + * @return a boolean. + */ public boolean isCBC(){return true; } } diff --git a/src/com/jcraft/jsch/jce/TripleDESCTR.java b/src/main/java/com/jcraft/jsch/jce/TripleDESCTR.java similarity index 86% rename from src/com/jcraft/jsch/jce/TripleDESCTR.java rename to src/main/java/com/jcraft/jsch/jce/TripleDESCTR.java index d511852..4cea731 100644 --- a/src/com/jcraft/jsch/jce/TripleDESCTR.java +++ b/src/main/java/com/jcraft/jsch/jce/TripleDESCTR.java @@ -33,12 +33,36 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import javax.crypto.*; import javax.crypto.spec.*; +/** + *TripleDESCTR class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class TripleDESCTR implements Cipher{ private static final int ivsize=8; private static final int bsize=24; private javax.crypto.Cipher cipher; + /** + *getIVSize.
+ * + * @return a int. + */ public int getIVSize(){return ivsize;} + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return bsize;} + /** + *init.
+ * + * @param mode a int. + * @param key an array of byte. + * @param iv an array of byte. + * @throws java.lang.Exception if any. + */ public void init(int mode, byte[] key, byte[] iv) throws Exception{ String pad="NoPadding"; //if(padding) pad="PKCS5Padding"; @@ -77,8 +101,14 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception{ throw e; } } + @Override public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ cipher.update(foo, s1, len, bar, s2); } + /** + *isCBC.
+ * + * @return a boolean. + */ public boolean isCBC(){return false; } } diff --git a/src/com/jcraft/jsch/jcraft/Compression.java b/src/main/java/com/jcraft/jsch/jcraft/Compression.java similarity index 92% rename from src/com/jcraft/jsch/jcraft/Compression.java rename to src/main/java/com/jcraft/jsch/jcraft/Compression.java index d06976e..7da5e49 100644 --- a/src/com/jcraft/jsch/jcraft/Compression.java +++ b/src/main/java/com/jcraft/jsch/jcraft/Compression.java @@ -31,6 +31,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import com.jcraft.jzlib.*; import com.jcraft.jsch.*; +/** + *Compression class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class Compression implements com.jcraft.jsch.Compression { static private final int BUF_SIZE=4096; @@ -38,10 +44,14 @@ public class Compression implements com.jcraft.jsch.Compression { private ZStream stream; private byte[] tmpbuf=new byte[BUF_SIZE]; + /** + *Constructor for Compression.
+ */ public Compression(){ stream=new ZStream(); } + @Override public void init(int type, int level){ if(type==DEFLATER){ stream.deflateInit(level); @@ -72,6 +82,7 @@ static Compression getInflater(){ } */ + @Override public int compress(byte[] buf, int start, int len){ stream.next_in=buf; stream.next_in_index=start; @@ -99,6 +110,14 @@ public int compress(byte[] buf, int start, int len){ return outputlen; } + /** + *uncompress.
+ * + * @param buffer an array of byte. + * @param start a int. + * @param length an array of int. + * @return an array of byte. + */ public byte[] uncompress(byte[] buffer, int start, int[] length){ int inflated_end=0; diff --git a/src/com/jcraft/jsch/jcraft/HMAC.java b/src/main/java/com/jcraft/jsch/jcraft/HMAC.java similarity index 85% rename from src/com/jcraft/jsch/jcraft/HMAC.java rename to src/main/java/com/jcraft/jsch/jcraft/HMAC.java index 1610df1..0b30844 100644 --- a/src/com/jcraft/jsch/jcraft/HMAC.java +++ b/src/main/java/com/jcraft/jsch/jcraft/HMAC.java @@ -51,12 +51,28 @@ class HMAC{ private int bsize=0; + /** + *setH.
+ * + * @param md a {@link java.security.MessageDigest} object. + */ protected void setH(MessageDigest md){ this.md=md; bsize=md.getDigestLength(); } + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return bsize;}; + /** + *init.
+ * + * @param key an array of byte. + * @throws java.lang.Exception if any. + */ public void init(byte[] key) throws Exception{ if(key.length>bsize){ byte[] tmp=new byte[bsize]; @@ -85,6 +101,11 @@ public void init(byte[] key) throws Exception{ } private final byte[] tmp=new byte[4]; + /** + *update.
+ * + * @param i a int. + */ public void update(int i){ tmp[0]=(byte)(i>>>24); tmp[1]=(byte)(i>>>16); @@ -93,10 +114,23 @@ public void update(int i){ update(tmp, 0, 4); } + /** + *update.
+ * + * @param foo an array of byte. + * @param s a int. + * @param l a int. + */ public void update(byte foo[], int s, int l){ md.update(foo, s, l); } + /** + *doFinal.
+ * + * @param buf an array of byte. + * @param offset a int. + */ public void doFinal(byte[] buf, int offset){ byte[] result=md.digest(); md.update(k_opad, 0, B); diff --git a/src/com/jcraft/jsch/jcraft/HMACMD5.java b/src/main/java/com/jcraft/jsch/jcraft/HMACMD5.java similarity index 86% rename from src/com/jcraft/jsch/jcraft/HMACMD5.java rename to src/main/java/com/jcraft/jsch/jcraft/HMACMD5.java index 69bbe63..4784ea1 100644 --- a/src/com/jcraft/jsch/jcraft/HMACMD5.java +++ b/src/main/java/com/jcraft/jsch/jcraft/HMACMD5.java @@ -32,9 +32,18 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import com.jcraft.jsch.MAC; import java.security.*; +/** + *HMACMD5 class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class HMACMD5 extends HMAC implements MAC{ private static final String name="hmac-md5"; + /** + *Constructor for HMACMD5.
+ */ public HMACMD5(){ super(); MessageDigest md=null; @@ -45,6 +54,11 @@ public HMACMD5(){ setH(md); } + /** + *Getter for the field name.
HMACMD596 class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class HMACMD596 extends HMACMD5{ private static final String name="hmac-md5-96"; private static final int BSIZE=12; + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return BSIZE;}; private final byte[] _buf16=new byte[16]; + @Override public void doFinal(byte[] buf, int offset){ super.doFinal(_buf16, 0); System.arraycopy(_buf16, 0, buf, offset, BSIZE); } + /** + *Getter for the field name.
HMACSHA1 class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class HMACSHA1 extends HMAC implements MAC{ private static final String name="hmac-sha1"; + /** + *Constructor for HMACSHA1.
+ */ public HMACSHA1(){ super(); MessageDigest md=null; @@ -45,6 +54,11 @@ public HMACSHA1(){ setH(md); } + /** + *Getter for the field name.
HMACSHA196 class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class HMACSHA196 extends HMACSHA1{ private static final String name="hmac-sha1-96"; private static final int BSIZE=12; + /** + *getBlockSize.
+ * + * @return a int. + */ public int getBlockSize(){return BSIZE;}; private final byte[] _buf16=new byte[20]; + @Override public void doFinal(byte[] buf, int offset){ super.doFinal(_buf16, 0); System.arraycopy(_buf16, 0, buf, offset, BSIZE); } + /** + *Getter for the field name.
GSSContextKrb5 class.
+ * + * @author Atsuhiko Yamanaka + * @version $Id: $Id + */ public class GSSContextKrb5 implements com.jcraft.jsch.GSSContext{ private static final String pUseSubjectCredsOnly = @@ -49,6 +55,7 @@ public class GSSContextKrb5 implements com.jcraft.jsch.GSSContext{ getSystemProperty(pUseSubjectCredsOnly); private GSSContext context=null; + @Override public void create(String user, String host) throws JSchException{ try{ // RFC 1964 @@ -111,10 +118,16 @@ public void create(String user, String host) throws JSchException{ } } + /** + *isEstablished.
+ * + * @return a boolean. + */ public boolean isEstablished(){ return context.isEstablished(); } + @Override public byte[] init(byte[] token, int s, int l) throws JSchException { try{ // Without setting "javax.security.auth.useSubjectCredsOnly" to "false", @@ -142,6 +155,7 @@ public byte[] init(byte[] token, int s, int l) throws JSchException { } } + @Override public byte[] getMIC(byte[] message, int s, int l){ try{ MessageProp prop = new MessageProp(0, true); @@ -152,6 +166,9 @@ public byte[] getMIC(byte[] message, int s, int l){ } } + /** + *dispose.
+ */ public void dispose(){ try{ context.dispose(); diff --git a/tools/bin/ant b/tools/bin/ant deleted file mode 100644 index 365f900..0000000 --- a/tools/bin/ant +++ /dev/null @@ -1,134 +0,0 @@ -#! /bin/sh - -if [ -f $HOME/.antrc ] ; then - . $HOME/.antrc -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -case "`uname`" in - CYGWIN*) cygwin=true ;; - Darwin*) darwin=true ;; -esac - -if [ -z "$ANT_HOME" ] ; then - # try to find ANT - if [ -d /opt/ant ] ; then - ANT_HOME=/opt/ant - fi - - if [ -d ${HOME}/opt/ant ] ; then - ANT_HOME=${HOME}/opt/ant - fi - - ## resolve links - $0 may be a link to ant's home - PRG=$0 - progname=`basename $0` - - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '.*/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname $PRG`/$link" - fi - done - - ANT_HOME=`dirname "$PRG"`/.. - -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$ANT_HOME" ] && - ANT_HOME=`cygpath --unix "$ANT_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - else - JAVACMD=java - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." - echo " We cannot execute $JAVACMD" - exit -fi - -if [ -n "$CLASSPATH" ] ; then - LOCALCLASSPATH=$CLASSPATH -fi - -# add in the dependency .jar files -DIRLIBS=${ANT_HOME}/lib/*.jar -for i in ${DIRLIBS} -do - # if the directory is empty, then it will return the input string - # this is stupid, so case for it - if [ "$i" != "${DIRLIBS}" ] ; then - if [ -z "$LOCALCLASSPATH" ] ; then - LOCALCLASSPATH=$i - else - LOCALCLASSPATH="$i":$LOCALCLASSPATH - fi - fi -done - -if [ -n "$JAVA_HOME" ] ; then - if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then - LOCALCLASSPATH=$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar - fi - - if [ -f "$JAVA_HOME/lib/classes.zip" ] ; then - LOCALCLASSPATH=$LOCALCLASSPATH:$JAVA_HOME/lib/classes.zip - fi - - # OSX hack to make Ant work with jikes - if $darwin ; then - OSXHACK="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes" - if [ -d ${OSXHACK} ] ; then - for i in ${OSXHACK}/*.jar - do - JIKESPATH=$JIKESPATH:$i - done - fi - fi - -else - echo "Warning: JAVA_HOME environment variable is not set." - echo " If build fails because sun.* classes could not be found" - echo " you will need to set the JAVA_HOME environment variable" - echo " to the installation directory of java." -fi - -# supply JIKESPATH to Ant as jikes.class.path -if [ -n "$JIKESPATH" ] ; then - if [ -n "$ANT_OPTS" ] ; then - ANT_OPTS="$ANT_OPTS -Djikes.class.path=$JIKESPATH" - else - ANT_OPTS=-Djikes.class.path=$JIKESPATH - fi -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - ANT_HOME=`cygpath --path --windows "$ANT_HOME"` - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - LOCALCLASSPATH=`cygpath --path --windows "$LOCALCLASSPATH"` -fi - -$JAVACMD -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" $ANT_OPTS org.apache.tools.ant.Main "$@" diff --git a/tools/bin/ant.bat b/tools/bin/ant.bat deleted file mode 100644 index 81a2835..0000000 --- a/tools/bin/ant.bat +++ /dev/null @@ -1,110 +0,0 @@ -@echo off - -if exist "%HOME%\antrc_pre.bat" call "%HOME%\antrc_pre.bat" - -if not "%OS%"=="Windows_NT" goto win9xStart -:winNTStart -@setlocal - -rem %~dp0 is name of current script under NT -set DEFAULT_ANT_HOME=%~dp0 - -rem : operator works similar to make : operator -set DEFAULT_ANT_HOME=%DEFAULT_ANT_HOME%\.. - -if "%ANT_HOME%"=="" set ANT_HOME=%DEFAULT_ANT_HOME% -set DEFAULT_ANT_HOME= - -rem Need to check if we are using the 4NT shell... -if "%eval[2+2]" == "4" goto setup4NT - -rem On NT/2K grab all arguments at once -set ANT_CMD_LINE_ARGS=%* -goto doneStart - -:setup4NT -set ANT_CMD_LINE_ARGS=%$ -goto doneStart - -:win9xStart -rem Slurp the command line arguments. This loop allows for an unlimited number of -rem agruments (up to the command line limit, anyway). - -set ANT_CMD_LINE_ARGS= - -:setupArgs -if %1a==a goto doneStart -set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1 -shift -goto setupArgs - -:doneStart -rem This label provides a place for the argument list loop to break out -rem and for NT handling to skip to. - -rem find ANT_HOME -if not "%ANT_HOME%"=="" goto checkJava - -rem check for ant in Program Files on system drive -if not exist "%SystemDrive%\Program Files\ant" goto checkSystemDrive -set ANT_HOME=%SystemDrive%\Program Files\ant -goto checkJava - -:checkSystemDrive -rem check for ant in root directory of system drive -if not exist %SystemDrive%\ant\nul goto checkCDrive -set ANT_HOME=%SystemDrive%\ant -goto checkJava - -:checkCDrive -rem check for ant in C:\ant for Win9X users -if not exist C:\ant\nul goto noAntHome -set ANT_HOME=C:\ant -goto checkJava - -:noAntHome -echo ANT_HOME is not set and ant could not be located. Please set ANT_HOME. -goto end - -:checkJava -set _JAVACMD=%JAVACMD% -set LOCALCLASSPATH=%CLASSPATH% -for %%i in ("%ANT_HOME%\lib\*.jar") do call "%ANT_HOME%\bin\lcp.bat" %%i - -if "%JAVA_HOME%" == "" goto noJavaHome -if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java -if exist "%JAVA_HOME%\lib\tools.jar" call "%ANT_HOME%\bin\lcp.bat" %JAVA_HOME%\lib\tools.jar -if exist "%JAVA_HOME%\lib\classes.zip" call "%ANT_HOME%\bin\lcp.bat" %JAVA_HOME%\lib\classes.zip -goto checkJikes - -:noJavaHome -if "%_JAVACMD%" == "" set _JAVACMD=java -echo. -echo Warning: JAVA_HOME environment variable is not set. -echo If build fails because sun.* classes could not be found -echo you will need to set the JAVA_HOME environment variable -echo to the installation directory of java. -echo. - -:checkJikes -if not "%JIKESPATH%" == "" goto runAntWithJikes - -:runAnt -"%_JAVACMD%" -classpath "%LOCALCLASSPATH%" -Dant.home="%ANT_HOME%" %ANT_OPTS% org.apache.tools.ant.Main %ANT_CMD_LINE_ARGS% -goto end - -:runAntWithJikes -"%_JAVACMD%" -classpath "%LOCALCLASSPATH%" -Dant.home="%ANT_HOME%" -Djikes.class.path="%JIKESPATH%" %ANT_OPTS% org.apache.tools.ant.Main %ANT_CMD_LINE_ARGS% - -:end -set LOCALCLASSPATH= -set _JAVACMD= -set ANT_CMD_LINE_ARGS= - -if not "%OS%"=="Windows_NT" goto mainEnd -:winNTend -@endlocal - -:mainEnd -if exist "%HOME%\antrc_post.bat" call "%HOME%\antrc_post.bat" - diff --git a/tools/bin/antRun b/tools/bin/antRun deleted file mode 100644 index f0a18f1..0000000 --- a/tools/bin/antRun +++ /dev/null @@ -1,9 +0,0 @@ -#! /bin/sh - -# Args: DIR command -cd "$1" -CMD="$2" -shift -shift - -exec $CMD "$@" diff --git a/tools/bin/antRun.bat b/tools/bin/antRun.bat deleted file mode 100644 index 9168932..0000000 --- a/tools/bin/antRun.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off - -rem Change drive and directory to %1 (Win9X only for NT/2K use "cd /d") -cd %1 -%1\ -set ANT_RUN_CMD=%2 -shift -shift - -set PARAMS= -:loop -if ""%1 == "" goto runCommand -set PARAMS=%PARAMS% %1 -shift -goto loop - -:runCommand -rem echo %ANT_RUN_CMD% %PARAMS% -%ANT_RUN_CMD% %PARAMS% - diff --git a/tools/bin/lcp.bat b/tools/bin/lcp.bat deleted file mode 100644 index 2c7e276..0000000 --- a/tools/bin/lcp.bat +++ /dev/null @@ -1,9 +0,0 @@ -set _CLASSPATHCOMPONENT=%1 -:argCheck -if %2a==a goto gotAllArgs -shift -set _CLASSPATHCOMPONENT=%_CLASSPATHCOMPONENT% %1 -goto argCheck -:gotAllArgs -set LOCALCLASSPATH=%_CLASSPATHCOMPONENT%;%LOCALCLASSPATH% - diff --git a/tools/bin/runant.pl b/tools/bin/runant.pl deleted file mode 100644 index a2cc523..0000000 --- a/tools/bin/runant.pl +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/perl -####################################################################### -# -# runant.pl -# -# wrapper script for invoking ant in a platform with Perl installed -# this may include cgi-bin invocation, which is considered somewhat daft. -# (slo: that should be a separate file which can be derived from this -# and returns the XML formatted output) -# -# the code is not totally portable due to classpath and directory splitting -# issues. oops. (NB, use File::Spec::Functions will help and the code is -# structured for the catfile() call, but because of perl version funnies -# the code is not included. -# -# created: 2000-8-24 -# last modified: 2000-8-24 -# author: Steve Loughran steve_l@sourceforge.net -####################################################################### -# -# Assumptions: -# -# - the "java" executable/script is on the command path -# - ANT_HOME has been set -# - target platform uses ":" as classpath separator or perl indicates it is dos/win32 -# - target platform uses "/" as directory separator. - -#be fussy about variables -use strict; - -#platform specifics (disabled) -#use File::Spec::Functions; - -#turn warnings on during dev; generates a few spurious uninitialised var access warnings -#use warnings; - -#and set $debug to 1 to turn on trace info -my $debug=0; - -####################################################################### -# -# check to make sure environment is setup -# - -my $HOME = $ENV{ANT_HOME}; -if ($HOME eq "") - { - die "\n\nANT_HOME *MUST* be set!\n\n"; - } - -my $JAVACMD = $ENV{JAVACMD}; -$JAVACMD = "java" if $JAVACMD eq ""; - -#ISSUE: what java wants to split up classpath varies from platform to platform -#and perl is not too hot at hinting which box it is on. -#here I assume ":" 'cept on win32 and dos. Add extra tests here as needed. -my $s=":"; -if(($^O eq "MSWin32") || ($^O eq "dos")) - { - $s=";"; - } - -#build up standard classpath -my $localpath=$ENV{CLASSPATH}; -if ($localpath eq "") - { - print "warning: no initial classpath\n" if ($debug); - $localpath=""; - } - -#add jar files. I am sure there is a perl one liner to do this. -my $jarpattern="$HOME/lib/*.jar"; -my @jarfiles =glob($jarpattern); -print "jarfiles=@jarfiles\n" if ($debug); -my $jar; -foreach $jar (@jarfiles ) - { - $localpath.="$s$jar"; - } - -#if Java home is defined, look for tools.jar & classes.zip and add to classpath -my $JAVA_HOME = $ENV{JAVA_HOME}; -if ($JAVA_HOME ne "") - { - my $tools="$JAVA_HOME/lib/tools.jar"; - if (-e "$tools") - { - $localpath .= "$s$tools"; - } - my $classes="$JAVA_HOME/lib/classes.zip"; - if (-e $classes) - { - $localpath .= "$s$classes"; - } - } -else - { - print "\n\nWarning: JAVA_HOME environment variable is not set.\n". - "If the build fails because sun.* classes could not be found\n". - "you will need to set the JAVA_HOME environment variable\n". - "to the installation directory of java\n"; - } - -#jikes -my @ANT_OPTS=split $ENV{ANT_OPTS}; -if($ENV{JIKESPATH} ne "") - { - push @ANT_OPTS, "-Djikes.class.path=$ENV{JIKESPATH}"; - } - -#construct arguments to java - -my @ARGS; -push @ARGS, "-classpath", "$localpath", "-Dant.home=$HOME"; -push @ARGS, @ANT_OPTS; -push @ARGS, "org.apache.tools.ant.Main"; -push @ARGS, @ARGV; - -print "\n $JAVACMD @ARGS\n\n" if ($debug); - -my $returnValue = system $JAVACMD, @ARGS; -if ($returnValue eq 0) - { - exit 0; - } -else - { - # only 0 and 1 are widely recognized as exit values - # so change the exit value to 1 - exit 1; - } diff --git a/tools/bin/runant.py b/tools/bin/runant.py deleted file mode 100644 index d5e200c..0000000 --- a/tools/bin/runant.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/python -""" - - runant.py - - This script is a translation of the runant.pl written by Steve Loughran. - It runs ant with/out arguments, it should be quite portable (thanks to - the python os library) - This script has been tested with Python2.0/Win2K - - created: 2001-04-11 - author: Pierre Dittgen pierre.dittgen@criltelecom.com - - Assumptions: - - - the "java" executable/script is on the command path - - ANT_HOME has been set -""" -import os, os.path, string, sys - -# Change it to 1 to get extra debug information -debug = 0 - -####################################################################### -# -# check to make sure environment is setup -# -if not os.environ.has_key('ANT_HOME'): - print '\n\nANT_HOME *MUST* be set!\n\n' - sys.exit(1) -else: - ANT_HOME = os.environ['ANT_HOME'] - -if not os.environ.has_key('JAVACMD'): - JAVACMD = 'java' -else: - JAVACMD = os.environ['JAVACMD'] - -# Sets the separator char for CLASSPATH -SEPARATOR = ':' -if os.name == 'dos' or os.name == 'nt': - SEPARATOR = ';' - -# Build up standard classpath -localpath = '' -if os.environ.has_key('CLASSPATH'): - localpath = os.environ['CLASSPATH'] -else: - if debug: - print 'Warning: no initial classpath\n' - -# Add jar files -LIBDIR = os.path.join(ANT_HOME, 'lib') -jarfiles = [] -for file in os.listdir(LIBDIR): - if file[-4:] == '.jar': - jarfiles.append(os.path.join(LIBDIR,file)) -if debug: - print 'Jar files:' - for jar in jarfiles: - print jar -localpath = localpath + SEPARATOR + string.join(jarfiles, SEPARATOR) - -# If JAVA_HOME is defined, look for tools.jar & classes.zip -# and add to classpath -if os.environ.has_key('JAVA_HOME') and os.environ['JAVA_HOME'] != '': - JAVA_HOME = os.environ['JAVA_HOME'] - TOOLS = os.path.join(JAVA_HOME, os.path.join('lib', 'tools.jar')) - if os.path.exists(TOOLS): - localpath = localpath + SEPARATOR + TOOLS - CLASSES = os.path.join(JAVA_HOME, os.path.join('lib', 'classes.zip')) - if os.path.exists(CLASSES): - localpath = localpath + SEPARATOR + CLASSES -else: - print '\n\nWarning: JAVA_HOME environment variable is not set.\n', \ - 'If the build fails because sun.* classes could not be found\n', \ - 'you will need to set the JAVA_HOME environment variable\n', \ - 'to the installation directory of java\n' - -# Jikes -ANT_OPTS = [] -if os.environ.has_key('ANT_OPTS'): - ANT_OPTS = string.split(os.environ['ANT_OPTS']) -if os.environ.has_key('JIKESPATH'): - ANT_OPTS.append('-Djikes.class.path=' + os.environ['JIKESPATH']) - -# Builds the commandline -cmdline = '%s -classpath %s -Dant.home=%s %s org.apache.tools.ant.Main %s' \ - % (JAVACMD, localpath, ANT_HOME, string.join(ANT_OPTS,' '), \ - string.join(sys.argv[1:], ' ')) - -if debug: - print '\n%s\n\n' % (cmdline) - -# Run the biniou! -os.system(cmdline)