├── j2ssh-maverick ├── .gitignore ├── .project ├── templates │ └── GPL-3.txt ├── README ├── src │ └── main │ │ └── java │ │ ├── com │ │ └── sshtools │ │ │ ├── logging │ │ │ ├── LoggerLevel.java │ │ │ ├── Logger.java │ │ │ ├── NoLogger.java │ │ │ ├── LoggerFactory.java │ │ │ └── SimpleLogger.java │ │ │ ├── ssh │ │ │ ├── message │ │ │ │ ├── Message.java │ │ │ │ ├── MessageObserver.java │ │ │ │ ├── MessageStore.java │ │ │ │ ├── MessageHolder.java │ │ │ │ ├── SshMessageReader.java │ │ │ │ ├── SshMessage.java │ │ │ │ ├── SshChannelMessage.java │ │ │ │ └── SshAbstractChannel.java │ │ │ ├── components │ │ │ │ ├── jce │ │ │ │ │ ├── AbstractKeyExchange.java │ │ │ │ │ ├── AbstractPublicKey.java │ │ │ │ │ ├── DiffieHellmanEcdhNistp256.java │ │ │ │ │ ├── DiffieHellmanEcdhNistp384.java │ │ │ │ │ ├── DiffieHellmanEcdhNistp521.java │ │ │ │ │ ├── AES128Ctr.java │ │ │ │ │ ├── AES192Ctr.java │ │ │ │ │ ├── AES256Ctr.java │ │ │ │ │ ├── Ssh2EcdsaSha2Nist256PublicKey.java │ │ │ │ │ ├── Ssh2EcdsaSha2Nist384PublicKey.java │ │ │ │ │ ├── Ssh2EcdsaSha2Nist521PublicKey.java │ │ │ │ │ ├── MD5Digest.java │ │ │ │ │ ├── HmacMD5.java │ │ │ │ │ ├── SHA1Digest.java │ │ │ │ │ ├── SHA384Digest.java │ │ │ │ │ ├── SHA512Digest.java │ │ │ │ │ ├── HmacMD596.java │ │ │ │ │ ├── SHA256Digest.java │ │ │ │ │ ├── package.html │ │ │ │ │ ├── AES128Cbc.java │ │ │ │ │ ├── AES192Cbc.java │ │ │ │ │ ├── AES256Cbc.java │ │ │ │ │ ├── TripleDesCbc.java │ │ │ │ │ ├── TripleDesCtr.java │ │ │ │ │ ├── DiffieHellmanGroupExchangeSha256.java │ │ │ │ │ ├── BlowfishCbc.java │ │ │ │ │ ├── HmacSha512.java │ │ │ │ │ ├── SecureRND.java │ │ │ │ │ ├── HmacSha1.java │ │ │ │ │ ├── HmacSha196.java │ │ │ │ │ ├── HmacSha256.java │ │ │ │ │ ├── ArcFour.java │ │ │ │ │ ├── ArcFour128.java │ │ │ │ │ ├── ArcFour256.java │ │ │ │ │ └── AbstractDigest.java │ │ │ │ ├── SshKeyExchange.java │ │ │ │ ├── SshDsaPublicKey.java │ │ │ │ ├── SshSecureRandomGenerator.java │ │ │ │ ├── SshRsaPrivateKey.java │ │ │ │ ├── SshRsaPublicKey.java │ │ │ │ ├── SshPrivateKey.java │ │ │ │ ├── package.html │ │ │ │ ├── SshDsaPrivateKey.java │ │ │ │ ├── SshRsaPrivateCrtKey.java │ │ │ │ ├── SshHmac.java │ │ │ │ ├── NoneHmac.java │ │ │ │ ├── SshKeyPair.java │ │ │ │ ├── Digest.java │ │ │ │ └── SshPublicKey.java │ │ │ ├── Client.java │ │ │ ├── compression │ │ │ │ ├── package.html │ │ │ │ └── SshCompression.java │ │ │ ├── package.html │ │ │ ├── SocketTimeoutSupport.java │ │ │ ├── SshIOException.java │ │ │ ├── SshIO.java │ │ │ ├── ChannelOpenException.java │ │ │ ├── Packet.java │ │ │ ├── SshAuthentication.java │ │ │ ├── SshChannel.java │ │ │ ├── CommandExecutor.java │ │ │ └── SshTransport.java │ │ │ ├── ssh2 │ │ │ ├── MaverickCallbackHandler.java │ │ │ ├── TransportProtocolListener.java │ │ │ ├── package.html │ │ │ ├── KBIRequestHandler.java │ │ │ ├── SignatureGenerator.java │ │ │ ├── GlobalRequestHandler.java │ │ │ ├── GlobalRequest.java │ │ │ ├── KBIPrompt.java │ │ │ ├── AuthenticationResult.java │ │ │ ├── ChannelFactory.java │ │ │ ├── BannerDisplay.java │ │ │ └── AuthenticationClient.java │ │ │ ├── zlib │ │ │ └── OpenSSHZLibCompression.java │ │ │ ├── util │ │ │ ├── package.html │ │ │ ├── EOLProcessorOutputStream.java │ │ │ ├── SimpleASNWriter.java │ │ │ ├── EOLProcessorInputStream.java │ │ │ └── SimpleASNReader.java │ │ │ ├── sftp │ │ │ ├── package.html │ │ │ ├── TransferCancelledException.java │ │ │ ├── SftpMessage.java │ │ │ ├── ACL.java │ │ │ ├── RegularExpressionMatching.java │ │ │ ├── NoRegExpMatching.java │ │ │ └── FileTransferProgress.java │ │ │ ├── net │ │ │ ├── package.html │ │ │ ├── HttpRequest.java │ │ │ ├── SocketWrapper.java │ │ │ └── SocketTransport.java │ │ │ ├── publickey │ │ │ ├── package.html │ │ │ ├── InvalidPassphraseException.java │ │ │ ├── PublicKeySubsystemException.java │ │ │ ├── SshPublicKeyFile.java │ │ │ └── SECSHPublicKeyFile.java │ │ │ ├── events │ │ │ ├── EventListener.java │ │ │ ├── EventService.java │ │ │ ├── J2SSHEventMessages.java │ │ │ └── EventObject.java │ │ │ └── scp │ │ │ └── package.html │ │ └── socks │ │ ├── AuthenticationNone.java │ │ ├── SocketWrappedChannel.java │ │ ├── server │ │ └── UserValidation.java │ │ ├── UDPEncapsulation.java │ │ └── Authentication.java └── .classpath └── README.md /j2ssh-maverick/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /.settings/ 3 | /.metadata/ 4 | /RemoteSystemsTempFiles/ 5 | -------------------------------------------------------------------------------- /j2ssh-maverick/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | j2ssh-maverick 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /j2ssh-maverick/templates/GPL-3.txt: -------------------------------------------------------------------------------- 1 | Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 2 | 3 | For product documentation visit https://www.sshtools.com/ 4 | 5 | This file is part of ${project.name}. 6 | 7 | ${project.name} is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | ${project.name} is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with ${project.name}. If not, see . -------------------------------------------------------------------------------- /j2ssh-maverick/README: -------------------------------------------------------------------------------- 1 | Introduction 2 | ------------ 3 | 4 | J2SSH Maverick is the successor to the original J2SSH API and includes a complete and stable implementation of an SSH2 client. Originally built from the ground up by the original author back in 2003, this product has, until now, only been available under a commercial license. With the development and pending release of a third generation SSH API, this legacy API has now been released under the GPLv3 and will continue to be maintained by the core author as a contribution to the open source community. 5 | 6 | Getting Started 7 | --------------- 8 | 9 | You need to include the core j2ssh-maverick-${version}.jar from this archives dist folder, along with any dependency jar files found in the lib folder. 10 | 11 | Check out the examples folder for a number of useful working examples. 12 | 13 | Support 14 | ------- 15 | 16 | The author does not guarantee to provide timely support for this project. Please post your question on stack overflow with 'j2ssh' tag. 17 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/logging/LoggerLevel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.logging; 22 | 23 | public enum LoggerLevel { 24 | ERROR, INFO, DEBUG 25 | } 26 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/message/Message.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.message; 22 | 23 | public interface Message { 24 | 25 | public int getMessageId(); 26 | } 27 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/AbstractKeyExchange.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | public interface AbstractKeyExchange { 24 | public String getProvider(); 25 | } 26 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/AbstractPublicKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | public interface AbstractPublicKey { 24 | public String getProvider(); 25 | } 26 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/message/MessageObserver.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.message; 22 | 23 | public interface MessageObserver { 24 | 25 | public boolean wantsNotification(Message msg); 26 | } 27 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/message/MessageStore.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.message; 22 | 23 | public interface MessageStore { 24 | 25 | public Message hasMessage(MessageObserver observer); 26 | } 27 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/Client.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh; 22 | 23 | import java.io.IOException; 24 | 25 | public interface Client { 26 | 27 | public void exit() throws SshException, IOException; 28 | } 29 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/message/MessageHolder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.message; 22 | 23 | public class MessageHolder { 24 | 25 | public Message msg = null; 26 | 27 | public MessageHolder() { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh2/MaverickCallbackHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh2; 22 | 23 | public interface MaverickCallbackHandler { 24 | public void setUser(String uname); 25 | 26 | public void setPassword(String pword); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /j2ssh-maverick/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/zlib/OpenSSHZLibCompression.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.zlib; 22 | 23 | public class OpenSSHZLibCompression extends ZLibCompression { 24 | 25 | public String getAlgorithm() { 26 | return "zlib@openssh.com"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh2/TransportProtocolListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh2; 22 | 23 | public interface TransportProtocolListener { 24 | 25 | public void onDisconnect(String msg, int reason); 26 | 27 | public void onIdle(long lastActivity); 28 | } 29 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/SshKeyExchange.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components; 22 | 23 | /** 24 | * Base interface for SSH2 key exchange implementations. 25 | * 26 | * @author Lee David Painter 27 | * 28 | */ 29 | public interface SshKeyExchange { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/DiffieHellmanEcdhNistp256.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | public class DiffieHellmanEcdhNistp256 extends DiffieHellmanEcdh { 24 | 25 | public DiffieHellmanEcdhNistp256() { 26 | super("ecdh-sha2-nistp256", "secp256r1", "SHA-256"); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/DiffieHellmanEcdhNistp384.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | public class DiffieHellmanEcdhNistp384 extends DiffieHellmanEcdh { 24 | 25 | public DiffieHellmanEcdhNistp384() { 26 | super("ecdh-sha2-nistp384", "secp384r1", "SHA-384"); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/DiffieHellmanEcdhNistp521.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | public class DiffieHellmanEcdhNistp521 extends DiffieHellmanEcdh { 24 | 25 | public DiffieHellmanEcdhNistp521() { 26 | super("ecdh-sha2-nistp521", "secp521r1", "SHA-512"); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/logging/Logger.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.logging; 22 | 23 | public interface Logger { 24 | 25 | boolean isLevelEnabled(LoggerLevel level); 26 | 27 | void log(LoggerLevel level, Object source, String msg); 28 | 29 | void log(LoggerLevel level, Object source, String msg, Throwable t); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/AES128Ctr.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.io.IOException; 24 | 25 | public class AES128Ctr extends AbstractJCECipher { 26 | 27 | public AES128Ctr() throws IOException { 28 | super(JCEAlgorithms.JCE_AESCTRNOPADDING, "AES", 16, "aes128-ctr"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/message/SshMessageReader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.message; 22 | 23 | import com.sshtools.ssh.SshException; 24 | 25 | /** 26 | * @author Lee David Painter 27 | */ 28 | public interface SshMessageReader { 29 | public byte[] nextMessage() throws SshException; 30 | 31 | public boolean isConnected(); 32 | } 33 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/AES192Ctr.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.io.IOException; 24 | 25 | public class AES192Ctr extends AbstractJCECipher { 26 | 27 | public AES192Ctr() throws IOException { 28 | super(JCEAlgorithms.JCE_AESCTRNOPADDING, "AES", 24, "aes192-ctr"); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/AES256Ctr.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.io.IOException; 24 | 25 | public class AES256Ctr extends AbstractJCECipher { 26 | 27 | public AES256Ctr() throws IOException { 28 | super(JCEAlgorithms.JCE_AESCTRNOPADDING, "AES", 32, "aes256-ctr"); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/util/package.html: -------------------------------------------------------------------------------- 1 | 23 | 24 | 25 | 26 | 30 | 31 | 32 |

A set of SSHTools utility classes. 33 |

