Skip to content

Commit

Permalink
531 replacing jsch with sshj in ssh app (#551)
Browse files Browse the repository at this point in the history
* 531-replacing-jsch-with-sshj-in-ssh-app
  • Loading branch information
osuender authored Oct 31, 2023
1 parent 534dee6 commit 5e959a4
Show file tree
Hide file tree
Showing 73 changed files with 3,024 additions and 2,873 deletions.
2 changes: 1 addition & 1 deletion installation/build/copyLicenseFiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
#copy license files (non .jar-files) in input dir to output dir

mkdir "$2"
while read -r i; do cp "$i" "$2"; done <<< $(find "$1" ! -iname "*.jar" -type f)
while read -r i; do cp "$i" "$2"; done <<< $(find "$1" -maxdepth 1 ! -iname "*.jar" -type f)

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<IsServiceGroupOnly>true</IsServiceGroupOnly>
</Meta>
<Libraries>SSHFileTransferImpl.jar</Libraries>
<SharedLibraries>sshlibs</SharedLibraries>
<Service Label="SSH File Transfer" TypeName="SSHFileTransfer">
<Operation IsStatic="true" Label="SCP To Remote Host" Name="sCPToRemoteHost">
<Meta>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<IsServiceGroupOnly>false</IsServiceGroupOnly>
</Meta>
<Libraries>SSHNETCONFConnectionImpl.jar</Libraries>
<SharedLibraries>sshlibs</SharedLibraries>
<Service Label="SSH NETCONF connection" TypeName="SSHNETCONFConnection">
<Operation IsStatic="false" Label="Has Capability" Name="hasCapability">
<Input>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<IsServiceGroupOnly>false</IsServiceGroupOnly>
</Meta>
<Libraries>SSHShellConnectionImpl.jar</Libraries>
<SharedLibraries>sshlibs</SharedLibraries>
<Service Label="SSH shell connection" TypeName="SSHShellConnection">
<Meta>
<AdditionalDependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<Meta>
<IsServiceGroupOnly>false</IsServiceGroupOnly>
</Meta>
<SharedLibraries>sshlibs</SharedLibraries>
<Data Label="terminal height rows" VariableName="terminalHeightRows">
<Meta>
<Type>int</Type>
Expand Down
2 changes: 1 addition & 1 deletion modules/xact/connection/ssh/application.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<Application applicationName="SSH" comment="" factoryVersion="" versionName="1.0.25" xmlVersion="1.1">
<Application applicationName="SSH" comment="" factoryVersion="" versionName="2.0.25" xmlVersion="1.1">
<ApplicationInfo>
<Description Lang="DE">SSH Connections (NETCONF, Shell), Management, SFTP, SharedLibs, SFTPTrigger</Description>
<Description Lang="EN">SSH connections (NETCONF, Shell), management, SFTP, sharedLibs, SFTPTrigger</Description>
Expand Down
2 changes: 1 addition & 1 deletion modules/xact/connection/ssh/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<ant antfile="build.xml" target="build-app" inheritAll="false" dir="sharedlib/PromptExtraction">
<property name="target.dir" value="${target.dir}/app" />
</ant>
<ant antfile="build.xml" target="build-app" inheritAll="false" dir="sharedlib/SSHJSchUtils">
<ant antfile="build.xml" target="build-app" inheritAll="false" dir="sharedlib/SSHJUtils">
<property name="target.dir" value="${target.dir}/app" />
</ant>
<ant antfile="build.xml" target="build-app" inheritAll="false" dir="sharedlib/SSHStorables">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<import file="${root.dir}/installation/build/buildService.xml" />

<target name="prepareLibs" description="Build for application">
<ant antfile="build.xml" target="build" inheritAll="false" dir="${basedir}/../../sharedlib/SSHJSchUtils">
<ant antfile="build.xml" target="build" inheritAll="false" dir="${basedir}/../../sharedlib/SSHJUtils">
<property name="target.dir" value="${basedir}/lib/xyna" />
</ant>
</target>
Expand Down
11 changes: 1 addition & 10 deletions modules/xact/connection/ssh/mdmimpl/SSHConnectionImpl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,17 @@
<version>1.0.0</version>
<relativePath>../../../../../../installation/build/pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<groupId>com.gip.xyna</groupId>
<artifactId>SSHConnectionImpl</artifactId>
<version>1.0.22</version>
<version>2.0.25</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
</dependency>
<dependency>
<groupId>com.hierynomus</groupId>
<artifactId>sshj</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,34 @@
*/
package xact.ssh;



import java.util.ArrayList;
import java.util.List;



public enum AuthenticationMethod {
PUBLICKEY(new String[] {"publickey"}, PublicKey.class),
PASSWORD(new String[] {"password","keyboard-interactive"}, Password.class),
HOSTBASED(new String[] {"hostbased"}, HostBased.class);


PUBLICKEY(new String[] {"publickey"}, PublicKey.class), PASSWORD(new String[] {"password", "keyboard-interactive"},
Password.class), HOSTBASED(new String[] {"hostbased"}, HostBased.class);


private final String[] identifiers;
private final Class<? extends AuthenticationMode> xynaRepresentation;



private AuthenticationMethod(String[] identifiers, Class<? extends AuthenticationMode> xynaRepresentation) {
this.identifiers = identifiers;
this.xynaRepresentation = xynaRepresentation;
}



public String[] getIdentifiers() {
return identifiers;
}


public static <M extends AuthenticationMode> AuthenticationMethod getByXynaRepresentation(M xynaRepresentation) {
if (xynaRepresentation != null) {
for (AuthenticationMethod mode : values()) {
Expand All @@ -49,8 +55,8 @@ public static <M extends AuthenticationMode> AuthenticationMethod getByXynaRepre
}
return null;
}


public static <M extends AuthenticationMode> List<AuthenticationMethod> getByXynaRepresentation(List<M> xynaRepresentations) {
List<AuthenticationMethod> methods = new ArrayList<AuthenticationMethod>();
for (M xynaRepresentation : xynaRepresentations) {
Expand All @@ -61,5 +67,5 @@ public static <M extends AuthenticationMode> List<AuthenticationMethod> getByXyn
}
return methods;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,25 @@
package xact.ssh;



public enum HostKeyCheckingMode {
YES("yes", Yes.class), NO("no", No.class), ASK("ask", Ask.class);

private final String stringRepresentation;
private final Class<? extends HostKeyChecking> xynaRepresentation;



private HostKeyCheckingMode(String stringRepresentation, Class<? extends HostKeyChecking> xynaRepresentation) {
this.stringRepresentation = stringRepresentation;
this.xynaRepresentation = xynaRepresentation;
}


public String getStringRepresentation() {
return stringRepresentation;
}


public static <C extends HostKeyChecking> HostKeyCheckingMode getByXynaRepresentation(C xynaRepresentation) {
if (xynaRepresentation != null) {
for (HostKeyCheckingMode mode : values()) {
Expand All @@ -45,5 +47,5 @@ public static <C extends HostKeyChecking> HostKeyCheckingMode getByXynaRepresent
}
return HostKeyCheckingMode.YES;
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* Copyright 2022 Xyna GmbH, Germany
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
package xact.ssh;


Expand All @@ -6,27 +23,31 @@




public final class Utils {

private Utils() {} // static utils class
private Utils() {
}


static SSHException toSshException(net.schmizz.sshj.common.SSHException sshjException) {
public static SSHException toSshException(net.schmizz.sshj.common.SSHException sshjException) {
switch (sshjException.getDisconnectReason()) {
case CONNECTION_LOST:
case CONNECTION_LOST :
return new ConnectionLostException(sshjException.getMessage());
case HOST_KEY_NOT_VERIFIABLE:
case HOST_KEY_NOT_VERIFIABLE :
return new HostKeyNotVerifiableException(sshjException.getMessage());
case HOST_NOT_ALLOWED_TO_CONNECT:
case HOST_NOT_ALLOWED_TO_CONNECT :
return new HostNotAllowedToConnectException(sshjException.getMessage());
case ILLEGAL_USER_NAME:
case ILLEGAL_USER_NAME :
return new IllegalUserNameException(sshjException.getMessage());
case KEY_EXCHANGE_FAILED:
case KEY_EXCHANGE_FAILED :
return new KeyExchangeFailedException(sshjException.getMessage());
case AUTH_CANCELLED_BY_USER:
case AUTH_CANCELLED_BY_USER :
return new UserAuthException(sshjException.getMessage());
default:
default :
return new SSHException(sshjException.getMessage());
}
}

}

Loading

0 comments on commit 5e959a4

Please sign in to comment.