Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate build to Maven #5

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed/Added JavaDoc in numerous places
  • Loading branch information
InfoSec812 committed May 19, 2015
commit 778acf224d429dd1889f55d890ff3f3ba6a961cc
4 changes: 2 additions & 2 deletions src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ public void run(){
//System.err.println("connect end");
}

/** {@inheritDoc} */
@Override
public void setInputStream(InputStream in){
io.setInputStream(in);
}
/** {@inheritDoc} */
@Override
public void setOutputStream(OutputStream out){
io.setOutputStream(out);
}
Expand Down
46 changes: 46 additions & 0 deletions src/main/java/com/jcraft/jsch/ChannelSftp.java
Original file line number Diff line number Diff line change
Expand Up @@ -2810,6 +2810,9 @@ public String realpath(String path) throws SftpException{
}
}

/**
* Filesystem listing class
*/
public class LsEntry implements Comparable{
private String filename;
private String longname;
Expand All @@ -2819,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());
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/jcraft/jsch/ChannelSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ public class ChannelSubsystem extends ChannelSession{
boolean pty=false;
boolean want_reply=true;
String subsystem="";
/** {@inheritDoc} */
@Override
public void setXForwarding(boolean foo){ xforwading=true; }
/** {@inheritDoc} */

@Override
public void setPty(boolean foo){ pty=foo; }
/**
* <p>setWantReply.</p>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcraft/jsch/CipherNone.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class CipherNone implements Cipher{
*/
public void init(int mode, byte[] key, byte[] iv) throws Exception{
}
/** {@inheritDoc} */
@Override
public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{
}
/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcraft/jsch/DHG1.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void init(Session session,
state=SSH_MSG_KEXDH_REPLY;
}

/** {@inheritDoc} */
@Override
public boolean next(Buffer _buf) throws Exception{
int i,j;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcraft/jsch/DHGEX.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void init(Session session,
state=SSH_MSG_KEX_DH_GEX_GROUP;
}

/** {@inheritDoc} */
@Override
public boolean next(Buffer _buf) throws Exception{
int i,j;
switch(state){
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/jcraft/jsch/HostKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,19 @@ public class HostKey{
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;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcraft/jsch/IdentityFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ private byte a2b(byte c){
return (byte)(c-'A'+10);
}

/** {@inheritDoc} */
@Override
public boolean equals(Object o){
if(!(o instanceof IdentityFile)) return super.equals(o);
IdentityFile foo=(IdentityFile)o;
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/jcraft/jsch/KeyExchange.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,29 @@ public abstract class KeyExchange{
/** Constant <code>STATE_END=0</code> */
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;

/**
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/jcraft/jsch/KnownHosts.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public int check(String host, byte[] key){

return result;
}
/** {@inheritDoc} */
@Override
public void add(HostKey hostkey, UserInfo userinfo){
int type=hostkey.type;
String host=hostkey.getHost();
Expand Down Expand Up @@ -304,7 +304,7 @@ public void add(HostKey hostkey, UserInfo userinfo){
public HostKey[] getHostKey(){
return getHostKey(null, null);
}
/** {@inheritDoc} */
@Override
public HostKey[] getHostKey(String host, String type){
synchronized(pool){
int count=0;
Expand Down Expand Up @@ -332,7 +332,7 @@ public HostKey[] getHostKey(String host, String type){
return foo;
}
}
/** {@inheritDoc} */
@Override
public void remove(String host, String type){
remove(host, type, null);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcraft/jsch/ProxyHTTP.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void setUserPasswd(String user, String passwd){
this.user=user;
this.passwd=passwd;
}
/** {@inheritDoc} */
@Override
public void connect(SocketFactory socket_factory, String host, int port, int timeout) throws JSchException{
try{
if(socket_factory==null){
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcraft/jsch/ProxySOCKS4.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void setUserPasswd(String user, String passwd){
this.user=user;
this.passwd=passwd;
}
/** {@inheritDoc} */
@Override
public void connect(SocketFactory socket_factory, String host, int port, int timeout) throws JSchException{
try{
if(socket_factory==null){
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcraft/jsch/ProxySOCKS5.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void setUserPasswd(String user, String passwd){
this.user=user;
this.passwd=passwd;
}
/** {@inheritDoc} */
@Override
public void connect(SocketFactory socket_factory, String host, int port, int timeout) throws JSchException{
try{
if(socket_factory==null){
Expand Down
122 changes: 75 additions & 47 deletions src/main/java/com/jcraft/jsch/Request.java
Original file line number Diff line number Diff line change
@@ -1,68 +1,96 @@
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/*
Copyright (c) 2002-2010 ymnk, JCraft,Inc. All rights reserved.
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:
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.
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.
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.
*/
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){
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
*/
void request(Session session, Channel channel) {
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;

/**
* 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;
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");
if (channel.reply == 0) {
throw new JSchException("failed to send channel request");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcraft/jsch/RequestAgentForwarding.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
package com.jcraft.jsch;

class RequestAgentForwarding extends Request{
/** {@inheritDoc} */
@Override
public void request(Session session, Channel channel) throws Exception{
super.request(session, channel);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcraft/jsch/RequestEnv.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void setEnv(byte[] name, byte[] value){
this.name=name;
this.value=value;
}
/** {@inheritDoc} */
@Override
public void request(Session session, Channel channel) throws Exception{
super.request(session, channel);

Expand Down
Loading