34 | 35 | 36 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/Ssh2EcdsaSha2Nist256PublicKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | 24 | public class Ssh2EcdsaSha2Nist256PublicKey extends Ssh2EcdsaSha2NistPublicKey { 25 | 26 | public Ssh2EcdsaSha2Nist256PublicKey() { 27 | super("ecdsa-sha2-nistp256", "SHA256withECDSA", "secp256r1"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/Ssh2EcdsaSha2Nist384PublicKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | 24 | public class Ssh2EcdsaSha2Nist384PublicKey extends Ssh2EcdsaSha2NistPublicKey { 25 | 26 | public Ssh2EcdsaSha2Nist384PublicKey() { 27 | super("ecdsa-sha2-nistp384", "SHA384withECDSA", "secp384r1"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/Ssh2EcdsaSha2Nist521PublicKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | 24 | public class Ssh2EcdsaSha2Nist521PublicKey extends Ssh2EcdsaSha2NistPublicKey { 25 | 26 | public Ssh2EcdsaSha2Nist521PublicKey() { 27 | super("ecdsa-sha2-nistp521", "SHA512withECDSA", "secp521r1"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/sftp/package.html: -------------------------------------------------------------------------------- 1 | 23 | 24 | 25 | 26 | 30 | 31 | 32 |

The base implementation of the SFTP protocol.
33 |

34 | 35 | 36 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/net/package.html: -------------------------------------------------------------------------------- 1 | 23 | 24 | 25 | 26 | 30 | 31 | 32 |

This package contains a set of network utilities for the J2SSH Maverick API. 33 |

34 | 35 | 36 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/compression/package.html: -------------------------------------------------------------------------------- 1 | 23 | 24 | 25 | 29 | 30 |

Compression interface for the SSH Transport Protocol.

31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/logging/NoLogger.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.logging; 22 | 23 | public class NoLogger implements Logger { 24 | 25 | public boolean isLevelEnabled(LoggerLevel level) { 26 | return false; 27 | } 28 | 29 | public void log(LoggerLevel level, Object source, String msg) { 30 | 31 | } 32 | 33 | public void log(LoggerLevel level, Object source, String msg, Throwable t) { 34 | 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/MD5Digest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.security.NoSuchAlgorithmException; 24 | 25 | /** 26 | * MD5 digest implementation. 27 | * 28 | * @author Lee David Painter 29 | * 30 | */ 31 | public class MD5Digest extends AbstractDigest { 32 | 33 | public MD5Digest() throws NoSuchAlgorithmException { 34 | super(JCEAlgorithms.JCE_MD5); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/HmacMD5.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | /** 24 | * MD5 message authentication implementation. 25 | * 26 | * @author Lee David Painter 27 | * 28 | */ 29 | public class HmacMD5 extends AbstractHmac { 30 | 31 | public HmacMD5() { 32 | super(JCEAlgorithms.JCE_HMACMD5, 16); 33 | } 34 | 35 | public String getAlgorithm() { 36 | return "hmac-md5"; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/SHA1Digest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.security.NoSuchAlgorithmException; 24 | 25 | /** 26 | * SHA-1 digest implementation. 27 | * 28 | * @author Lee David Painter 29 | * 30 | */ 31 | public class SHA1Digest extends AbstractDigest { 32 | 33 | public SHA1Digest() throws NoSuchAlgorithmException { 34 | super(JCEAlgorithms.JCE_SHA1); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/SHA384Digest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.security.NoSuchAlgorithmException; 24 | 25 | /** 26 | * SHA-1 digest implementation. 27 | * @author Lee David Painter 28 | * 29 | */ 30 | public class SHA384Digest extends AbstractDigest { 31 | 32 | public SHA384Digest() throws NoSuchAlgorithmException { 33 | super(JCEAlgorithms.JCE_SHA384); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/SHA512Digest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.security.NoSuchAlgorithmException; 24 | 25 | /** 26 | * SHA-1 digest implementation. 27 | * @author Lee David Painter 28 | * 29 | */ 30 | public class SHA512Digest extends AbstractDigest { 31 | 32 | public SHA512Digest() throws NoSuchAlgorithmException { 33 | super(JCEAlgorithms.JCE_SHA512); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/HmacMD596.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | /** 24 | * MD5 message authentication implementation. 25 | * 26 | * @author Lee David Painter 27 | * 28 | */ 29 | public class HmacMD596 extends AbstractHmac { 30 | 31 | public HmacMD596() { 32 | super(JCEAlgorithms.JCE_HMACMD5, 16, 12); 33 | } 34 | 35 | public String getAlgorithm() { 36 | return "hmac-md5"; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/SHA256Digest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.security.NoSuchAlgorithmException; 24 | 25 | /** 26 | * SHA-1 digest implementation. 27 | * 28 | * @author Lee David Painter 29 | * 30 | */ 31 | public class SHA256Digest extends AbstractDigest { 32 | 33 | public SHA256Digest() throws NoSuchAlgorithmException { 34 | super(JCEAlgorithms.JCE_SHA256); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/package.html: -------------------------------------------------------------------------------- 1 | 23 | 24 | 25 | 26 | 30 | 31 | 32 |

This package contains a set of algoritm implementations that enable the Maverick API 33 | to use a Java Cryptography Extension provider. 34 |

35 | 36 | 37 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/AES128Cbc.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.io.IOException; 24 | 25 | /** 26 | * An implementation of the AES 128 bit cipher using a JCE provider. 27 | * 28 | * @author Lee David Painter 29 | */ 30 | public class AES128Cbc extends AbstractJCECipher { 31 | 32 | public AES128Cbc() throws IOException { 33 | super(JCEAlgorithms.JCE_AESCBCNOPADDING, "AES", 16, "aes128-cbc"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/AES192Cbc.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.io.IOException; 24 | 25 | /** 26 | * An implementation of the AES 128 bit cipher using a JCE provider. 27 | * 28 | * @author Lee David Painter 29 | */ 30 | public class AES192Cbc extends AbstractJCECipher { 31 | 32 | public AES192Cbc() throws IOException { 33 | super(JCEAlgorithms.JCE_AESCBCNOPADDING, "AES", 24, "aes192-cbc"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/AES256Cbc.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.io.IOException; 24 | 25 | /** 26 | * An implementation of the AES 128 bit cipher using a JCE provider. 27 | * 28 | * @author Lee David Painter 29 | */ 30 | public class AES256Cbc extends AbstractJCECipher { 31 | 32 | public AES256Cbc() throws IOException { 33 | super(JCEAlgorithms.JCE_AESCBCNOPADDING, "AES", 32, "aes256-cbc"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/TripleDesCbc.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.io.IOException; 24 | 25 | /** 26 | * An implementation of the 3DES cipher using a JCE provider. 27 | * 28 | * @author Lee David Painter 29 | */ 30 | public class TripleDesCbc extends AbstractJCECipher { 31 | 32 | public TripleDesCbc() throws IOException { 33 | super(JCEAlgorithms.JCE_3DESCBCNOPADDING, "DESede", 24, "3des-cbc"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/TripleDesCtr.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.io.IOException; 24 | 25 | /** 26 | * An implementation of the 3DES cipher using a JCE provider. 27 | * 28 | * @author Lee David Painter 29 | */ 30 | public class TripleDesCtr extends AbstractJCECipher { 31 | 32 | public TripleDesCtr() throws IOException { 33 | super(JCEAlgorithms.JCE_3DESCTRNOPADDING, "DESede", 24, "3des-ctr"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh2/package.html: -------------------------------------------------------------------------------- 1 | 23 | 24 | 25 | 26 | 30 | 31 | 32 |

This package contains an SSH2 implementation of the 33 | com.sshtools.ssh interfaces. 34 |

35 | 36 | 37 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/publickey/package.html: -------------------------------------------------------------------------------- 1 | 23 | 24 | 25 | 26 | 30 | 31 | 32 |

This package contains utility classes for loading/storing public/private keys 33 | and is based on the SSHTools key format architecture. 34 |

35 | 36 | 37 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/events/EventListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.events; 22 | 23 | /** 24 | * Interface to be implemented by classes interested in receiving events. 25 | *

26 | * Listeners should be registered by using 27 | * EventService#addListener(EventListener). 28 | */ 29 | public interface EventListener { 30 | 31 | /** 32 | * Invoked when an event occurs. 33 | * 34 | * @param evt 35 | * event 36 | */ 37 | public void processEvent(Event evt); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/SshDsaPublicKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components; 22 | 23 | import java.math.BigInteger; 24 | 25 | /** 26 | * This interface should be implemented by all DSA public key implementations. 27 | * 28 | * @author Lee David Painter 29 | * 30 | */ 31 | public interface SshDsaPublicKey extends SshPublicKey { 32 | public BigInteger getP(); 33 | 34 | public BigInteger getQ(); 35 | 36 | public BigInteger getG(); 37 | 38 | public BigInteger getY(); 39 | } 40 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/sftp/TransferCancelledException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.sftp; 22 | 23 | /** 24 | *

25 | * Exception thrown when a file transfer is cancelled. 26 | *

27 | * 28 | * @author Lee David Painter 29 | */ 30 | public class TransferCancelledException extends Exception { 31 | 32 | private static final long serialVersionUID = 1L; 33 | 34 | /** 35 | * Creates a new TransferCancelledException object. 36 | */ 37 | public TransferCancelledException() { 38 | super(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/scp/package.html: -------------------------------------------------------------------------------- 1 | 23 | 24 | 25 | 26 | 30 | 31 | 32 |

33 | This package contains a Secure Copy (SCP) engine suitable for the 34 | lightweight J2SSH Maverick API. This implementation has no 35 | dependencies on files making it suitable for all JAVA platforms. 36 |

37 | 38 | 39 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/SshSecureRandomGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components; 22 | 23 | import com.sshtools.ssh.SshException; 24 | 25 | /** 26 | * This interface should be implemented by all secure random number generator 27 | * implementations. 28 | * 29 | * @author Lee David Painter 30 | * 31 | */ 32 | public interface SshSecureRandomGenerator { 33 | 34 | void nextBytes(byte[] bytes); 35 | 36 | void nextBytes(byte[] bytes, int off, int len) throws SshException; 37 | 38 | int nextInt(); 39 | } -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/DiffieHellmanGroupExchangeSha256.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | public class DiffieHellmanGroupExchangeSha256 extends 24 | DiffieHellmanGroupExchangeSha1 { 25 | 26 | public static final String DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA256 = "diffie-hellman-group-exchange-sha256"; 27 | 28 | public DiffieHellmanGroupExchangeSha256() { 29 | super("SHA-256"); 30 | } 31 | 32 | public String getAlgorithm() { 33 | return DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA256; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/SshRsaPrivateKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components; 22 | 23 | import java.io.IOException; 24 | import java.math.BigInteger; 25 | 26 | /** 27 | * This interface should be implemented by all RSA private key implementations. 28 | * 29 | * @author Lee David Painter 30 | */ 31 | public interface SshRsaPrivateKey extends SshPrivateKey { 32 | 33 | public abstract BigInteger getModulus(); 34 | 35 | public abstract BigInteger getPrivateExponent(); 36 | 37 | public abstract byte[] sign(byte[] msg) throws IOException; 38 | 39 | } -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/SshRsaPublicKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components; 22 | 23 | import java.math.BigInteger; 24 | 25 | import com.sshtools.ssh.SshException; 26 | 27 | /** 28 | * This interface should be implemented by all RSA public key implementations. 29 | * 30 | * @author Lee David Painter 31 | */ 32 | public interface SshRsaPublicKey extends SshPublicKey { 33 | BigInteger getModulus(); 34 | 35 | BigInteger getPublicExponent(); 36 | 37 | int getVersion(); 38 | 39 | public BigInteger doPublic(BigInteger input) throws SshException; 40 | } 41 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/BlowfishCbc.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.io.IOException; 24 | 25 | /** 26 | * An implementation of the Blowfish cipher using a JCE provider. If you have 27 | * enabled JCE usage there is no need to configure this separately. 28 | * 29 | * @author Lee David Painter 30 | */ 31 | public class BlowfishCbc extends AbstractJCECipher { 32 | 33 | public BlowfishCbc() throws IOException { 34 | super(JCEAlgorithms.JCE_BLOWFISHCBCNOPADDING, "Blowfish", 16, 35 | "blowfish-cbc"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/SshPrivateKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components; 22 | 23 | import java.io.IOException; 24 | 25 | import com.sshtools.ssh.SshException; 26 | 27 | /** 28 | * Interface for SSH supported private keys. 29 | * 30 | * @author Lee David Painter 31 | */ 32 | public interface SshPrivateKey { 33 | 34 | /** 35 | * Create a signature from the data. 36 | * 37 | * @param data 38 | * @return byte[] 39 | * @throws SshException 40 | */ 41 | public byte[] sign(byte[] data) throws IOException; 42 | 43 | public String getAlgorithm(); 44 | } 45 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/package.html: -------------------------------------------------------------------------------- 1 | 23 | 24 | 25 | 26 | 30 | 31 | 32 |

This package contains an abstract cryptographic provider for the SSH protocol. No actual 33 | provider is implemented here, this is simply a set of interfaces that require a concrete 34 | implementation to perform the actual cryptographic functions.

35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpMessage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.sftp; 22 | 23 | import java.io.IOException; 24 | 25 | import com.sshtools.ssh.message.Message; 26 | import com.sshtools.util.ByteArrayReader; 27 | 28 | public class SftpMessage extends ByteArrayReader implements Message { 29 | 30 | int type; 31 | int requestId; 32 | 33 | SftpMessage(byte[] msg) throws IOException { 34 | super(msg); 35 | type = read(); 36 | requestId = (int) readInt(); 37 | } 38 | 39 | public int getType() { 40 | return type; 41 | } 42 | 43 | public int getMessageId() { 44 | return requestId; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/logging/LoggerFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.logging; 22 | 23 | public class LoggerFactory { 24 | 25 | static Logger logger = new NoLogger(); 26 | 27 | static boolean enabled = false; 28 | 29 | public static void setInstance(Logger logger) { 30 | LoggerFactory.logger = logger; 31 | enabled = true; 32 | } 33 | 34 | public static Logger getInstance() { 35 | return logger; 36 | } 37 | 38 | public static boolean isEnabled() { 39 | return enabled; 40 | } 41 | 42 | public static void enable() { 43 | enabled = true; 44 | } 45 | 46 | public static void disable() { 47 | enabled = false; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/publickey/InvalidPassphraseException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.publickey; 22 | 23 | /** 24 | * 25 | *

26 | * Thrown by an {@link SshPrivateKeyFile} when it detects that the passphrase 27 | * supplied was invalid. 28 | *

29 | * 30 | * @author Lee David Painter 31 | */ 32 | public class InvalidPassphraseException extends Exception { 33 | 34 | private static final long serialVersionUID = 1L; 35 | 36 | public InvalidPassphraseException() { 37 | super("The passphrase supplied was invalid!"); 38 | } 39 | 40 | public InvalidPassphraseException(Exception ex) { 41 | super(ex.getMessage()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/package.html: -------------------------------------------------------------------------------- 1 | 23 | 24 | 25 | 26 | 30 | 31 | 32 |

This package contains a set of general interface contracts for SSH communication. 33 | To connect to an SSH server you need to use SshConnector to get a reference to an 34 | SshClient. Once a client instance is obtained you can proceed to authenticate 35 | the user and start a session. 36 |

37 | 38 | 39 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/SshDsaPrivateKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components; 22 | 23 | import java.io.IOException; 24 | import java.math.BigInteger; 25 | 26 | /** 27 | * This interface should be implemented by all DSA private key implementations. 28 | * 29 | * @author Lee David Painter 30 | * 31 | */ 32 | public interface SshDsaPrivateKey extends SshPrivateKey { 33 | 34 | public abstract BigInteger getX(); 35 | 36 | /* 37 | * (non-Javadoc) 38 | * 39 | * @see com.sshtools.ssh.SshPrivateKey#sign(byte[]) 40 | */ 41 | public abstract byte[] sign(byte[] msg) throws IOException; 42 | 43 | public SshDsaPublicKey getPublicKey(); 44 | 45 | } -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/net/HttpRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.net; 22 | 23 | import com.sshtools.util.Base64; 24 | 25 | /** 26 | * Utility class to process HTTP requests. 27 | * 28 | * @author Lee David Painter 29 | * 30 | */ 31 | public class HttpRequest extends HttpHeader { 32 | 33 | public HttpRequest() { 34 | super(); 35 | } 36 | 37 | public void setHeaderBegin(String begin) { 38 | this.begin = begin; 39 | } 40 | 41 | public void setBasicAuthentication(String username, String password) { 42 | String str = username + ":" + password; 43 | setHeaderField("Proxy-Authorization", 44 | "Basic " + Base64.encodeBytes(str.getBytes(), true)); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/logging/SimpleLogger.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.logging; 22 | 23 | public class SimpleLogger implements Logger { 24 | 25 | LoggerLevel level; 26 | 27 | public SimpleLogger(LoggerLevel level) { 28 | this.level = level; 29 | } 30 | 31 | public boolean isLevelEnabled(LoggerLevel level) { 32 | return this.level.ordinal() >= level.ordinal(); 33 | } 34 | 35 | public void log(LoggerLevel level, Object source, String msg) { 36 | System.out.println(level.toString() + ": " + msg); 37 | } 38 | 39 | public void log(LoggerLevel level, Object source, String msg, Throwable t) { 40 | System.out.println(level.toString() + ": " + msg); 41 | t.printStackTrace(); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/socks/AuthenticationNone.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | /** 22 | * This file is originally from the http://sourceforge.net/projects/jsocks/ 23 | * released under the LGPL. 24 | */ 25 | package socks; 26 | 27 | /** 28 | SOCKS5 none authentication. Dummy class does almost nothing. 29 | */ 30 | public class AuthenticationNone implements Authentication{ 31 | 32 | public Object[] doSocksAuthentication(int methodId, 33 | java.net.Socket proxySocket) 34 | throws java.io.IOException{ 35 | 36 | if(methodId!=0) return null; 37 | 38 | return new Object[] { proxySocket.getInputStream(), 39 | proxySocket.getOutputStream()}; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/SocketTimeoutSupport.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh; 22 | 23 | import java.io.IOException; 24 | 25 | /** 26 | *

27 | * This interface adds timeout support to the {@see SocketTransport} interface. 28 | *

29 | * 30 | * @author Lee David Painter 31 | */ 32 | public interface SocketTimeoutSupport { 33 | 34 | /** 35 | * Set the socket timeout in milliseconds. 36 | * 37 | * @param timeout 38 | * int 39 | * @throws IOException 40 | */ 41 | public void setSoTimeout(int timeout) throws IOException; 42 | 43 | /** 44 | * Get the current socket timeout in milliseconds. 45 | * 46 | * @return int 47 | * @throws IOException 48 | */ 49 | public int getSoTimeout() throws IOException; 50 | } 51 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/message/SshMessage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.message; 22 | 23 | import com.sshtools.util.ByteArrayReader; 24 | 25 | /** 26 | * 27 | * @author Lee David Painter 28 | */ 29 | public class SshMessage extends ByteArrayReader implements Message { 30 | 31 | int messageid; 32 | byte[] msg; 33 | SshMessage next; 34 | SshMessage previous; 35 | 36 | // Private constrcutor for Linked List 37 | SshMessage() { 38 | super(new byte[] {}); 39 | } 40 | 41 | public SshMessage(byte[] msg, int off, int len) { 42 | super(msg, off, len); 43 | } 44 | 45 | public SshMessage(byte[] msg) { 46 | super(msg); 47 | this.messageid = read(); 48 | } 49 | 50 | public int getMessageId() { 51 | return messageid; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/SshRsaPrivateCrtKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components; 22 | 23 | import java.math.BigInteger; 24 | 25 | import com.sshtools.ssh.SshException; 26 | 27 | /** 28 | * This interface should be implemented by all RSA private co-efficient private 29 | * key implementations. 30 | * 31 | * @author Lee David Painter 32 | */ 33 | public interface SshRsaPrivateCrtKey extends SshRsaPrivateKey { 34 | 35 | public BigInteger getPublicExponent(); 36 | 37 | public BigInteger getPrimeP(); 38 | 39 | public BigInteger getPrimeQ(); 40 | 41 | public BigInteger getPrimeExponentP(); 42 | 43 | public BigInteger getPrimeExponentQ(); 44 | 45 | public BigInteger getCrtCoefficient(); 46 | 47 | BigInteger doPrivate(BigInteger input) throws SshException; 48 | } -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/SshHmac.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components; 22 | 23 | import com.sshtools.ssh.SshException; 24 | 25 | /** 26 | * This interface should be implemented by all message authentication 27 | * implementations. 28 | * 29 | * @author Lee David Painter 30 | * 31 | */ 32 | public interface SshHmac { 33 | 34 | public int getMacLength(); 35 | 36 | public void generate(long sequenceNo, byte[] data, int offset, int len, 37 | byte[] output, int start); 38 | 39 | public void init(byte[] keydata) throws SshException; 40 | 41 | public boolean verify(long sequenceNo, byte[] data, int start, int len, 42 | byte[] mac, int offset); 43 | 44 | public void update(byte[] b); 45 | 46 | public byte[] doFinal(); 47 | 48 | public String getAlgorithm(); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/NoneHmac.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components; 22 | 23 | import com.sshtools.ssh.SshException; 24 | 25 | public class NoneHmac implements SshHmac { 26 | 27 | public int getMacLength() { 28 | return 0; 29 | } 30 | 31 | public void generate(long sequenceNo, byte[] data, int offset, int len, 32 | byte[] output, int start) { 33 | } 34 | 35 | public void init(byte[] keydata) throws SshException { 36 | } 37 | 38 | public boolean verify(long sequenceNo, byte[] data, int start, int len, 39 | byte[] mac, int offset) { 40 | return true; 41 | } 42 | 43 | public void update(byte[] b) { 44 | } 45 | 46 | public byte[] doFinal() { 47 | 48 | return new byte[0]; 49 | } 50 | 51 | public String getAlgorithm() { 52 | return "none"; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/util/EOLProcessorOutputStream.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.util; 22 | 23 | import java.io.IOException; 24 | import java.io.OutputStream; 25 | 26 | class EOLProcessorOutputStream extends OutputStream { 27 | 28 | EOLProcessor processor; 29 | 30 | public EOLProcessorOutputStream(int inputStyle, int outputStyle, 31 | OutputStream out) throws IOException { 32 | processor = new EOLProcessor(inputStyle, outputStyle, out); 33 | } 34 | 35 | public void write(byte[] buf, int off, int len) throws IOException { 36 | processor.processBytes(buf, off, len); 37 | } 38 | 39 | public void write(int b) throws IOException { 40 | processor.processBytes(new byte[] { (byte) b }, 0, 1); 41 | } 42 | 43 | public void close() throws IOException { 44 | processor.close(); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/message/SshChannelMessage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.message; 22 | 23 | import java.io.IOException; 24 | 25 | import com.sshtools.ssh.SshException; 26 | 27 | /** 28 | * @author Lee David Painter 29 | */ 30 | public class SshChannelMessage extends SshMessage { 31 | 32 | int channelid; 33 | 34 | public SshChannelMessage(int channelid, byte[] msg, int off, int len) 35 | throws SshException { 36 | super(msg, off, len); 37 | this.channelid = channelid; 38 | } 39 | 40 | public SshChannelMessage(byte[] msg) throws SshException { 41 | super(msg); 42 | try { 43 | this.channelid = (int) readInt(); 44 | } catch (IOException ex) { 45 | throw new SshException(SshException.INTERNAL_ERROR, ex); 46 | } 47 | } 48 | 49 | int getChannelId() { 50 | return channelid; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/socks/SocketWrappedChannel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | /** 22 | * This file is originally from the http://sourceforge.net/projects/jsocks/ 23 | * released under the LGPL. 24 | */ 25 | package socks; 26 | 27 | import java.io.IOException; 28 | import java.io.InputStream; 29 | import java.io.OutputStream; 30 | import java.net.Socket; 31 | 32 | import com.sshtools.ssh.SshChannel; 33 | 34 | public class SocketWrappedChannel extends Socket { 35 | 36 | SshChannel channel; 37 | SocketWrappedChannel(SshChannel channel) { 38 | this.channel = channel; 39 | } 40 | 41 | public InputStream getInputStream() throws IOException { 42 | return channel.getInputStream(); 43 | } 44 | 45 | public OutputStream getOutputStream() throws IOException { 46 | return channel.getOutputStream(); 47 | } 48 | 49 | public void close() throws IOException { 50 | channel.close(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/SshIOException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh; 22 | 23 | import java.io.IOException; 24 | 25 | /** 26 | * This class is provided so that when a channel InputStream/OutputStream 27 | * interface has to throw an IOException; the real SshException cause can be 28 | * retrieved. 29 | * 30 | * @author Lee David Painter 31 | */ 32 | public class SshIOException extends IOException { 33 | 34 | private static final long serialVersionUID = 1L; 35 | SshException realEx; 36 | 37 | /** 38 | * Construct the exception with the real exception. 39 | * 40 | * @param realEx 41 | */ 42 | public SshIOException(SshException realEx) { 43 | this.realEx = realEx; 44 | } 45 | 46 | /** 47 | * Get the real exception 48 | * 49 | * @return SshException 50 | */ 51 | public SshException getRealException() { 52 | return realEx; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/sftp/ACL.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.sftp; 22 | 23 | /** 24 | * Version 4 of the SFTP protocol introduces an ACL field in the 25 | * {@link SftpFileAttributes} structure. 26 | * 27 | * @author Lee David Painter 28 | */ 29 | public class ACL { 30 | 31 | public static final int ACL_ALLOWED_TYPE = 1; 32 | public static final int ACL_DENIED_TYPE = 1; 33 | public static final int ACL_AUDIT_TYPE = 1; 34 | public static final int ACL_ALARM_TYPE = 1; 35 | 36 | int type; 37 | int flags; 38 | int mask; 39 | String who; 40 | 41 | public ACL(int type, int flags, int mask, String who) { 42 | } 43 | 44 | public int getType() { 45 | return type; 46 | } 47 | 48 | public int getFlags() { 49 | return flags; 50 | } 51 | 52 | public int getMask() { 53 | return mask; 54 | } 55 | 56 | public String getWho() { 57 | return who; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh2/KBIRequestHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh2; 22 | 23 | /** 24 | * 25 | * Callback interface used by the KBIAuthentication authentication mechanism. 27 | * 28 | * @author $author$ 29 | */ 30 | public interface KBIRequestHandler { 31 | /** 32 | * Called by the keyboard-interactive authentication mechanism when 33 | * the server requests information from the user. Each prompt should be 34 | * displayed to the user with their response recorded within the prompt 35 | * object. 36 | * 37 | * @param name 38 | * @param instruction 39 | * @param prompts 40 | * @return true if the user entered the prompts, or false 41 | * if the user cancelled the authentication attempt. 42 | */ 43 | public boolean showPrompts(String name, String instruction, 44 | KBIPrompt[] prompts); 45 | } 46 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh2/SignatureGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh2; 22 | 23 | import java.io.IOException; 24 | 25 | import com.sshtools.ssh.SshException; 26 | import com.sshtools.ssh.components.SshPublicKey; 27 | 28 | /** 29 | * Provides a callback when a private key signature is required. This is 30 | * suitable for use when you do not have direct access to the private key, but 31 | * know its public key and have access to some mechanism that enables you to 32 | * request a signature from the corresponding private key (such as an ssh 33 | * agent). 34 | * 35 | * @author $Author: david $ 36 | */ 37 | public interface SignatureGenerator { 38 | 39 | /** 40 | * Sign the data using the private key of the public key provided. 41 | * 42 | * @param key 43 | * @param data 44 | * @return byte[] 45 | * @throws IOException 46 | */ 47 | public byte[] sign(SshPublicKey key, byte[] data) throws SshException; 48 | } 49 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/SshIO.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh; 22 | 23 | import java.io.IOException; 24 | import java.io.InputStream; 25 | import java.io.OutputStream; 26 | 27 | /** 28 | *

29 | * Base interface for all SSH related IO interfaces. 30 | *

31 | * 32 | * @author Lee David Painter 33 | */ 34 | public interface SshIO { 35 | 36 | /** 37 | * Get an InputStream to read incoming channel data. 38 | * 39 | * @return the channels InputStream 40 | * @throws IOException 41 | */ 42 | public InputStream getInputStream() throws IOException; 43 | 44 | /** 45 | * Get an OutputStream to write outgoing channel data. 46 | * 47 | * @return the channels OutputStream 48 | * @throws IOException 49 | */ 50 | public OutputStream getOutputStream() throws IOException; 51 | 52 | /** 53 | * Close the channel. 54 | * 55 | * @throws SshIOException 56 | */ 57 | public void close() throws IOException; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/publickey/PublicKeySubsystemException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.publickey; 22 | 23 | /** 24 | * Exception thrown by the {@link PublicKeySubsystem} when errors occur in 25 | * listing, adding or removing keys. 26 | * 27 | * @author Lee David Painter 28 | */ 29 | public class PublicKeySubsystemException extends Exception { 30 | 31 | private static final long serialVersionUID = 1L; 32 | static final int SUCCESS = 0; 33 | public static final int ACCESS_DENIED = 1; 34 | public static final int STORAGE_EXCEEDED = 2; 35 | public static final int REQUEST_NOT_SUPPPORTED = 3; 36 | public static final int KEY_NOT_FOUND = 4; 37 | public static final int KEY_NOT_SUPPORTED = 5; 38 | public static final int GENERAL_FAILURE = 6; 39 | 40 | int status; 41 | 42 | public PublicKeySubsystemException(int status, String desc) { 43 | super(desc); 44 | this.status = status; 45 | } 46 | 47 | public int getStatus() { 48 | return status; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/publickey/SshPublicKeyFile.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.publickey; 22 | 23 | import java.io.IOException; 24 | 25 | import com.sshtools.ssh.components.SshPublicKey; 26 | 27 | /** 28 | * Interface which all public key formats must implement to provide decoding of 29 | * the public key into a suitable format for the API. 30 | * 31 | * @author Lee David Painter 32 | */ 33 | public interface SshPublicKeyFile { 34 | 35 | /** 36 | * Convert the key file into a usable SshPublicKey. 38 | * 39 | * @return SshPublicKey 40 | * @throws IOException 41 | */ 42 | public SshPublicKey toPublicKey() throws IOException; 43 | 44 | /** 45 | * Get the comment applied to the key file. 46 | * 47 | * @return String 48 | */ 49 | public String getComment(); 50 | 51 | /** 52 | * Get the formatted key. 53 | * 54 | * @return byte[] 55 | * @throws IOException 56 | */ 57 | public byte[] getFormattedKey() throws IOException; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh2/GlobalRequestHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh2; 22 | 23 | import java.io.IOException; 24 | 25 | import com.sshtools.ssh.SshException; 26 | 27 | /** 28 | *

29 | * There are several kinds of requests that affect the state of the remote end 30 | * "globally", independent of any channels, this interface defines the contract 31 | * for handling such global requests. 32 | *

33 | * 34 | * @author Lee David Painter 35 | */ 36 | public interface GlobalRequestHandler { 37 | 38 | /** 39 | * Return the supported request types. 40 | * 41 | * @return an array of Strings containing the supported request types. 42 | */ 43 | public String[] supportedRequests(); 44 | 45 | /** 46 | * Called when a supported global request has been recieved. 47 | * 48 | * @param request 49 | * @return true if the request succeeded, otherwise 50 | * false 51 | * @throws IOException 52 | */ 53 | public boolean processGlobalRequest(GlobalRequest request) 54 | throws SshException; 55 | } 56 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/socks/server/UserValidation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | /** 22 | * This file is originally from the http://sourceforge.net/projects/jsocks/ 23 | * released under the LGPL. 24 | */ 25 | package socks.server; 26 | 27 | /** 28 | Interface which provides for user validation, based on user name 29 | password and where it connects from. 30 | */ 31 | public interface UserValidation{ 32 | /** 33 | Implementations of this interface are expected to use some or all 34 | of the information provided plus any information they can extract 35 | from other sources to decide wether given user should be allowed 36 | access to SOCKS server, or whatever you use it for. 37 | 38 | @return true to indicate user is valid, false otherwise. 39 | @param username User whom implementation should validate. 40 | @param password Password this user provided. 41 | @param connection Socket which user used to connect to the server. 42 | */ 43 | boolean isUserValid(String username,String password, 44 | java.net.Socket connection); 45 | } 46 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/ChannelOpenException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh; 22 | 23 | /** 24 | * Exception thrown when a channel cannot be opened, the reason for which should 25 | * be specified in with any of the constants defined here. 26 | * 27 | * @author Lee David Painter 28 | */ 29 | public class ChannelOpenException extends Exception { 30 | 31 | private static final long serialVersionUID = 1L; 32 | 33 | /** The administrator does not permit this channel to be opened **/ 34 | public static final int ADMINISTRATIVIVELY_PROHIBITED = 1; 35 | 36 | /** The connection could not be established **/ 37 | public static final int CONNECT_FAILED = 2; 38 | 39 | /** The channel type is unknown **/ 40 | public static final int UNKNOWN_CHANNEL_TYPE = 3; 41 | 42 | /** There are no more resources available to open the channel **/ 43 | public static final int RESOURCE_SHORTAGE = 4; 44 | 45 | int reason; 46 | 47 | public ChannelOpenException(String msg, int reason) { 48 | super(msg); 49 | this.reason = reason; 50 | } 51 | 52 | public int getReason() { 53 | return reason; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/sftp/RegularExpressionMatching.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.sftp; 22 | 23 | import java.io.File; 24 | 25 | import com.sshtools.ssh.SshException; 26 | 27 | /** 28 | * Interface for treating a filename as a regular expression and returning the 29 | * list of files that match. 30 | * 31 | * @author David Hodgins 32 | */ 33 | public interface RegularExpressionMatching { 34 | 35 | /** 36 | * returns each of the SftpFiles that match the pattern fileNameRegExp 37 | * 38 | * @param files 39 | * @param fileNameRegExp 40 | * @return SftpFile[] 41 | * @throws SftpStatusException 42 | * @throws SshException 43 | */ 44 | public SftpFile[] matchFilesWithPattern(SftpFile[] files, 45 | String fileNameRegExp) throws SftpStatusException, SshException; 46 | 47 | /** 48 | * returns each of the files that match the pattern fileNameRegExp 49 | * 50 | * @param files 51 | * @param fileNameRegExp 52 | * @return String[] 53 | * @throws SftpStatusException 54 | * @throws SshException 55 | */ 56 | public String[] matchFileNamesWithPattern(File[] files, 57 | String fileNameRegExp) throws SftpStatusException, SshException; 58 | 59 | } -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/Packet.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh; 22 | 23 | import java.io.IOException; 24 | 25 | import com.sshtools.util.ByteArrayWriter; 26 | 27 | /** 28 | * A utility class that provides the SSH layers with the ability to dynamically 29 | * write an SSH packet. 30 | * 31 | * @author Lee David Painter 32 | */ 33 | public class Packet extends ByteArrayWriter { 34 | 35 | int markedPosition = -1; 36 | 37 | public Packet() throws IOException { 38 | this(35000); 39 | } 40 | 41 | public Packet(int size) throws IOException { 42 | super(size + 4); 43 | 44 | // Save some space for the length field 45 | writeInt(0); 46 | } 47 | 48 | public int setPosition(int pos) { 49 | int count = this.count; 50 | this.count = pos; 51 | return count; 52 | } 53 | 54 | public int position() { 55 | return count; 56 | } 57 | 58 | public void finish() { 59 | 60 | buf[0] = (byte) (count - 4 >> 24); 61 | buf[1] = (byte) (count - 4 >> 16); 62 | buf[2] = (byte) (count - 4 >> 8); 63 | buf[3] = (byte) (count - 4); 64 | 65 | } 66 | 67 | public void reset() { 68 | 69 | super.reset(); 70 | try { 71 | writeInt(0); 72 | } catch (IOException ex) { 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/sftp/NoRegExpMatching.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.sftp; 22 | 23 | import java.io.File; 24 | 25 | import com.sshtools.ssh.SshException; 26 | 27 | /** 28 | * Implements the RegularExpressionMatching Interface.
29 | * Performs no regular expression matching so:
30 | * matchFilesWithPattern() simply returns the files parameter it is passed as an 31 | * argument
32 | * matchFileNamesWithPattern() simply returns a 1 element array containing the 33 | * filename on the first element of the file[] argument passed to it. 34 | */ 35 | public class NoRegExpMatching implements RegularExpressionMatching { 36 | 37 | /** 38 | * opens and returns the requested filename string 39 | * 40 | * @throws SftpStatusException 41 | */ 42 | public String[] matchFileNamesWithPattern(File[] files, 43 | String fileNameRegExp) throws SshException, SftpStatusException { 44 | String[] thefile = new String[1]; 45 | thefile[0] = files[0].getName(); 46 | return thefile; 47 | } 48 | 49 | /** 50 | * returns files 51 | */ 52 | public SftpFile[] matchFilesWithPattern(SftpFile[] files, 53 | String fileNameRegExp) throws SftpStatusException, SshException { 54 | return files; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/events/EventService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.events; 22 | 23 | /** 24 | * Interface to be implemented by an event service implementation. 25 | */ 26 | public interface EventService { 27 | 28 | /** 29 | * Add a MaverickListener to the list of objects that will be sent 30 | * MaverickEvents. 31 | * 32 | * @param listener 33 | * listener to add 34 | */ 35 | public void addListener(EventListener listener); 36 | 37 | /** 38 | * Add a MaverickListener to the list of objects that will be sent 39 | * MaverickEvents. 40 | * 41 | * @param listener 42 | * listener to add 43 | */ 44 | public void addListener(String threadPrefix, EventListener listener); 45 | 46 | /** 47 | * Remove a MaverickListener from the list of objects that will be sent 48 | * MaverickEventss. 49 | * 50 | * @param listener 51 | * listener to remove 52 | */ 53 | public void removeListener(String threadPrefix); 54 | 55 | /** 56 | * Fire a MaverickEvent at all MaverickListeners that have registered an 57 | * interest in events. 58 | * 59 | * @param evt 60 | * event to fire to all listener 61 | */ 62 | public void fireEvent(Event evt); 63 | } 64 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/HmacSha512.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import javax.crypto.Mac; 24 | import javax.crypto.spec.SecretKeySpec; 25 | 26 | import com.sshtools.ssh.SshException; 27 | 28 | /** 29 | * SHA-1 message authentication implementation. 30 | * 31 | * @author Lee David Painter 32 | * 33 | */ 34 | public class HmacSha512 extends AbstractHmac { 35 | 36 | public HmacSha512() { 37 | super(JCEAlgorithms.JCE_HMACSHA512, 64); 38 | } 39 | 40 | public String getAlgorithm() { 41 | return "hmac-sha2-512"; 42 | } 43 | 44 | public void init(byte[] keydata) throws SshException { 45 | try { 46 | mac = JCEProvider.getProviderForAlgorithm(jceAlgorithm)==null ? Mac.getInstance(jceAlgorithm) : Mac.getInstance(jceAlgorithm, JCEProvider.getProviderForAlgorithm(jceAlgorithm)); 47 | 48 | // Create a key of 16 bytes 49 | byte[] key = new byte[64]; 50 | System.arraycopy(keydata, 0, key, 0, key.length); 51 | 52 | SecretKeySpec keyspec = new SecretKeySpec(key, jceAlgorithm); 53 | mac.init(keyspec); 54 | } catch (Throwable t) { 55 | throw new SshException(t); 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/SecureRND.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.security.NoSuchAlgorithmException; 24 | import java.security.SecureRandom; 25 | 26 | import com.sshtools.ssh.SshException; 27 | import com.sshtools.ssh.components.SshSecureRandomGenerator; 28 | 29 | /** 30 | * Secure random number generator implementation for JCE provider. 31 | */ 32 | public class SecureRND implements SshSecureRandomGenerator { 33 | 34 | SecureRandom rnd; 35 | 36 | public SecureRND() throws NoSuchAlgorithmException { 37 | rnd = JCEProvider.getSecureRandom(); 38 | } 39 | 40 | public void nextBytes(byte[] bytes) { 41 | rnd.nextBytes(bytes); 42 | } 43 | 44 | public void nextBytes(byte[] bytes, int off, int len) throws SshException { 45 | 46 | try { 47 | byte[] tmp = new byte[len]; 48 | rnd.nextBytes(tmp); 49 | System.arraycopy(tmp, 0, bytes, off, len); 50 | } catch (ArrayIndexOutOfBoundsException ex) { 51 | throw new SshException("ArrayIndexOutOfBoundsException: Index " 52 | + off + " on actual array length " + bytes.length 53 | + " with len=" + len, SshException.INTERNAL_ERROR); 54 | } 55 | } 56 | 57 | public int nextInt() { 58 | return rnd.nextInt(); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/HmacSha1.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import javax.crypto.Mac; 24 | import javax.crypto.spec.SecretKeySpec; 25 | 26 | import com.sshtools.ssh.SshException; 27 | 28 | /** 29 | * SHA-1 message authentication implementation. 30 | * 31 | * @author Lee David Painter 32 | * 33 | */ 34 | public class HmacSha1 extends AbstractHmac { 35 | 36 | public HmacSha1() { 37 | super(JCEAlgorithms.JCE_HMACSHA1, 20); 38 | } 39 | 40 | public String getAlgorithm() { 41 | return "hmac-sha1"; 42 | } 43 | 44 | public void init(byte[] keydata) throws SshException { 45 | try { 46 | mac = JCEProvider.getProviderForAlgorithm(jceAlgorithm) == null ? Mac 47 | .getInstance(jceAlgorithm) : Mac.getInstance(jceAlgorithm, 48 | JCEProvider.getProviderForAlgorithm(jceAlgorithm)); 49 | 50 | // Create a key of 16 bytes 51 | byte[] key = new byte[System.getProperty( 52 | "miscomputes.ssh2.hmac.keys", "false").equalsIgnoreCase( 53 | "true") ? 16 : 20]; 54 | System.arraycopy(keydata, 0, key, 0, key.length); 55 | 56 | SecretKeySpec keyspec = new SecretKeySpec(key, jceAlgorithm); 57 | mac.init(keyspec); 58 | } catch (Throwable t) { 59 | throw new SshException(t); 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/HmacSha196.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import javax.crypto.Mac; 24 | import javax.crypto.spec.SecretKeySpec; 25 | 26 | import com.sshtools.ssh.SshException; 27 | 28 | /** 29 | * SHA-1 message authentication implementation. 30 | * 31 | * @author Lee David Painter 32 | * 33 | */ 34 | public class HmacSha196 extends AbstractHmac { 35 | 36 | public HmacSha196() { 37 | super(JCEAlgorithms.JCE_HMACSHA1, 20, 12); 38 | } 39 | 40 | public String getAlgorithm() { 41 | return "hmac-sha1"; 42 | } 43 | 44 | public void init(byte[] keydata) throws SshException { 45 | try { 46 | mac = JCEProvider.getProviderForAlgorithm(jceAlgorithm) == null ? Mac 47 | .getInstance(jceAlgorithm) : Mac.getInstance(jceAlgorithm, 48 | JCEProvider.getProviderForAlgorithm(jceAlgorithm)); 49 | 50 | // Create a key of 16 bytes 51 | byte[] key = new byte[System.getProperty( 52 | "miscomputes.ssh2.hmac.keys", "false").equalsIgnoreCase( 53 | "true") ? 16 : 20]; 54 | System.arraycopy(keydata, 0, key, 0, key.length); 55 | 56 | SecretKeySpec keyspec = new SecretKeySpec(key, jceAlgorithm); 57 | mac.init(keyspec); 58 | } catch (Throwable t) { 59 | throw new SshException(t); 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/HmacSha256.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import javax.crypto.Mac; 24 | import javax.crypto.spec.SecretKeySpec; 25 | 26 | import com.sshtools.ssh.SshException; 27 | 28 | /** 29 | * SHA-1 message authentication implementation. 30 | * 31 | * @author Lee David Painter 32 | * 33 | */ 34 | public class HmacSha256 extends AbstractHmac { 35 | 36 | public HmacSha256() { 37 | super(JCEAlgorithms.JCE_HMACSHA256, 32); 38 | } 39 | 40 | public String getAlgorithm() { 41 | return "hmac-sha256@ssh.com"; 42 | } 43 | 44 | public void init(byte[] keydata) throws SshException { 45 | try { 46 | mac = JCEProvider.getProviderForAlgorithm(jceAlgorithm) == null ? Mac 47 | .getInstance(jceAlgorithm) : Mac.getInstance(jceAlgorithm, 48 | JCEProvider.getProviderForAlgorithm(jceAlgorithm)); 49 | 50 | // Create a key of 16 bytes 51 | byte[] key = new byte[System.getProperty( 52 | "miscomputes.ssh2.hmac.keys", "false").equalsIgnoreCase( 53 | "true") ? 16 : 32]; 54 | System.arraycopy(keydata, 0, key, 0, key.length); 55 | 56 | SecretKeySpec keyspec = new SecretKeySpec(key, jceAlgorithm); 57 | mac.init(keyspec); 58 | } catch (Throwable t) { 59 | throw new SshException(t); 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh2/GlobalRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh2; 22 | 23 | /** 24 | * 25 | *

26 | * This class represents a global request. 27 | *

28 | * 29 | * @author Lee David Painter 30 | */ 31 | public class GlobalRequest { 32 | 33 | String name; 34 | byte[] requestdata; 35 | 36 | /** 37 | * Contstruct a request. 38 | * 39 | * @param name 40 | * the name of the request 41 | * @param requestdata 42 | * the request data 43 | */ 44 | public GlobalRequest(String name, byte[] requestdata) { 45 | this.name = name; 46 | this.requestdata = requestdata; 47 | } 48 | 49 | /** 50 | * Get the name of the request. 51 | * 52 | * @return String 53 | */ 54 | public String getName() { 55 | return name; 56 | } 57 | 58 | /** 59 | * Get the request data, if the request has been sent and processed, this 60 | * will return the response data (which can be null). 61 | * 62 | * @return either the request data or response data according to the current 63 | * state. 64 | */ 65 | public byte[] getData() { 66 | return requestdata; 67 | } 68 | 69 | /** 70 | * Set the data. 71 | * 72 | * @param requestdata 73 | */ 74 | public void setData(byte[] requestdata) { 75 | this.requestdata = requestdata; 76 | } 77 | 78 | } -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/SshAuthentication.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh; 22 | 23 | /** 24 | *

25 | * The base interface for all SSH authentication mechanisms and authentication 26 | * result constants. 27 | *

28 | * 29 | * @author Lee David Painter 30 | */ 31 | public interface SshAuthentication { 32 | 33 | /** The authentication completed **/ 34 | public static final int COMPLETE = 1; 35 | /** The authentication failed **/ 36 | public static final int FAILED = 2; 37 | /** The authentication succeeded but further authentication is required **/ 38 | public static final int FURTHER_AUTHENTICATION_REQUIRED = 3; 39 | /** The authentication was cancelled by the user */ 40 | public static final int CANCELLED = 4; 41 | /** The public key provided is acceptable for authentication **/ 42 | public static final int PUBLIC_KEY_ACCEPTABLE = 5; 43 | 44 | /** 45 | * Set the username for this authentication attempt. 46 | * 47 | * @param username 48 | */ 49 | public void setUsername(String username); 50 | 51 | /** 52 | * Get the username for this authentication attempt. 53 | * 54 | * @return the username used. 55 | */ 56 | public String getUsername(); 57 | 58 | /** 59 | * The SSH authentication method name 60 | * 61 | * @return String 62 | */ 63 | public String getMethod(); 64 | } 65 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh2/KBIPrompt.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh2; 22 | 23 | /** 24 | * Represents a single prompt in the keyboard-interactive 25 | * authentication process 26 | * 27 | * @author Lee David Painter 28 | */ 29 | public class KBIPrompt { 30 | private String prompt; 31 | private String response; 32 | private boolean echo; 33 | 34 | /** 35 | * Creates a new KBIPrompt object. 36 | * 37 | * @param prompt 38 | * @param echo 39 | */ 40 | public KBIPrompt(String prompt, boolean echo) { 41 | this.prompt = prompt; 42 | this.echo = echo; 43 | } 44 | 45 | /** 46 | * Get the prompt message to display to the user 47 | * 48 | * @return String 49 | */ 50 | public String getPrompt() { 51 | return prompt; 52 | } 53 | 54 | /** 55 | * true if the user response should be echo'd to the display, 56 | * otherwise false. 57 | * 58 | * @return boolean 59 | */ 60 | public boolean echo() { 61 | return echo; 62 | } 63 | 64 | /** 65 | * Set the user's response for this prompt. 66 | * 67 | * @param response 68 | */ 69 | public void setResponse(String response) { 70 | this.response = response; 71 | } 72 | 73 | /** 74 | * Get the user's response for this prompt. 75 | * 76 | * @return String 77 | */ 78 | public String getResponse() { 79 | return response; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/events/J2SSHEventMessages.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.events; 22 | 23 | import java.lang.reflect.Field; 24 | import java.lang.reflect.Modifier; 25 | import java.util.Hashtable; 26 | 27 | /** 28 | * Time saving class for the LoggingMaverickListener class that sets the message 29 | * code for each event to its event code field name. 30 | * 31 | * @author david 32 | * 33 | */ 34 | public final class J2SSHEventMessages { 35 | public static Hashtable messageCodes = new Hashtable(); 36 | public static Hashtable messageAttributes = new Hashtable(); 37 | 38 | static { 39 | Class mavevent = J2SSHEventCodes.class; 40 | Field[] fields = mavevent.getFields(); 41 | for (int i = 0; i < fields.length; i++) { 42 | int modifiers = fields[i].getModifiers(); 43 | if (Modifier.isFinal(modifiers) && Modifier.isStatic(modifiers)) { 44 | try { 45 | String fieldName = fields[i].getName(); 46 | if (fieldName.startsWith("EVENT_")) { 47 | messageCodes.put(fields[i].get(null), 48 | fieldName.substring(6)); 49 | } else { 50 | messageAttributes.put(fields[i].get(null), 51 | fieldName.substring(10)); 52 | } 53 | } catch (IllegalArgumentException e) { 54 | } catch (IllegalAccessException e) { 55 | } 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/sftp/FileTransferProgress.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.sftp; 22 | 23 | /** 24 | *

25 | * Interface for monitoring the state of a file transfer 26 | *

27 | * 28 | *

29 | * It should be noted that the total bytes to transfer passed to the started 30 | * method is an indication of file length and may not be exact for some types of 31 | * file transfer, for example ASCII text mode transfers may add or remove 32 | * newline characters from the stream and therefore the total bytes transfered 33 | * may not equal the number expected. 34 | * 35 | * @author Lee David Painter 36 | */ 37 | public interface FileTransferProgress { 38 | /** 39 | * The transfer has started 40 | * 41 | * @param bytesTotal 42 | * @param remoteFile 43 | */ 44 | public void started(long bytesTotal, String remoteFile); 45 | 46 | /** 47 | * The transfer is cancelled. Implementations should return true if the user 48 | * wants to cancel the transfer. The transfer will then be stopped at the 49 | * next evaluation stage. 50 | * 51 | * @return boolean 52 | */ 53 | public boolean isCancelled(); 54 | 55 | /** 56 | * The transfer has progressed 57 | * 58 | * @param bytesSoFar 59 | */ 60 | public void progressed(long bytesSoFar); 61 | 62 | /** 63 | * The transfer has completed. 64 | */ 65 | public void completed(); 66 | } 67 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/SshKeyPair.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components; 22 | 23 | /** 24 | * Storage class for a public/private key pair. 25 | * 26 | * @author Lee David Painter 27 | */ 28 | public class SshKeyPair { 29 | SshPrivateKey privatekey; 30 | SshPublicKey publickey; 31 | 32 | /** 33 | * Get the private key. 34 | * 35 | * @return SshPrivateKey 36 | */ 37 | public SshPrivateKey getPrivateKey() { 38 | return privatekey; 39 | } 40 | 41 | /** 42 | * Get the public key. 43 | * 44 | * @return SshPublicKey 45 | */ 46 | public SshPublicKey getPublicKey() { 47 | return publickey; 48 | } 49 | 50 | /** 51 | * Wraps a public/private key pair into an SshKeyPair instance. 52 | * 53 | * @param prv 54 | * @param pub 55 | * @return SshKeyPair 56 | */ 57 | public static SshKeyPair getKeyPair(SshPrivateKey prv, SshPublicKey pub) { 58 | SshKeyPair pair = new SshKeyPair(); 59 | pair.publickey = pub; 60 | pair.privatekey = prv; 61 | return pair; 62 | } 63 | 64 | /** 65 | * Set the private key 66 | * 67 | * @param privatekey 68 | */ 69 | public void setPrivateKey(SshPrivateKey privatekey) { 70 | this.privatekey = privatekey; 71 | 72 | } 73 | 74 | /** 75 | * Set the public key 76 | * 77 | * @param publickey 78 | */ 79 | public void setPublicKey(SshPublicKey publickey) { 80 | this.publickey = publickey; 81 | 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh2/AuthenticationResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh2; 22 | 23 | /** 24 | *

25 | * Throwable class used by the 26 | * AuthenticationProtocol to indicate that a authentication request has 27 | * either been completed, failed or cancelled. 28 | *

29 | * 30 | * @author Lee David Painter 31 | */ 32 | public class AuthenticationResult extends Throwable { 33 | 34 | private static final long serialVersionUID = 1L; 35 | int result; 36 | String auths; 37 | 38 | /** 39 | * Construct an AuthenticationResult 40 | * 41 | * @param result 42 | */ 43 | public AuthenticationResult(int result) { 44 | this.result = result; 45 | } 46 | 47 | /** 48 | * Construct an AuthenticationResult 49 | * 50 | * @param result 51 | * @param auths 52 | */ 53 | public AuthenticationResult(int result, String auths) { 54 | this.result = result; 55 | this.auths = auths; 56 | } 57 | 58 | /** 59 | * Get the result of this authentication. 60 | * 61 | * @return one of the constants defined above 62 | */ 63 | public int getResult() { 64 | return result; 65 | } 66 | 67 | /** 68 | * Get the authentication methods that can be used. 69 | * 70 | * @return a comma delimited list of authentication methods, for example 71 | * "publickey,password" 72 | */ 73 | public String getAuthenticationMethods() { 74 | return auths; 75 | } 76 | 77 | } -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh2/ChannelFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh2; 22 | 23 | import com.sshtools.ssh.ChannelOpenException; 24 | import com.sshtools.ssh.SshException; 25 | 26 | /** 27 | *

28 | * The SSH2 protocol supports many different channel types including sesisons, 29 | * port forwarding and x11 forwarding; most channels are requested by the client 30 | * and created by the server however it is possible for the server to request 31 | * any type of channel from the client, this interface defines the contract for 32 | * supporting a standard and custom channel creation. 33 | *

34 | * 35 | * @author Lee David Painter 36 | */ 37 | public interface ChannelFactory { 38 | 39 | /** 40 | * Return the supported channel types. 41 | * 42 | * @return an array of Strings containing the channel types. 43 | */ 44 | public String[] supportedChannelTypes(); 45 | 46 | /** 47 | *

48 | * Create an instance of an SSH channel. The new instance should be 49 | * returned, if for any reason the channel cannot be created either because 50 | * the channel is not supported or there are not enough resources an 51 | * exception is thrown. 52 | *

53 | * 54 | * @param channeltype 55 | * @param requestdata 56 | * @return an open channel 57 | * @throws ChannelOpenException 58 | */ 59 | public Ssh2Channel createChannel(String channeltype, byte[] requestdata) 60 | throws SshException, ChannelOpenException; 61 | } 62 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/SshChannel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh; 22 | 23 | import com.sshtools.ssh.message.SshMessageRouter; 24 | 25 | /** 26 | * 27 | *

28 | * The base interface for all SSH channels. SSH Channels enable the multiplexing 29 | * of several unique data channels over a single SSH connection, each channel is 30 | * identified by an unique ID and provides a set of IO streams for sending and 31 | * recieving data. 32 | *

33 | * 34 | * @author Lee David Painter 35 | */ 36 | public interface SshChannel extends SshIO { 37 | 38 | /** 39 | * Get the id of this channel. 40 | * 41 | * @return the channel id 42 | */ 43 | public int getChannelId(); 44 | 45 | /** 46 | * Evaluate whether the channel is closed. 47 | * 48 | * @return true if the channel is closed, otherwise 49 | * false 50 | */ 51 | public boolean isClosed(); 52 | 53 | /** 54 | * Provides an event listening mechanism. 55 | * 56 | * @param listener 57 | */ 58 | public void addChannelEventListener(ChannelEventListener listener); 59 | 60 | /** 61 | * Automatically consume input data 62 | * 63 | * @param autoConsumeInput 64 | * boolean 65 | */ 66 | public void setAutoConsumeInput(boolean autoConsumeInput); 67 | 68 | /** 69 | * Returns the message router instance to which this channel belongs. 70 | * 71 | * @return 72 | */ 73 | public SshMessageRouter getMessageRouter(); 74 | 75 | } 76 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/events/EventObject.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.events; 22 | 23 | /** 24 | *

25 | * The root class from which all event state objects shall be derived. 26 | *

27 | * All Events are constructed with a reference to the object, the "source", that 28 | * is logically deemed to be the object upon which the Event in question 29 | * initially occurred upon. 30 | * 31 | * @since JDK1.1 32 | */ 33 | 34 | public class EventObject { 35 | 36 | /** 37 | * The object on which the Event initially occurred. 38 | */ 39 | protected transient Object source; 40 | 41 | /** 42 | * Constructs a prototypical Event. 43 | * 44 | * @param source 45 | * The object on which the Event initially occurred. 46 | * @exception IllegalArgumentException 47 | * if source is null. 48 | */ 49 | public EventObject(Object source) { 50 | if (source == null) { 51 | throw new IllegalArgumentException("null source"); 52 | } 53 | 54 | this.source = source; 55 | } 56 | 57 | /** 58 | * The object on which the Event initially occurred. 59 | * 60 | * @return The object on which the Event initially occurred. 61 | */ 62 | public Object getSource() { 63 | return source; 64 | } 65 | 66 | /** 67 | * Returns a String representation of this EventObject. 68 | * 69 | * @return A a String representation of this EventObject. 70 | */ 71 | public String toString() { 72 | return getClass().getName() + "[source=" + source + "]"; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/socks/UDPEncapsulation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | /** 22 | * This file is originally from the http://sourceforge.net/projects/jsocks/ 23 | * released under the LGPL. 24 | */ 25 | package socks; 26 | /** 27 | This interface provides for datagram encapsulation for SOCKSv5 protocol. 28 |

29 | SOCKSv5 allows for datagrams to be encapsulated for purposes of integrity 30 | and/or authenticity. How it should be done is aggreed during the 31 | authentication stage, and is authentication dependent. This interface is 32 | provided to allow this encapsulation. 33 | @see Authentication 34 | */ 35 | public interface UDPEncapsulation{ 36 | 37 | /** 38 | This method should provide any authentication depended transformation 39 | on datagrams being send from/to the client. 40 | 41 | @param data Datagram data (including any SOCKS related bytes), to be 42 | encapsulated/decapsulated. 43 | @param out Wether the data is being send out. If true method should 44 | encapsulate/encrypt data, otherwise it should decapsulate/ 45 | decrypt data. 46 | @throw IOException if for some reason data can be transformed correctly. 47 | @return Should return byte array containing data after transformation. 48 | It is possible to return same array as input, if transformation 49 | only involves bit mangling, and no additional data is being 50 | added or removed. 51 | */ 52 | byte[] udpEncapsulate(byte[] data, boolean out) throws java.io.IOException; 53 | } 54 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/message/SshAbstractChannel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.message; 22 | 23 | import com.sshtools.ssh.SshChannel; 24 | import com.sshtools.ssh.SshException; 25 | 26 | /** 27 | * @author Lee David Painter 28 | */ 29 | public abstract class SshAbstractChannel implements SshChannel { 30 | 31 | public static final int CHANNEL_UNINITIALIZED = 1; 32 | public static final int CHANNEL_OPEN = 2; 33 | public static final int CHANNEL_CLOSED = 3; 34 | 35 | protected int channelid = -1; 36 | protected int state = CHANNEL_UNINITIALIZED; 37 | protected SshMessageRouter manager; 38 | protected SshMessageStore ms; 39 | 40 | protected SshMessageStore getMessageStore() throws SshException { 41 | if (ms == null) { 42 | throw new SshException("Channel is not initialized!", 43 | SshException.INTERNAL_ERROR); 44 | } 45 | return ms; 46 | } 47 | 48 | public int getChannelId() { 49 | return channelid; 50 | } 51 | 52 | public SshMessageRouter getMessageRouter() { 53 | return manager; 54 | } 55 | 56 | protected void init(SshMessageRouter manager, int channelid) { 57 | this.channelid = channelid; 58 | this.manager = manager; 59 | this.ms = new SshMessageStore(manager, this, getStickyMessageIds()); 60 | } 61 | 62 | protected abstract MessageObserver getStickyMessageIds(); 63 | 64 | public boolean isClosed() { 65 | return state == CHANNEL_CLOSED; 66 | } 67 | 68 | public void idle() { 69 | 70 | } 71 | 72 | protected abstract boolean processChannelMessage(SshChannelMessage m) 73 | throws SshException; 74 | 75 | } 76 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/Digest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components; 22 | 23 | import java.math.BigInteger; 24 | 25 | /** 26 | * A general interface for a digest with utility methods to add java types into 27 | * the digest. 28 | * 29 | * @author Lee David Painter 30 | * 31 | */ 32 | public interface Digest { 33 | 34 | /** 35 | * Update the digest with a BigInteger value. This puts both the integer 36 | * length of the BigInteger data and the binary data. 37 | * 38 | * @param bi 39 | */ 40 | public abstract void putBigInteger(BigInteger bi); 41 | 42 | /** 43 | * Put a single byte into the digest. 44 | * 45 | * @param b 46 | */ 47 | public abstract void putByte(byte b); 48 | 49 | /** 50 | * Put a byte array into the digest. 51 | * 52 | * @param data 53 | */ 54 | public abstract void putBytes(byte[] data); 55 | 56 | /** 57 | * Put a byte array into the digest 58 | * 59 | * @param data 60 | * @param offset 61 | * @param len 62 | */ 63 | public abstract void putBytes(byte[] data, int offset, int len); 64 | 65 | /** 66 | * Put an integer into the digest. 67 | * 68 | * @param i 69 | */ 70 | public abstract void putInt(int i); 71 | 72 | /** 73 | * Put a String into the digest. 74 | * 75 | * @param str 76 | */ 77 | public abstract void putString(String str); 78 | 79 | /** 80 | * Reset the underlying digest. 81 | */ 82 | public abstract void reset(); 83 | 84 | /** 85 | * Do the final processing and return the hash. 86 | * 87 | * @return the hash 88 | */ 89 | public abstract byte[] doFinal(); 90 | 91 | } 92 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/util/SimpleASNWriter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.util; 22 | 23 | import java.io.ByteArrayOutputStream; 24 | 25 | /** 26 | * 27 | * 28 | * @author $author$ 29 | */ 30 | public class SimpleASNWriter { 31 | private ByteArrayOutputStream data; 32 | 33 | /** 34 | * Creates a new SimpleASNWriter object. 35 | */ 36 | public SimpleASNWriter() { 37 | this.data = new ByteArrayOutputStream(); 38 | } 39 | 40 | /** 41 | * 42 | * 43 | * @param b 44 | */ 45 | public void writeByte(int b) { 46 | data.write(b); 47 | } 48 | 49 | /** 50 | * 51 | * 52 | * @param b 53 | */ 54 | public void writeData(byte[] b) { 55 | writeLength(b.length); 56 | this.data.write(b, 0, b.length); 57 | } 58 | 59 | /** 60 | * 61 | * 62 | * @param length 63 | */ 64 | public void writeLength(int length) { 65 | if (length < 0x80) { 66 | data.write(length); 67 | } else { 68 | if (length < 0x100) { 69 | data.write(0x81); 70 | data.write(length); 71 | } else if (length < 0x10000) { 72 | data.write(0x82); 73 | data.write(length >>> 8); 74 | data.write(length); 75 | } else if (length < 0x1000000) { 76 | data.write(0x83); 77 | data.write(length >>> 16); 78 | data.write(length >>> 8); 79 | data.write(length); 80 | } else { 81 | data.write(0x84); 82 | data.write(length >>> 24); 83 | data.write(length >>> 16); 84 | data.write(length >>> 8); 85 | data.write(length); 86 | } 87 | } 88 | } 89 | 90 | /** 91 | * 92 | * 93 | * @return 94 | */ 95 | public byte[] toByteArray() { 96 | return data.toByteArray(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/util/EOLProcessorInputStream.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.util; 22 | 23 | import java.io.IOException; 24 | import java.io.InputStream; 25 | 26 | class EOLProcessorInputStream extends InputStream { 27 | 28 | EOLProcessor processor; 29 | InputStream in; 30 | DynamicBuffer buf = new DynamicBuffer(); 31 | byte[] tmp = new byte[32768]; 32 | 33 | public EOLProcessorInputStream(int inputStyle, int outputStyle, 34 | InputStream in) throws IOException { 35 | this.in = in; 36 | processor = new EOLProcessor(inputStyle, outputStyle, 37 | buf.getOutputStream()); 38 | } 39 | 40 | /** 41 | * Reads the next byte of data from the input stream. 42 | * 43 | * @return the next byte of data, or -1 if the end of the 44 | * stream is reached. 45 | * @throws IOException 46 | * if an I/O error occurs. 47 | * @todo Implement this java.io.InputStream method 48 | */ 49 | public int read() throws IOException { 50 | fillBuffer(1); 51 | return buf.getInputStream().read(); 52 | } 53 | 54 | public int available() throws IOException { 55 | return in.available(); 56 | } 57 | 58 | public int read(byte[] b, int off, int len) throws IOException { 59 | fillBuffer(len); 60 | return buf.getInputStream().read(b, off, len); 61 | } 62 | 63 | private void fillBuffer(int count) throws IOException { 64 | 65 | while (buf.available() < count) { 66 | int read = in.read(tmp); 67 | if (read == -1) { 68 | processor.close(); 69 | buf.close(); 70 | return; 71 | } 72 | processor.processBytes(tmp, 0, read); 73 | } 74 | } 75 | 76 | public void close() throws IOException { 77 | in.close(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh2/BannerDisplay.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh2; 22 | 23 | /** 24 | * 25 | *

26 | * Callback interface to display authentication banner messages. 27 | *

28 | * 29 | *

30 | * In some jurisdictions sending a warning message before authentication may be 31 | * relevant for getting legal protection. Many UNIX machines, for example, 32 | * normally display text from `/etc/issue', or use "tcp wrappers" or similar 33 | * software to display a banner before issuing a login prompt. 34 | *

35 | * 36 | *

37 | * Implement this interface to show the authentication banner message. The 38 | * method should display the message and should not return until the user 39 | * accepts the message 40 | *

41 | * 42 | *

43 | * To configure a banner display you must setup the Ssh2Context on a SshConnector instance using the following 46 | * code:

47 | * 48 | *
49 |  * SshConnector con = SshConnector.getInstance();
50 |  * 
51 |  * BannerDisplay display = new BannerDisplay() {
52 |  * 	public void displayBanner(String message) {
53 |  * 		System.out.println(message);
54 |  * 		System.in.read();
55 |  * 	}
56 |  * };
57 |  * Ssh2Context context = (Ssh2Context) con.getContext(SshConnector.SSH2);
58 |  * context.setBannerDisplay(display);
59 |  * 
60 | * 61 | *
62 | * 63 | * @author Lee David Painter 64 | */ 65 | public interface BannerDisplay { 66 | /** 67 | * Called when a banner message is received. 68 | * 69 | * @param message 70 | * the message to display. 71 | */ 72 | public void displayBanner(String message); 73 | } -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/ArcFour.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.io.IOException; 24 | import java.security.InvalidKeyException; 25 | import java.security.NoSuchAlgorithmException; 26 | 27 | import javax.crypto.Cipher; 28 | import javax.crypto.NoSuchPaddingException; 29 | import javax.crypto.spec.SecretKeySpec; 30 | 31 | public class ArcFour extends AbstractJCECipher { 32 | 33 | public ArcFour() throws IOException { 34 | super(JCEAlgorithms.JCE_ARCFOUR, "ARCFOUR", 16, "arcfour"); 35 | } 36 | 37 | public void init(int mode, byte[] iv, byte[] keydata) throws IOException { 38 | try { 39 | 40 | cipher = JCEProvider.getProviderForAlgorithm(spec) == null ? Cipher 41 | .getInstance(spec) : Cipher.getInstance(spec, 42 | JCEProvider.getProviderForAlgorithm(spec)); 43 | 44 | if (cipher == null) { 45 | throw new IOException("Failed to create cipher engine for " 46 | + spec); 47 | } 48 | 49 | // Create a byte key 50 | byte[] actualKey = new byte[keylength]; 51 | System.arraycopy(keydata, 0, actualKey, 0, actualKey.length); 52 | 53 | SecretKeySpec kspec = new SecretKeySpec(actualKey, keyspec); 54 | 55 | // Create the cipher according to its algorithm 56 | cipher.init(((mode == ENCRYPT_MODE) ? Cipher.ENCRYPT_MODE 57 | : Cipher.DECRYPT_MODE), kspec); 58 | 59 | } catch (NoSuchPaddingException nspe) { 60 | throw new IOException("Padding type not supported"); 61 | } catch (NoSuchAlgorithmException nsae) { 62 | throw new IOException("Algorithm not supported:" + spec); 63 | } catch (InvalidKeyException ike) { 64 | throw new IOException("Invalid encryption key"); 65 | } 66 | } 67 | 68 | public int getBlockSize() { 69 | return 8; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/publickey/SECSHPublicKeyFile.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.publickey; 22 | 23 | import java.io.IOException; 24 | 25 | import com.sshtools.ssh.SshException; 26 | import com.sshtools.ssh.components.SshPublicKey; 27 | 28 | public class SECSHPublicKeyFile extends Base64EncodedFileFormat implements 29 | SshPublicKeyFile { 30 | 31 | private static String BEGIN = "---- BEGIN SSH2 PUBLIC KEY ----"; 32 | private static String END = "---- END SSH2 PUBLIC KEY ----"; 33 | String algorithm; 34 | byte[] encoded; 35 | 36 | SECSHPublicKeyFile(byte[] formattedkey) throws IOException { 37 | super(BEGIN, END); 38 | encoded = getKeyBlob(formattedkey); 39 | toPublicKey(); // Validate 40 | } 41 | 42 | SECSHPublicKeyFile(SshPublicKey key, String comment) throws IOException { 43 | super(BEGIN, END); 44 | try { 45 | algorithm = key.getAlgorithm(); 46 | encoded = key.getEncoded(); 47 | setComment(comment); 48 | toPublicKey(); // Validate 49 | } catch (SshException ex) { 50 | throw new IOException("Failed to encode public key"); 51 | } 52 | } 53 | 54 | public String getComment() { 55 | return getHeaderValue("Comment"); 56 | } 57 | 58 | public SshPublicKey toPublicKey() throws IOException { 59 | return SshPublicKeyFileFactory.decodeSSH2PublicKey(encoded); 60 | } 61 | 62 | public byte[] getFormattedKey() throws IOException { 63 | return formatKey(encoded); 64 | } 65 | 66 | public void setComment(String comment) { 67 | setHeaderValue("Comment", (comment.trim().startsWith("\"") ? "" : "\"") 68 | + comment.trim() + (comment.trim().endsWith("\"") ? "" : "\"")); 69 | } 70 | 71 | public String toString() { 72 | try { 73 | return new String(getFormattedKey()); 74 | } catch (IOException ex) { 75 | return "Invalid encoding!"; 76 | } 77 | 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/net/SocketWrapper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.net; 22 | 23 | import java.io.IOException; 24 | import java.io.InputStream; 25 | import java.io.OutputStream; 26 | import java.net.Socket; 27 | 28 | import com.sshtools.ssh.SocketTimeoutSupport; 29 | import com.sshtools.ssh.SshTransport; 30 | 31 | /** 32 | * 33 | * Implements a basic wrapper around a Socket to provide an SshTransport suitable for use 35 | * in making connections using the SshConnector. 37 | * 38 | * @author Lee David Painter 39 | */ 40 | public class SocketWrapper implements SshTransport, SocketTimeoutSupport { 41 | 42 | protected Socket socket; 43 | 44 | /** 45 | * Create a SocketWrapper 46 | * 47 | * @param socket 48 | */ 49 | public SocketWrapper(Socket socket) { 50 | this.socket = socket; 51 | } 52 | 53 | public InputStream getInputStream() throws IOException { 54 | return socket.getInputStream(); 55 | } 56 | 57 | public OutputStream getOutputStream() throws IOException { 58 | return socket.getOutputStream(); 59 | } 60 | 61 | public String getHost() { 62 | return socket.getInetAddress() == null ? "proxied" : socket 63 | .getInetAddress().getHostAddress(); 64 | } 65 | 66 | public int getPort() { 67 | return socket.getPort(); 68 | } 69 | 70 | public void close() throws IOException { 71 | socket.close(); 72 | } 73 | 74 | public SshTransport duplicate() throws IOException { 75 | return new SocketWrapper(new Socket(getHost(), socket.getPort())); 76 | } 77 | 78 | public void setSoTimeout(int timeout) throws IOException { 79 | socket.setSoTimeout(timeout); 80 | } 81 | 82 | public int getSoTimeout() throws IOException { 83 | return socket.getSoTimeout(); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/ArcFour128.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.io.IOException; 24 | import java.security.InvalidKeyException; 25 | import java.security.NoSuchAlgorithmException; 26 | 27 | import javax.crypto.Cipher; 28 | import javax.crypto.NoSuchPaddingException; 29 | import javax.crypto.spec.SecretKeySpec; 30 | 31 | public class ArcFour128 extends AbstractJCECipher { 32 | 33 | public ArcFour128() throws IOException { 34 | super("ARCFOUR", "ARCFOUR", 16, "arcfour128"); 35 | } 36 | 37 | public void init(int mode, byte[] iv, byte[] keydata) throws IOException { 38 | try { 39 | 40 | cipher = JCEProvider.getProviderForAlgorithm(spec) == null ? Cipher 41 | .getInstance(spec) : Cipher.getInstance(spec, 42 | JCEProvider.getProviderForAlgorithm(spec)); 43 | 44 | if (cipher == null) { 45 | throw new IOException("Failed to create cipher engine for " 46 | + spec); 47 | } 48 | 49 | // Create a byte key 50 | byte[] actualKey = new byte[keylength]; 51 | System.arraycopy(keydata, 0, actualKey, 0, actualKey.length); 52 | 53 | SecretKeySpec kspec = new SecretKeySpec(actualKey, keyspec); 54 | 55 | // Create the cipher according to its algorithm 56 | cipher.init(((mode == ENCRYPT_MODE) ? Cipher.ENCRYPT_MODE 57 | : Cipher.DECRYPT_MODE), kspec); 58 | 59 | byte[] tmp = new byte[1536]; 60 | cipher.update(tmp); 61 | 62 | } catch (NoSuchPaddingException nspe) { 63 | throw new IOException("Padding type not supported"); 64 | } catch (NoSuchAlgorithmException nsae) { 65 | throw new IOException("Algorithm not supported:" + spec); 66 | } catch (InvalidKeyException ike) { 67 | throw new IOException("Invalid encryption key"); 68 | } 69 | } 70 | 71 | public int getBlockSize() { 72 | return 8; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/ArcFour256.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.io.IOException; 24 | import java.security.InvalidKeyException; 25 | import java.security.NoSuchAlgorithmException; 26 | 27 | import javax.crypto.Cipher; 28 | import javax.crypto.NoSuchPaddingException; 29 | import javax.crypto.spec.SecretKeySpec; 30 | 31 | public class ArcFour256 extends AbstractJCECipher { 32 | 33 | public ArcFour256() throws IOException { 34 | super("ARCFOUR", "ARCFOUR", 32, "arcfour256"); 35 | } 36 | 37 | public void init(int mode, byte[] iv, byte[] keydata) throws IOException { 38 | try { 39 | 40 | cipher = JCEProvider.getProviderForAlgorithm(spec) == null ? Cipher 41 | .getInstance(spec) : Cipher.getInstance(spec, 42 | JCEProvider.getProviderForAlgorithm(spec)); 43 | 44 | if (cipher == null) { 45 | throw new IOException("Failed to create cipher engine for " 46 | + spec); 47 | } 48 | 49 | // Create a byte key 50 | byte[] actualKey = new byte[keylength]; 51 | System.arraycopy(keydata, 0, actualKey, 0, actualKey.length); 52 | 53 | SecretKeySpec kspec = new SecretKeySpec(actualKey, keyspec); 54 | 55 | // Create the cipher according to its algorithm 56 | cipher.init(((mode == ENCRYPT_MODE) ? Cipher.ENCRYPT_MODE 57 | : Cipher.DECRYPT_MODE), kspec); 58 | 59 | byte[] tmp = new byte[1536]; 60 | cipher.update(tmp); 61 | 62 | } catch (NoSuchPaddingException nspe) { 63 | throw new IOException("Padding type not supported"); 64 | } catch (NoSuchAlgorithmException nsae) { 65 | throw new IOException("Algorithm not supported:" + spec); 66 | } catch (InvalidKeyException ike) { 67 | throw new IOException("Invalid encryption key"); 68 | } 69 | } 70 | 71 | public int getBlockSize() { 72 | return 8; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/SshPublicKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components; 22 | 23 | import com.sshtools.ssh.SshException; 24 | 25 | /** 26 | *

27 | * Interface for SSH supported public keys. 28 | *

29 | * 30 | * @author Lee David Painter 31 | */ 32 | public interface SshPublicKey { 33 | 34 | /** 35 | * Initialize the public key from a blob of binary data. 36 | * 37 | * @param blob 38 | * @param start 39 | * @param len 40 | * @throws SshException 41 | */ 42 | public void init(byte[] blob, int start, int len) throws SshException; 43 | 44 | /** 45 | * Get the algorithm name for the public key. 46 | * 47 | * @return the algorithm name, for example "ssh-dss" 48 | */ 49 | public String getAlgorithm(); 50 | 51 | /** 52 | * Get the bit length of the public key 53 | * 54 | * @return the bit length of the public key 55 | */ 56 | public int getBitLength(); 57 | 58 | /** 59 | * Encode the public key into a blob of binary data, the encoded result will 60 | * be passed into init to recreate the key. 61 | * 62 | * @return an encoded byte array 63 | * @throws SshException 64 | */ 65 | public byte[] getEncoded() throws SshException; 66 | 67 | /** 68 | * Return an SSH fingerprint of the public key 69 | * 70 | * @return String 71 | * @throws SshException 72 | */ 73 | public String getFingerprint() throws SshException; 74 | 75 | /** 76 | * Verify the signature. 77 | * 78 | * @param signature 79 | * @param data 80 | * @return true if the signature was produced by the 81 | * corresponding private key that owns this public key, otherwise 82 | * false. 83 | * @throws SshException 84 | */ 85 | public boolean verifySignature(byte[] signature, byte[] data) 86 | throws SshException; 87 | } 88 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/CommandExecutor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh; 22 | 23 | import java.io.IOException; 24 | 25 | /** 26 | * Simple command executor class. This class will output commands to a shell in 27 | * order to execute them synchronously. This requires prior knowledge of the 28 | * shell prompt and required EOL. For a more detailed implementation use the 29 | * {@link Shell} class. 30 | * 31 | * @author Lee David Painter 32 | * @deprecated 33 | */ 34 | public class CommandExecutor { 35 | 36 | SshSession session; 37 | String eol; 38 | String prompt; 39 | String encoding; 40 | 41 | public CommandExecutor(SshSession session, String eol, String promptCmd, 42 | String prompt, String encoding) throws SshException, IOException { 43 | this.session = session; 44 | this.eol = eol; 45 | this.prompt = prompt; 46 | this.encoding = encoding; 47 | 48 | executeCommand(promptCmd); 49 | 50 | } 51 | 52 | public String executeCommand(String cmd) throws SshException, IOException { 53 | 54 | try { 55 | // write the command + eol to the outputstream 56 | session.getOutputStream().write(cmd.getBytes()); 57 | session.getOutputStream().write(eol.getBytes()); 58 | 59 | // read the input stream until reached the end (-1) or reached the 60 | // promptString 61 | StringBuffer buf = new StringBuffer(); 62 | int ch; 63 | do { 64 | ch = session.getInputStream().read(); 65 | 66 | // no more bytes to read so break 67 | if (ch == -1) 68 | break; 69 | 70 | // save the character read to the buffer 71 | buf.append((char) ch); 72 | } while (!buf.toString().endsWith(prompt)); 73 | // ??? error in return statement when do-while ends from ch==-1. 74 | return buf.toString().substring(0, buf.length() - prompt.length()) 75 | .trim(); 76 | } catch (SshIOException ex) { 77 | throw ex.getRealException(); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/components/jce/AbstractDigest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.components.jce; 22 | 23 | import java.math.BigInteger; 24 | import java.security.MessageDigest; 25 | import java.security.NoSuchAlgorithmException; 26 | 27 | import com.sshtools.ssh.components.Digest; 28 | import com.sshtools.util.ByteArrayWriter; 29 | 30 | /** 31 | * An abstract class that implements the 32 | * {@link com.sshtools.ssh.components.Digest} interface to provide support for 33 | * JCE based digests. 34 | * 35 | * @author Lee David Painter 36 | * 37 | */ 38 | public class AbstractDigest implements Digest { 39 | 40 | MessageDigest digest; 41 | String jceAlgorithm; 42 | 43 | public AbstractDigest(String jceAlgorithm) throws NoSuchAlgorithmException { 44 | digest = JCEProvider.getProviderForAlgorithm(jceAlgorithm) == null ? MessageDigest 45 | .getInstance(jceAlgorithm) : MessageDigest 46 | .getInstance(jceAlgorithm, 47 | JCEProvider.getProviderForAlgorithm(jceAlgorithm)); 48 | } 49 | 50 | public byte[] doFinal() { 51 | return digest.digest(); 52 | } 53 | 54 | public void putBigInteger(BigInteger bi) { 55 | 56 | byte[] data = bi.toByteArray(); 57 | putInt(data.length); 58 | putBytes(data); 59 | } 60 | 61 | public void putByte(byte b) { 62 | digest.update(b); 63 | } 64 | 65 | public void putBytes(byte[] data) { 66 | digest.update(data, 0, data.length); 67 | } 68 | 69 | public void putBytes(byte[] data, int offset, int len) { 70 | digest.update(data, offset, len); 71 | } 72 | 73 | public void putInt(int i) { 74 | putBytes(ByteArrayWriter.encodeInt(i)); 75 | } 76 | 77 | public void putString(String str) { 78 | putInt(str.length()); 79 | putBytes(str.getBytes()); 80 | } 81 | 82 | public void reset() { 83 | digest.reset(); 84 | } 85 | 86 | public String getProvider() { 87 | return digest.getProvider().getName(); 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/socks/Authentication.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | /** 22 | * This file is originally from the http://sourceforge.net/projects/jsocks/ 23 | * released under the LGPL. 24 | */ 25 | package socks; 26 | 27 | /** 28 | The Authentication interface provides for performing method specific 29 | authentication for SOCKS5 connections. 30 | */ 31 | public interface Authentication{ 32 | /** 33 | This method is called when SOCKS5 server have selected a particular 34 | authentication method, for whch an implementaion have been registered. 35 | 36 |

37 | This method should return an array {inputstream,outputstream 38 | [,UDPEncapsulation]}. The reason for that is that SOCKS5 protocol 39 | allows to have method specific encapsulation of data on the socket for 40 | purposes of integrity or security. And this encapsulation should be 41 | performed by those streams returned from the method. It is also possible 42 | to encapsulate datagrams. If authentication method supports such 43 | encapsulation an instance of the UDPEncapsulation interface should be 44 | returned as third element of the array, otherwise either null should be 45 | returned as third element, or array should contain only 2 elements. 46 | 47 | @param methodId Authentication method selected by the server. 48 | @param proxySocket Socket used to conect to the proxy. 49 | @return Two or three element array containing 50 | Input/Output streams which should be used on this connection. 51 | Third argument is optional and should contain an instance 52 | of UDPEncapsulation. It should be provided if the authentication 53 | method used requires any encapsulation to be done on the 54 | datagrams. 55 | */ 56 | Object[] doSocksAuthentication(int methodId,java.net.Socket proxySocket) 57 | throws java.io.IOException; 58 | } 59 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/SshTransport.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh; 22 | 23 | import java.io.IOException; 24 | 25 | /** 26 | * 27 | *

28 | * Simple interface wrapper for transport layer communication. An SSH connection 29 | * requires a transport layer for communication and this interface defines the 30 | * general contract. Typically SSH will execute over a TCPIP Socket however the 31 | * use of this interface allows any type of transport that can expose a set of 32 | * I/O streams. In the simplest form this interface will be implemented for a 33 | * Socket as follows:

34 | * 35 | *
36 |  * import java.net.Socket;
37 |  * import java.io.*;
38 |  * 
39 |  * public class SocketTransport extends Socket implements SshTransport {
40 |  *   public SocketProvider(String host, int port) throws IOException {
41 |  *     super(host, port);
42 |  *   }
43 |  *   public String getConnectedHost() {
44 |  *      return getInetAddress().getHostName();
45 |  *   }
46 |  * 
47 |  *   ** The close, getInputStream and getOutputStream methods are exposed **
48 |  *   ** directly by the Socket.                                           **
49 |  * 
50 | * 51 | * 52 | *

53 | * 54 | * @author Lee David Painter 55 | */ 56 | public interface SshTransport extends SshIO { 57 | 58 | /** 59 | * Get the name of the connected host. 60 | * 61 | * @return the name of the connected host 62 | */ 63 | public String getHost(); 64 | 65 | /** 66 | * Get the port of this connection 67 | * 68 | * @return int 69 | */ 70 | public int getPort(); 71 | 72 | /** 73 | * Create a new copy of this transport and connect to the same host:port 74 | * combination. This is used by the SshClient to duplicate a client 75 | * connection. 76 | * 77 | * @return SshTransport 78 | * @throws SshException 79 | */ 80 | public SshTransport duplicate() throws IOException; 81 | 82 | } 83 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/util/SimpleASNReader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.util; 22 | 23 | import java.io.IOException; 24 | 25 | /** 26 | * 27 | * 28 | * @author $author$ 29 | */ 30 | public class SimpleASNReader { 31 | private byte[] data; 32 | private int offset; 33 | 34 | /** 35 | * Creates a new SimpleASNReader object. 36 | * 37 | * @param data 38 | */ 39 | public SimpleASNReader(byte[] data) { 40 | this.data = data; 41 | this.offset = 0; 42 | } 43 | 44 | /** 45 | * 46 | * 47 | * @param b 48 | * 49 | * @throws IOException 50 | */ 51 | public void assertByte(int b) throws IOException { 52 | int x = getByte(); 53 | 54 | if (x != b) { 55 | throw new IOException("Assertion failed, next byte value is " 56 | + Integer.toHexString(x) + " instead of asserted " 57 | + Integer.toHexString(b)); 58 | } 59 | } 60 | 61 | /** 62 | * 63 | * 64 | * @return 65 | */ 66 | public int getByte() { 67 | return data[offset++] & 0xff; 68 | } 69 | 70 | /** 71 | * 72 | * 73 | * @return 74 | */ 75 | public byte[] getData() { 76 | int length = getLength(); 77 | 78 | return getData(length); 79 | } 80 | 81 | /** 82 | * 83 | * 84 | * @return 85 | */ 86 | public int getLength() { 87 | int b = data[offset++] & 0xff; 88 | 89 | if ((b & 0x80) != 0) { 90 | int length = 0; 91 | 92 | for (int bytes = b & 0x7f; bytes > 0; bytes--) { 93 | length <<= 8; 94 | length |= (data[offset++] & 0xff); 95 | } 96 | 97 | return length; 98 | } 99 | 100 | return b; 101 | } 102 | 103 | private byte[] getData(int length) { 104 | byte[] result = new byte[length]; 105 | System.arraycopy(data, offset, result, 0, length); 106 | offset += length; 107 | 108 | return result; 109 | } 110 | 111 | /** 112 | * 113 | * 114 | * @return 115 | */ 116 | public boolean hasMoreData() { 117 | return offset < data.length; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/net/SocketTransport.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.net; 22 | 23 | import java.io.IOException; 24 | import java.lang.reflect.Method; 25 | import java.net.Socket; 26 | 27 | import com.sshtools.ssh.SocketTimeoutSupport; 28 | import com.sshtools.ssh.SshTransport; 29 | 30 | /** 31 | * Extends a Socket to provide an SshTransport suitable for use 33 | * in making connections using the SshConnector. 35 | * 36 | * @author Lee David Painter 37 | */ 38 | public class SocketTransport extends Socket implements SshTransport, 39 | SocketTimeoutSupport { 40 | 41 | String hostname; 42 | 43 | /** 44 | * Connect the socket. 45 | * 46 | * @param hostname 47 | * @param port 48 | * @throws IOException 49 | */ 50 | public SocketTransport(String hostname, int port) throws IOException { 51 | super(hostname, port); 52 | 53 | this.hostname = hostname; 54 | 55 | /** 56 | * The setSendBufferSize and setReceiveBufferSize methods are 1.2 , so 57 | * we use reflection so that if we are in 1.1 the code doesn't fall 58 | * over. 59 | */ 60 | try { 61 | Method m = Socket.class.getMethod("setSendBufferSize", 62 | new Class[] { int.class }); 63 | m.invoke(this, new Object[] { new Integer(65535) }); 64 | } catch (Throwable t) { 65 | // this will error in 1.1 as it is a 1.2 method, so ignore. 66 | } 67 | 68 | try { 69 | Method m = Socket.class.getMethod("setReceiveBufferSize", 70 | new Class[] { int.class }); 71 | m.invoke(this, new Object[] { new Integer(65535) }); 72 | } catch (Throwable t) { 73 | // this will error in 1.1 as it is a 1.2 method, so ignore. 74 | } 75 | 76 | } 77 | 78 | /** 79 | * Get the hostname of the connected host. 80 | */ 81 | public String getHost() { 82 | return hostname; 83 | } 84 | 85 | public SshTransport duplicate() throws IOException { 86 | return new SocketTransport(getHost(), getPort()); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh/compression/SshCompression.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh.compression; 22 | 23 | import java.io.IOException; 24 | 25 | /** 26 | * 27 | *

28 | * Compression interface which can be implemented to provide the SSH Transport 29 | * Protocol with compression. 30 | *

31 | * 32 | * @author Lee David Painter 33 | */ 34 | public interface SshCompression { 35 | 36 | /** 37 | * Inflation mode 38 | */ 39 | static public final int INFLATER = 0; 40 | 41 | /** 42 | * Deflation mode 43 | */ 44 | static public final int DEFLATER = 1; 45 | 46 | /** 47 | * Initialize the compression. 48 | * 49 | * @param type 50 | * the mode of the compression, should be either INFLATER or 51 | * DEFLATER 52 | * @param level 53 | * the level of compression 54 | */ 55 | public void init(int type, int level); 56 | 57 | /** 58 | * Compress a block of data. 59 | * 60 | * @param data 61 | * the data to compress 62 | * @param start 63 | * the offset of the data to compress 64 | * @param len 65 | * the length of the data 66 | * @return the compressed data with any uncompressed data at the start 67 | * remaining intact. 68 | * @throws IOException 69 | */ 70 | public byte[] compress(byte[] data, int start, int len) throws IOException; 71 | 72 | /** 73 | * Uncompress a block of data. 74 | * 75 | * @param data 76 | * the data to uncompress 77 | * @param start 78 | * the offset of the data to uncompress 79 | * @param len 80 | * the length of the data 81 | * @return the uncompressed data with any data not compressed at the start 82 | * remaining intact. 83 | * @throws IOException 84 | */ 85 | public byte[] uncompress(byte[] data, int start, int len) 86 | throws IOException; 87 | 88 | /** 89 | * Get the algorithm name for this compression implementation. 90 | * 91 | * @return the algorithm name. 92 | */ 93 | public String getAlgorithm(); 94 | 95 | } 96 | -------------------------------------------------------------------------------- /j2ssh-maverick/src/main/java/com/sshtools/ssh2/AuthenticationClient.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2003-2016 SSHTOOLS Limited. All Rights Reserved. 3 | * 4 | * For product documentation visit https://www.sshtools.com/ 5 | * 6 | * This file is part of J2SSH Maverick. 7 | * 8 | * J2SSH Maverick is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * J2SSH Maverick is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with J2SSH Maverick. If not, see . 20 | */ 21 | package com.sshtools.ssh2; 22 | 23 | import java.io.IOException; 24 | 25 | import com.sshtools.ssh.SshAuthentication; 26 | import com.sshtools.ssh.SshException; 27 | 28 | /** 29 | * 30 | *

31 | * Base interface for all SSH authentication mechanisms. Each authentication 32 | * mechanism must conform to this interface which is called by the AuthenticationProtocol after the user 34 | * invokes the authenticate method. Using the methods of the AuthenticationProtocol the 36 | * implementation must read and send messages are required by the authentication 37 | * specification. When the server return's either a SSH_MSG_USERAUTH_SUCCESS or 38 | * SSH_MSG_USERAUTH_FAILURE the readMessage method will throw AuthenticationResult and return back to 40 | * the AuthenticationProtocol. This 41 | * throwable class can also be thrown by the implementor from within the 42 | * mechanisms implementation, for instance if the user cancelled the 43 | * authentication. 44 | *

45 | * 46 | * @author Lee David Painter 47 | */ 48 | public interface AuthenticationClient extends SshAuthentication { 49 | 50 | /** 51 | * Perform the authentication according to the specification. The expected 52 | * result of this method is for the caller to catch an AuthenticationResult. If the method 54 | * returns without throwing this then the caller will attempt to read the 55 | * next message available expecting it to be either a 56 | * SSH_MSG_USERAUTH_SUCCESS or SSH_MSG_USERAUTH_FAILURE. 57 | * 58 | * @param authentication 59 | * @param servicename 60 | * @throws IOException 61 | * @throws AuthenticationResult 62 | */ 63 | public void authenticate(AuthenticationProtocol authentication, 64 | String servicename) throws SshException, AuthenticationResult; 65 | } 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | IMPORTANT 2 | ========= 3 | 4 | This project is no longer maintained and is out of date. Do not use this if you care about the security of your connections. This project is superseded by Maverick Synergy https://github.com/sshtools/maverick-synergy which is maintained and current and addresses all the known vulnerabilities like Terrapin and LogJam. It also uses NIO and has modern builder patterns and immutable objects among other improvements. 5 | 6 | J2SSH Maverick 7 | ============== 8 | 9 | J2SSH Maverick is the successor to the original J2SSH API and includes a complete and stable implementation of an SSH2 client. Originally built from the ground up by the original author back in 2003, this product has, until now, only been available under a commercial license. With the development and pending release of a third generation SSH API, this legacy API has now been released under the LGPL v3 and will continue to be maintained by the core author as a contribution to the open source community. 10 | 11 | License 12 | ------- 13 | 14 | **NEW** This project is now licensed under the LGPL v3 making it available to both commercial and open source applications. 15 | 16 | Maven Repository 17 | ---------------- 18 | 19 | **Releases are now available at maven central.** Simply include the following dependency in your pom. 20 | 21 | ``` 22 | 23 | com.sshtools 24 | j2ssh-maverick 25 | 1.5.5 26 | 27 | ``` 28 | 29 | Binary Builds 30 | ------------- 31 | 32 | Binary builds are available on SourceForge.net at the URL below. 33 | 34 | https://sourceforge.net/projects/sshtools/ 35 | 36 | Documentation 37 | ------------- 38 | 39 | You can find javadocs at http://j2ssh-maverick-javadocs.s3-website-eu-west-1.amazonaws.com 40 | 41 | Examples are included in the binary download or in the src/main/examples folder of the source tree. 42 | 43 | 44 | Status 45 | ------ 46 | 47 | This code was branched from our commercial codebase on August 27th 2014 and converted to a maven project for easier distribution in the ether. The version has been changed to 1.5.0 to avoid conflicts with our commercial codebase which continues to be developed. Bug fixes from our private repository will be pushed to this branch periodically along with any other community contributions that are forthcoming. 48 | 49 | For more information visit our website at https://www.sshtools.com/ 50 | 51 | For product update notifications follow us on Twitter https://www.twitter.com/javassh 52 | 53 | 54 | Author 55 | ------ 56 | 57 | Lee Painter is the original author of the J2SSH API and founder of SSHTOOLS Limited. He has extensive experience in Java network security development, developing our client and server APIs as well as the being the architect and founder of open source projects such as SSL-Explorer and more recently the Hypersocket Framework https://github.com/ludup/hypersocket-framework 58 | 59 | https://www.twitter.com/LeeDavidPainter 60 | 61 | --------------------------------------------------------------------------------