Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"version": "25",
"jdkDistro": "tem",
"installMaven": "true",
"mavenVersion": "3.9.14",
"mavenVersion": "3.9.15",
"installGradle": "false"
},
"ghcr.io/devcontainers/features/docker-in-docker:2": {
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: ['8', '11', '17', '21', '25']
java: ['8', '11', '17', '21', '25', '26']
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
run: |
LOWER_JDK="${{ matrix.java }}"
UPPER_JDK=$((LOWER_JDK+1))
./mvnw -B -V -e -Pcoverage verify -Dtoolchain.jdk.version="[$LOWER_JDK,$UPPER_JDK)" -Dmaven.resources.skip=true -Dflatten.skip=true -Dmaven.main.skip=true -Dbnd.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -Dcyclonedx.skip=true -Dspdx.skip=true -Dformatter.skip=true -Dforbiddenapis.skip=true -DskipTests=false -DskipITs=false
./mvnw -B -V -e -Pcoverage verify -Dtoolchain.jdk.version="[$LOWER_JDK,$UPPER_JDK)" -Dmaven.resources.skip=true -Dflatten.skip=true -Dmaven.main.skip=true -Dbnd.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -Dcyclonedx.skip=true -Dspdx.skip=true -Dformatter.skip=true -Dimpsort.skip=true -Dforbiddenapis.skip=true -DskipTests=false -DskipITs=false
- name: Upload test results
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
Expand Down
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
wrapperVersion=3.3.4
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.14/apache-maven-3.9.14-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.15/apache-maven-3.9.15-bin.zip
2 changes: 1 addition & 1 deletion .sdkmanrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=25-tem
maven=3.9.14
maven=3.9.15
4 changes: 3 additions & 1 deletion examples/AES.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** This program will demonstrate how to use "aes128-cbc". */
/**
* This program will demonstrate how to use "aes128-cbc".
*/
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
Expand Down
4 changes: 3 additions & 1 deletion examples/Logger.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** This program will demonstrate how to enable logging mechanism and get logging messages. */
/**
* This program will demonstrate how to enable logging mechanism and get logging messages.
*/
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
Expand Down
4 changes: 3 additions & 1 deletion examples/Subsystem.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** This program will demonstrate how to use the Subsystem channel. */
/**
* This program will demonstrate how to use the Subsystem channel.
*/
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelSubsystem;
import com.jcraft.jsch.JSch;
Expand Down
4 changes: 3 additions & 1 deletion examples/Sudo.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** This program will demonstrate how to exec 'sudo' on the remote. */
/**
* This program will demonstrate how to exec 'sudo' on the remote.
*/
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
Expand Down
50 changes: 47 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>1.83</version>
<version>1.84</version>
<optional>true</optional>
</dependency>
<dependency>
Expand Down Expand Up @@ -260,7 +260,7 @@
<version>25</version>
</requireJavaVersion>
<requireMavenVersion>
<version>3.9.14</version>
<version>3.9.15</version>
</requireMavenVersion>
<dependencyConvergence />
<banDuplicatePomDependencyVersions />
Expand Down Expand Up @@ -453,7 +453,7 @@
Import-Package: \
com.sun.jna*;version="${range;[=0,+)}";resolution:=optional,\
org.apache.logging.log4j*;version="${range;[=0,4)}";resolution:=optional,\
org.bouncycastle*;version="[1.79,${versionmask;+})";resolution:=optional,\
org.bouncycastle*;version="[1.84,${versionmask;+})";resolution:=optional,\
org.slf4j*;version="[1.7,${versionmask;+})";resolution:=optional,\
org.newsclub.net.unix;resolution:=optional,\
org.ietf.jgss;resolution:=optional,\
Expand Down Expand Up @@ -684,6 +684,26 @@
</directories>
</configuration>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<version>1.12.0</version>
<configuration>
<removeUnused>true</removeUnused>
<directories>
<directory>${project.build.sourceDirectory}</directory>
<directory>${project.build.testSourceDirectory}</directory>
<directory>${project.basedir}/examples</directory>
<directory>${project.basedir}/src/main/java9</directory>
<directory>${project.basedir}/src/main/java10</directory>
<directory>${project.basedir}/src/main/java11</directory>
<directory>${project.basedir}/src/main/java15</directory>
<directory>${project.basedir}/src/main/java16</directory>
<directory>${project.basedir}/src/main/java24</directory>
<directory>${project.basedir}/src/main/java-templates</directory>
</directories>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
Expand Down Expand Up @@ -856,6 +876,18 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<executions>
<execution>
<id>sort-imports</id>
<goals>
<goal>sort</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Expand All @@ -878,6 +910,18 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.jcraft.jsch;

import com.jcraft.jsch.JSch.InstanceLogger;

import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/jcraft/jsch/OpenSshCertificateUtil.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.jcraft.jsch;

import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -11,7 +10,6 @@
import java.util.Map;
import java.util.Objects;
import java.util.Set;

import java.util.stream.Collectors;

class OpenSshCertificateUtil {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/jcraft/jsch/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

package com.jcraft.jsch;


import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/jcraft/jsch/bc/MLKEM.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
import com.jcraft.jsch.KEM;
import java.security.SecureRandom;
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
import org.bouncycastle.pqc.crypto.mlkem.MLKEMExtractor;
import org.bouncycastle.pqc.crypto.mlkem.MLKEMKeyGenerationParameters;
import org.bouncycastle.pqc.crypto.mlkem.MLKEMKeyPairGenerator;
import org.bouncycastle.pqc.crypto.mlkem.MLKEMParameters;
import org.bouncycastle.pqc.crypto.mlkem.MLKEMPrivateKeyParameters;
import org.bouncycastle.pqc.crypto.mlkem.MLKEMPublicKeyParameters;
import org.bouncycastle.crypto.generators.MLKEMKeyPairGenerator;
import org.bouncycastle.crypto.kems.MLKEMExtractor;
import org.bouncycastle.crypto.params.MLKEMKeyGenerationParameters;
import org.bouncycastle.crypto.params.MLKEMParameters;
import org.bouncycastle.crypto.params.MLKEMPrivateKeyParameters;
import org.bouncycastle.crypto.params.MLKEMPublicKeyParameters;

abstract class MLKEM implements KEM {
protected MLKEMParameters params;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcraft/jsch/bc/MLKEM1024.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

package com.jcraft.jsch.bc;

import org.bouncycastle.pqc.crypto.mlkem.MLKEMParameters;
import org.bouncycastle.crypto.params.MLKEMParameters;

public class MLKEM1024 extends MLKEM {
public MLKEM1024() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcraft/jsch/bc/MLKEM768.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

package com.jcraft.jsch.bc;

import org.bouncycastle.pqc.crypto.mlkem.MLKEMParameters;
import org.bouncycastle.crypto.params.MLKEMParameters;

public class MLKEM768 extends MLKEM {
public MLKEM768() {
Expand Down
4 changes: 0 additions & 4 deletions src/main/java24/com/jcraft/jsch/jce/MLKEM.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@

import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PublicKey;
import java.security.spec.NamedParameterSpec;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import javax.crypto.KEM;

abstract class MLKEM implements com.jcraft.jsch.KEM {
Expand Down
13 changes: 6 additions & 7 deletions src/test/java/com/jcraft/jsch/HostCertificateDssIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.github.valfirst.slf4jtest.LoggingEvent;
import com.github.valfirst.slf4jtest.TestLogger;
import com.github.valfirst.slf4jtest.TestLoggerFactory;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;

import com.github.valfirst.slf4jtest.LoggingEvent;
import com.github.valfirst.slf4jtest.TestLogger;
import com.github.valfirst.slf4jtest.TestLoggerFactory;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
Expand All @@ -25,8 +24,8 @@
* Integration tests for {@code ssh-dss-cert-v01@openssh.com} host certificate validation.
*
* These tests verify that JSch correctly validates a host certificate whose underlying key
* algorithm is DSA ({@code ssh-dss-cert-v01@openssh.com}). The server runs Alpine 3.5 with OpenSSH
* 7.4, which is required because modern OpenSSH (9.8+) removed DSA support.
* algorithm is DSA ({@code ssh-dss-cert-v01@openssh.com}). The server runs Alpine 3.7 with OpenSSH
* 7.5, which is required because modern OpenSSH (9.8+) removed DSA support.
*
*
* The DSA certificate is signed by an Ed25519 CA, so the client-side CA signature verification does
Expand All @@ -46,7 +45,7 @@ public class HostCertificateDssIT {
TestLoggerFactory.getTestLogger(HostCertificateDssIT.class);

/**
* OpenSSH 7.4 (Alpine 3.5) container configured to serve a DSA host certificate
* OpenSSH 7.5 (Alpine 3.7) container configured to serve a DSA host certificate
* ({@code ssh-dss-cert-v01@openssh.com}). The certificate is signed by an Ed25519 CA whose public
* key is in the client's {@code known_hosts} file with the {@code @cert-authority} marker.
* <p>
Expand Down
7 changes: 3 additions & 4 deletions src/test/java/com/jcraft/jsch/HostCertificateEd448IT.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.condition.JRE.JAVA_15;

import com.github.valfirst.slf4jtest.LoggingEvent;
import com.github.valfirst.slf4jtest.TestLogger;
import com.github.valfirst.slf4jtest.TestLoggerFactory;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;

import com.github.valfirst.slf4jtest.LoggingEvent;
import com.github.valfirst.slf4jtest.TestLogger;
import com.github.valfirst.slf4jtest.TestLoggerFactory;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledForJreRange;
import org.testcontainers.containers.GenericContainer;
Expand Down
9 changes: 3 additions & 6 deletions src/test/java/com/jcraft/jsch/HostCertificateIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.condition.JRE.JAVA_15;

import com.github.valfirst.slf4jtest.LoggingEvent;
import com.github.valfirst.slf4jtest.TestLogger;
import com.github.valfirst.slf4jtest.TestLoggerFactory;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;

import com.github.valfirst.slf4jtest.LoggingEvent;
import com.github.valfirst.slf4jtest.TestLogger;
import com.github.valfirst.slf4jtest.TestLoggerFactory;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledForJreRange;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down
1 change: 0 additions & 1 deletion src/test/java/com/jcraft/jsch/JSchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import java.util.Hashtable;
import java.util.Map;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down
1 change: 0 additions & 1 deletion src/test/java/com/jcraft/jsch/KeyPair2IT.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import static org.junit.jupiter.api.condition.JRE.JAVA_15;

import java.net.URISyntaxException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down
1 change: 0 additions & 1 deletion src/test/java/com/jcraft/jsch/KeyPairIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import static org.junit.jupiter.api.condition.JRE.JAVA_15;

import java.net.URISyntaxException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Locale;

import org.junit.jupiter.api.Test;

public class OpenSshCertificateAwareIdentityFileTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.jcraft.jsch;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Arrays;
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/com/jcraft/jsch/OpenSshCertificateUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,27 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.nio.charset.StandardCharsets;
import java.time.ZoneOffset;
import java.util.TimeZone;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

public class OpenSshCertificateUtilTest {

private static TimeZone timezone;

@BeforeAll
public static void beforeAll() {

Check warning on line 22 in src/test/java/com/jcraft/jsch/OpenSshCertificateUtilTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=mwiede_jsch&issues=AZ1Ja2XqUwmeBQ8rIbkb&open=AZ1Ja2XqUwmeBQ8rIbkb&pullRequest=1027
timezone = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone(ZoneOffset.UTC));
}

@AfterAll
public static void afterAll() {

Check warning on line 28 in src/test/java/com/jcraft/jsch/OpenSshCertificateUtilTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=mwiede_jsch&issues=AZ1Ja2XqUwmeBQ8rIbkc&open=AZ1Ja2XqUwmeBQ8rIbkc&pullRequest=1027
TimeZone.setDefault(timezone);
}

@Test
public void testExtractSpaceDelimitedString_nullInput() {
assertNull(OpenSshCertificateUtil.extractSpaceDelimitedString(null, 0));
Expand Down
Loading