Skip to content

Commit

Permalink
Merge pull request #359 from norrisjeremy/20230714
Browse files Browse the repository at this point in the history
0.2.10 changes
  • Loading branch information
mwiede authored Jul 20, 2023
2 parents 04d9932 + 23b5265 commit 1060a4d
Show file tree
Hide file tree
Showing 28 changed files with 284 additions and 246 deletions.
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.1/apache-maven-3.9.1-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* [0.2.10](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.10)
* Fix new Java 21 compiler warning: `possible 'this' escape before subclass is fully initialized`.
* Tweak OSGi bundle manifest to allow Log4j 3.
* [0.2.9](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.9)
* [#293](https://github.com/mwiede/jsch/issues/293) allow UserAuthNone to be extended.
* Make JGSS module optional.
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
<dependency>
<groupId>com.github.valfirst</groupId>
<artifactId>slf4j-test</artifactId>
<version>2.9.0</version>
<version>3.0.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -404,7 +404,7 @@
<Export-Package>com.jcraft.jsch;-noimport:=true</Export-Package>
<Import-Package><![CDATA[
com.sun.jna*;version="${range;[=0,+)}",
org.apache.logging.log4j*;version="${range;[=0,+)}",
org.apache.logging.log4j*;version="${range;[=0,4)}",
org.bouncycastle*;version="[1.69,${versionmask;+})",
org.slf4j*;version="[1.7,${versionmask;+})",
org.ietf.jgss;resolution:=optional,
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/jcraft/jsch/ChannelAgentForwarding.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class ChannelAgentForwarding extends Channel {
ChannelAgentForwarding() {
super();

setLocalWindowSizeMax(LOCAL_WINDOW_SIZE_MAX);
setLocalWindowSize(LOCAL_WINDOW_SIZE_MAX);
setLocalPacketSize(LOCAL_MAXIMUM_PACKET_SIZE);
lwsize_max = LOCAL_WINDOW_SIZE_MAX;
lwsize = LOCAL_WINDOW_SIZE_MAX;
lmpsize = LOCAL_MAXIMUM_PACKET_SIZE;

type = Util.str2byte("auth-agent@openssh.com");
rbuf = new Buffer();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/jcraft/jsch/ChannelDirectStreamLocal.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public class ChannelDirectStreamLocal extends ChannelDirectTCPIP {
ChannelDirectStreamLocal() {
super();
type = _type;
setLocalWindowSizeMax(LOCAL_WINDOW_SIZE_MAX);
setLocalWindowSize(LOCAL_WINDOW_SIZE_MAX);
setLocalPacketSize(LOCAL_MAXIMUM_PACKET_SIZE);
lwsize_max = LOCAL_WINDOW_SIZE_MAX;
lwsize = LOCAL_WINDOW_SIZE_MAX;
lmpsize = LOCAL_MAXIMUM_PACKET_SIZE;
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public class ChannelDirectTCPIP extends Channel {
ChannelDirectTCPIP() {
super();
type = _type;
setLocalWindowSizeMax(LOCAL_WINDOW_SIZE_MAX);
setLocalWindowSize(LOCAL_WINDOW_SIZE_MAX);
setLocalPacketSize(LOCAL_MAXIMUM_PACKET_SIZE);
lwsize_max = LOCAL_WINDOW_SIZE_MAX;
lwsize = LOCAL_WINDOW_SIZE_MAX;
lmpsize = LOCAL_MAXIMUM_PACKET_SIZE;
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public class ChannelForwardedTCPIP extends Channel {

ChannelForwardedTCPIP() {
super();
setLocalWindowSizeMax(LOCAL_WINDOW_SIZE_MAX);
setLocalWindowSize(LOCAL_WINDOW_SIZE_MAX);
setLocalPacketSize(LOCAL_MAXIMUM_PACKET_SIZE);
lwsize_max = LOCAL_WINDOW_SIZE_MAX;
lwsize = LOCAL_WINDOW_SIZE_MAX;
lmpsize = LOCAL_MAXIMUM_PACKET_SIZE;
io = new IO();
connected = true;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/jcraft/jsch/ChannelSftp.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ public int getBulkRequests() {

public ChannelSftp() {
super();
setLocalWindowSizeMax(LOCAL_WINDOW_SIZE_MAX);
setLocalWindowSize(LOCAL_WINDOW_SIZE_MAX);
setLocalPacketSize(LOCAL_MAXIMUM_PACKET_SIZE);
lwsize_max = LOCAL_WINDOW_SIZE_MAX;
lwsize = LOCAL_WINDOW_SIZE_MAX;
lmpsize = LOCAL_MAXIMUM_PACKET_SIZE;
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/jcraft/jsch/ChannelX11.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ static void removeFakedCookie(Session session) {
ChannelX11() {
super();

setLocalWindowSizeMax(LOCAL_WINDOW_SIZE_MAX);
setLocalWindowSize(LOCAL_WINDOW_SIZE_MAX);
setLocalPacketSize(LOCAL_MAXIMUM_PACKET_SIZE);
lwsize_max = LOCAL_WINDOW_SIZE_MAX;
lwsize = LOCAL_WINDOW_SIZE_MAX;
lmpsize = LOCAL_MAXIMUM_PACKET_SIZE;

type = Util.str2byte("x11");

Expand Down
19 changes: 9 additions & 10 deletions src/main/java/com/jcraft/jsch/IdentityFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,23 @@
import java.io.*;

class IdentityFile implements Identity {
private JSch jsch;
private KeyPair kpair;
private String identity;

static IdentityFile newInstance(String prvfile, String pubfile, JSch jsch) throws JSchException {
KeyPair kpair = KeyPair.load(jsch, prvfile, pubfile);
return new IdentityFile(jsch, prvfile, kpair);
static IdentityFile newInstance(String prvfile, String pubfile, JSch.InstanceLogger instLogger)
throws JSchException {
KeyPair kpair = KeyPair.load(instLogger, prvfile, pubfile);
return new IdentityFile(prvfile, kpair);
}

static IdentityFile newInstance(String name, byte[] prvkey, byte[] pubkey, JSch jsch)
throws JSchException {
static IdentityFile newInstance(String name, byte[] prvkey, byte[] pubkey,
JSch.InstanceLogger instLogger) throws JSchException {

KeyPair kpair = KeyPair.load(jsch, prvkey, pubkey);
return new IdentityFile(jsch, name, kpair);
KeyPair kpair = KeyPair.load(instLogger, prvkey, pubkey);
return new IdentityFile(name, kpair);
}

private IdentityFile(JSch jsch, String name, KeyPair kpair) throws JSchException {
this.jsch = jsch;
private IdentityFile(String name, KeyPair kpair) throws JSchException {
this.identity = name;
this.kpair = kpair;
}
Expand Down
35 changes: 25 additions & 10 deletions src/main/java/com/jcraft/jsch/JSch.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,11 @@ public class JSch {
config.put("ClearAllForwardings", "no");
}

final InstanceLogger instLogger = new InstanceLogger();

private Vector<Session> sessionPool = new Vector<>();

private IdentityRepository defaultIdentityRepository = new LocalIdentityRepository(this);
private IdentityRepository defaultIdentityRepository = new LocalIdentityRepository(instLogger);

private IdentityRepository identityRepository = defaultIdentityRepository;

Expand Down Expand Up @@ -291,7 +293,6 @@ public boolean isEnabled(int level) {
public void log(int level, String message) {}
};
static Logger logger = DEVNULL;
private Logger instLogger;

public JSch() {}

Expand Down Expand Up @@ -480,7 +481,7 @@ public void addIdentity(String prvkey, String passphrase) throws JSchException {
* @see #addIdentity(String prvkey, String pubkey, byte[] passphrase)
*/
public void addIdentity(String prvkey, byte[] passphrase) throws JSchException {
Identity identity = IdentityFile.newInstance(prvkey, null, this);
Identity identity = IdentityFile.newInstance(prvkey, null, instLogger);
addIdentity(identity, passphrase);
}

Expand All @@ -495,7 +496,7 @@ public void addIdentity(String prvkey, byte[] passphrase) throws JSchException {
* @throws JSchException if <code>passphrase</code> is not right.
*/
public void addIdentity(String prvkey, String pubkey, byte[] passphrase) throws JSchException {
Identity identity = IdentityFile.newInstance(prvkey, pubkey, this);
Identity identity = IdentityFile.newInstance(prvkey, pubkey, instLogger);
addIdentity(identity, passphrase);
}

Expand All @@ -511,7 +512,7 @@ public void addIdentity(String prvkey, String pubkey, byte[] passphrase) throws
*/
public void addIdentity(String name, byte[] prvkey, byte[] pubkey, byte[] passphrase)
throws JSchException {
Identity identity = IdentityFile.newInstance(name, prvkey, pubkey, this);
Identity identity = IdentityFile.newInstance(name, prvkey, pubkey, instLogger);
addIdentity(identity, passphrase);
}

Expand Down Expand Up @@ -669,10 +670,7 @@ public static void setLogger(Logger logger) {
* statically set logger is returned.
*/
public Logger getInstanceLogger() {
if (this.instLogger == null) {
return logger;
}
return instLogger;
return instLogger.getLogger();
}

/**
Expand All @@ -682,7 +680,7 @@ public Logger getInstanceLogger() {
* used
*/
public void setInstanceLogger(Logger logger) {
this.instLogger = logger;
instLogger.setLogger(logger);
}

/**
Expand All @@ -694,4 +692,21 @@ public void setInstanceLogger(Logger logger) {
public static Logger getLogger() {
return logger;
}

static class InstanceLogger {
private Logger logger;

private InstanceLogger() {}

Logger getLogger() {
if (logger == null) {
return JSch.logger;
}
return logger;
}

void setLogger(Logger logger) {
this.logger = logger;
}
}
}
Loading

0 comments on commit 1060a4d

Please sign in to comment.