You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2020/04/20 11:37:59 UTC
[mina-sshd] 02/02: [SSHD-978] Autoformat code
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
commit 808cdeaccaeb9e42670c06cae175dafa0e9ce21a
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Mon Apr 20 11:07:37 2020 +0200
[SSHD-978] Autoformat code
---
.../main/java/org/apache/sshd/cli/CliSupport.java | 109 ++-
.../org/apache/sshd/cli/client/ScpCommandMain.java | 27 +-
.../sshd/cli/client/SftpCommandExecutor.java | 2 +-
.../apache/sshd/cli/client/SftpCommandMain.java | 140 ++--
.../sshd/cli/client/SshClientCliSupport.java | 145 ++--
.../org/apache/sshd/cli/client/SshClientMain.java | 34 +-
.../org/apache/sshd/cli/client/SshKeyScanMain.java | 51 +-
.../SftpFileTransferProgressOutputStream.java | 5 +-
.../sshd/cli/server/SshServerCliSupport.java | 40 +-
.../org/apache/sshd/cli/server/SshServerMain.java | 25 +-
.../server/helper/ServerEventListenerHelper.java | 4 +-
.../helper/ServerPortForwardingEventListener.java | 30 +-
.../helper/SftpServerSubSystemEventListener.java | 14 +-
.../apache/sshd/cli/client/ChannelExecMain.java | 8 +-
.../sshd/cli/client/ScpCommandMainDevelopment.java | 4 +-
.../cli/client/SftpCommandMainDevelopment.java | 4 +-
.../sshd/cli/client/SshClientMainDevelopment.java | 4 +-
.../sshd/cli/client/SshKeyScanMainDevelopment.java | 4 +-
.../org/apache/sshd/cli/server/SshFsMounter.java | 19 +-
.../sshd/cli/server/SshServerMainDevelopment.java | 4 +-
.../auth/AuthenticationIdentitiesProvider.java | 12 +-
.../auth/hostbased/HostKeyIdentityProvider.java | 3 +-
.../auth/password/PasswordIdentityProvider.java | 81 +-
.../sshd/client/auth/pubkey/PublicKeyIdentity.java | 10 +-
.../config/hosts/ConfigFileHostEntryResolver.java | 18 +-
.../hosts/DefaultConfigFileHostEntryResolver.java | 24 +-
.../sshd/client/config/hosts/HostConfigEntry.java | 355 ++++----
.../config/hosts/HostConfigEntryResolver.java | 35 +-
.../sshd/client/config/hosts/HostPatternValue.java | 12 +-
.../client/config/hosts/HostPatternsHolder.java | 100 +--
.../sshd/client/config/hosts/KnownHostDigest.java | 3 +-
.../sshd/client/config/hosts/KnownHostEntry.java | 25 +-
.../client/config/hosts/KnownHostHashValue.java | 39 +-
.../keys/BuiltinClientIdentitiesWatcher.java | 16 +-
.../config/keys/ClientIdentitiesWatcher.java | 10 +-
.../sshd/client/config/keys/ClientIdentity.java | 186 ++---
.../config/keys/ClientIdentityFileWatcher.java | 16 +-
.../client/config/keys/ClientIdentityLoader.java | 60 +-
.../config/keys/ClientIdentityLoaderHolder.java | 3 +-
.../client/config/keys/ClientIdentityProvider.java | 77 +-
.../keys/DefaultClientIdentitiesWatcher.java | 9 +-
.../config/keys/LazyClientIdentityIterator.java | 25 +-
.../config/keys/LazyClientKeyIdentityProvider.java | 13 +-
.../apache/sshd/common/AttributeRepository.java | 41 +-
.../org/apache/sshd/common/AttributeStore.java | 33 +-
.../org/apache/sshd/common/BuiltinFactory.java | 4 +-
.../java/org/apache/sshd/common/Closeable.java | 45 +-
.../main/java/org/apache/sshd/common/Factory.java | 4 +-
.../java/org/apache/sshd/common/NamedFactory.java | 32 +-
.../java/org/apache/sshd/common/NamedResource.java | 56 +-
.../org/apache/sshd/common/PropertyResolver.java | 44 +-
.../apache/sshd/common/PropertyResolverUtils.java | 241 +++---
.../java/org/apache/sshd/common/SshConstants.java | 69 +-
.../org/apache/sshd/common/SyspropsMapWrapper.java | 57 +-
.../sshd/common/auth/BasicCredentialsImpl.java | 2 +-
.../sshd/common/auth/UserAuthFactoriesManager.java | 17 +-
.../apache/sshd/common/auth/UserAuthInstance.java | 9 +-
.../sshd/common/auth/UserAuthMethodFactory.java | 62 +-
.../apache/sshd/common/auth/UsernameHolder.java | 3 +-
.../common/channel/PtyChannelConfiguration.java | 14 +-
.../channel/PtyChannelConfigurationHolder.java | 3 +-
.../channel/PtyChannelConfigurationMutator.java | 8 +-
.../org/apache/sshd/common/channel/PtyMode.java | 149 ++--
.../apache/sshd/common/channel/SttySupport.java | 68 +-
.../org/apache/sshd/common/cipher/BaseCipher.java | 14 +-
.../apache/sshd/common/cipher/BaseRC4Cipher.java | 10 +-
.../apache/sshd/common/cipher/BuiltinCiphers.java | 81 +-
.../java/org/apache/sshd/common/cipher/Cipher.java | 37 +-
.../sshd/common/cipher/CipherInformation.java | 7 +-
.../org/apache/sshd/common/cipher/CipherNone.java | 12 +-
.../org/apache/sshd/common/cipher/ECCurves.java | 226 +++---
.../org/apache/sshd/common/cipher/package.html | 18 +-
.../common/compression/BuiltinCompressions.java | 41 +-
.../sshd/common/compression/Compression.java | 21 +-
.../common/compression/CompressionDelayedZlib.java | 2 +-
.../common/compression/CompressionInformation.java | 9 +-
.../sshd/common/compression/CompressionZlib.java | 4 +-
.../apache/sshd/common/compression/package.html | 17 +-
.../sshd/common/config/CompressionConfigValue.java | 8 +-
.../common/config/ConfigFileReaderSupport.java | 76 +-
.../common/config/FactoriesListParseResult.java | 15 +-
.../apache/sshd/common/config/ListParseResult.java | 20 +-
.../apache/sshd/common/config/LogLevelValue.java | 10 +-
.../config/NamedFactoriesListParseResult.java | 10 +-
.../config/NamedResourceListParseResult.java | 13 +-
.../sshd/common/config/SyslogFacilityValue.java | 6 +-
.../apache/sshd/common/config/TimeValueConfig.java | 30 +-
.../sshd/common/config/VersionProperties.java | 7 +-
.../common/config/keys/AuthorizedKeyEntry.java | 155 ++--
.../sshd/common/config/keys/BuiltinIdentities.java | 83 +-
.../common/config/keys/FilePasswordProvider.java | 49 +-
.../config/keys/FilePasswordProviderHolder.java | 5 +-
.../apache/sshd/common/config/keys/Identity.java | 4 +-
.../common/config/keys/IdentityResourceLoader.java | 15 +-
.../sshd/common/config/keys/IdentityUtils.java | 59 +-
.../sshd/common/config/keys/KeyEntryResolver.java | 105 +--
.../sshd/common/config/keys/KeyRandomArt.java | 111 ++-
.../common/config/keys/KeyTypeNamesSupport.java | 35 +-
.../apache/sshd/common/config/keys/KeyUtils.java | 509 ++++++------
.../common/config/keys/OpenSshCertificateImpl.java | 12 +-
.../common/config/keys/PrivateKeyEntryDecoder.java | 66 +-
.../config/keys/PrivateKeyEntryResolver.java | 14 +-
.../sshd/common/config/keys/PublicKeyEntry.java | 235 +++---
.../config/keys/PublicKeyEntryDataResolver.java | 16 +-
.../common/config/keys/PublicKeyEntryDecoder.java | 20 +-
.../common/config/keys/PublicKeyEntryResolver.java | 16 +-
.../config/keys/PublicKeyRawDataDecoder.java | 40 +-
.../common/config/keys/PublicKeyRawDataReader.java | 25 +-
.../keys/impl/AbstractIdentityResourceLoader.java | 12 +-
.../config/keys/impl/AbstractKeyEntryResolver.java | 10 +-
.../keys/impl/AbstractPrivateKeyEntryDecoder.java | 10 +-
.../keys/impl/AbstractPublicKeyEntryDecoder.java | 10 +-
.../config/keys/impl/DSSPublicKeyEntryDecoder.java | 5 +-
.../keys/impl/ECDSAPublicKeyEntryDecoder.java | 16 +-
.../keys/impl/OpenSSHCertificateDecoder.java | 19 +-
.../config/keys/impl/RSAPublicKeyDecoder.java | 30 +-
.../keys/impl/SkECDSAPublicKeyEntryDecoder.java | 6 +-
.../keys/impl/SkED25519PublicKeyEntryDecoder.java | 8 +-
.../keys/loader/AESPrivateKeyObfuscator.java | 19 +-
.../keys/loader/AbstractKeyPairResourceParser.java | 113 ++-
.../keys/loader/AbstractPrivateKeyObfuscator.java | 22 +-
.../keys/loader/DESPrivateKeyObfuscator.java | 9 +-
.../loader/FileWatcherKeyPairResourceLoader.java | 18 +-
.../config/keys/loader/KeyPairResourceLoader.java | 80 +-
.../config/keys/loader/KeyPairResourceParser.java | 58 +-
.../keys/loader/PrivateKeyEncryptionContext.java | 49 +-
.../config/keys/loader/PrivateKeyObfuscator.java | 32 +-
.../openssh/OpenSSHDSSPrivateKeyEntryDecoder.java | 7 +-
.../OpenSSHECDSAPrivateKeyEntryDecoder.java | 7 +-
.../keys/loader/openssh/OpenSSHKeyDecryptor.java | 2 +-
.../openssh/OpenSSHKeyPairResourceParser.java | 132 +--
.../keys/loader/openssh/OpenSSHParserContext.java | 8 +-
.../openssh/OpenSSHRSAPrivateKeyDecoder.java | 5 +-
.../config/keys/loader/openssh/kdf/BCrypt.java | 9 +-
.../keys/loader/openssh/kdf/BCryptKdfOptions.java | 25 +-
.../keys/loader/openssh/kdf/RawKdfOptions.java | 6 +-
.../pem/AbstractPEMResourceKeyPairParser.java | 27 +-
.../loader/pem/DSSPEMResourceKeyPairParser.java | 32 +-
.../loader/pem/ECDSAPEMResourceKeyPairParser.java | 64 +-
.../keys/loader/pem/PEMResourceParserUtils.java | 8 +-
.../loader/pem/PKCS8PEMResourceKeyPairParser.java | 27 +-
.../loader/pem/RSAPEMResourceKeyPairParser.java | 32 +-
.../loader/ssh2/Ssh2PublicKeyEntryDecoder.java | 54 +-
.../org/apache/sshd/common/digest/BaseDigest.java | 11 +-
.../apache/sshd/common/digest/BuiltinDigests.java | 40 +-
.../java/org/apache/sshd/common/digest/Digest.java | 5 +-
.../org/apache/sshd/common/digest/DigestUtils.java | 116 +--
.../org/apache/sshd/common/digest/package.html | 17 +-
.../apache/sshd/common/file/FileSystemAware.java | 4 +-
.../common/file/root/RootedFileSystemProvider.java | 45 +-
.../sshd/common/file/util/BaseFileSystem.java | 5 +-
.../org/apache/sshd/common/file/util/BasePath.java | 9 +-
.../sshd/common/file/util/MockFileSystem.java | 2 +-
.../org/apache/sshd/common/file/util/MockPath.java | 2 +-
.../sshd/common/future/AbstractSshFuture.java | 114 +--
.../org/apache/sshd/common/future/CloseFuture.java | 5 +-
.../sshd/common/future/DefaultCloseFuture.java | 6 +-
.../sshd/common/future/DefaultSshFuture.java | 34 +-
.../common/future/DefaultVerifiableSshFuture.java | 4 +-
.../org/apache/sshd/common/future/SshFuture.java | 25 +-
.../sshd/common/future/SshFutureListener.java | 14 +-
.../sshd/common/future/VerifiableFuture.java | 34 +-
.../apache/sshd/common/future/WaitableFuture.java | 84 +-
.../sshd/common/io/AbstractIoWriteFuture.java | 6 +-
.../org/apache/sshd/common/io/IoConnectFuture.java | 27 +-
.../org/apache/sshd/common/io/IoConnector.java | 14 +-
.../org/apache/sshd/common/io/IoInputStream.java | 4 +-
.../org/apache/sshd/common/io/IoReadFuture.java | 5 +-
.../java/org/apache/sshd/common/io/IoService.java | 8 +-
.../sshd/common/io/IoServiceEventListener.java | 74 +-
.../java/org/apache/sshd/common/io/IoSession.java | 40 +-
.../org/apache/sshd/common/io/IoWriteFuture.java | 6 +-
.../org/apache/sshd/common/io/PacketWriter.java | 45 +-
.../apache/sshd/common/kex/KexProposalOption.java | 38 +-
.../java/org/apache/sshd/common/kex/KexState.java | 3 +-
.../common/kex/extension/KexExtensionParser.java | 8 +-
.../sshd/common/kex/extension/KexExtensions.java | 68 +-
.../parser/AbstractKexExtensionParser.java | 4 +-
.../kex/extension/parser/DelayCompression.java | 4 +-
.../parser/DelayedCompressionAlgorithms.java | 14 +-
.../common/kex/extension/parser/Elevation.java | 2 +-
.../common/kex/extension/parser/NoFlowControl.java | 2 +-
.../parser/ServerSignatureAlgorithms.java | 2 +-
.../AbstractResourceKeyPairProvider.java | 33 +-
.../ClassLoadableResourceKeyPairProvider.java | 9 +-
.../FileHostKeyCertificateProvider.java | 6 +-
.../common/keyprovider/FileKeyPairProvider.java | 7 +-
.../common/keyprovider/KeyIdentityProvider.java | 84 +-
.../keyprovider/KeyIdentityProviderHolder.java | 3 +-
.../sshd/common/keyprovider/KeyPairProvider.java | 87 +-
.../common/keyprovider/KeyPairProviderHolder.java | 4 +-
.../sshd/common/keyprovider/KeyTypeIndicator.java | 17 +-
.../common/keyprovider/MappedKeyPairProvider.java | 12 +-
.../keyprovider/MultiKeyIdentityIterator.java | 9 +-
.../keyprovider/MultiKeyIdentityProvider.java | 4 +-
.../org/apache/sshd/common/mac/BuiltinMacs.java | 70 +-
.../main/java/org/apache/sshd/common/mac/Mac.java | 3 +-
.../org/apache/sshd/common/mac/MacInformation.java | 3 +-
.../java/org/apache/sshd/common/mac/package.html | 17 +-
.../sshd/common/random/JceRandomFactory.java | 2 +-
.../java/org/apache/sshd/common/random/Random.java | 9 +-
.../sshd/common/random/SingletonRandomFactory.java | 3 +-
.../org/apache/sshd/common/random/package.html | 17 +-
.../apache/sshd/common/session/SessionContext.java | 97 ++-
.../common/session/SessionHeartbeatController.java | 20 +-
.../common/session/helpers/TimeoutIndicator.java | 12 +-
.../signature/AbstractSecurityKeySignature.java | 2 +-
.../sshd/common/signature/AbstractSignature.java | 45 +-
.../sshd/common/signature/BuiltinSignatures.java | 68 +-
.../apache/sshd/common/signature/Signature.java | 49 +-
.../apache/sshd/common/signature/SignatureDSA.java | 23 +-
.../sshd/common/signature/SignatureECDSA.java | 17 +-
.../signature/SignatureFactoriesManager.java | 22 +-
.../sshd/common/signature/SignatureFactory.java | 56 +-
.../apache/sshd/common/signature/SignatureRSA.java | 16 +-
.../org/apache/sshd/common/signature/package.html | 17 +-
.../apache/sshd/common/u2f/SkED25519PublicKey.java | 8 +-
.../apache/sshd/common/u2f/SkEcdsaPublicKey.java | 8 +-
.../sshd/common/util/EventListenerUtils.java | 151 ++--
.../org/apache/sshd/common/util/EventNotifier.java | 6 +-
.../org/apache/sshd/common/util/GenericUtils.java | 290 ++++---
.../apache/sshd/common/util/IgnoringEmptyMap.java | 6 +-
.../java/org/apache/sshd/common/util/Invoker.java | 69 +-
.../org/apache/sshd/common/util/MapEntryUtils.java | 11 +-
.../org/apache/sshd/common/util/NumberUtils.java | 27 +-
.../org/apache/sshd/common/util/ObjectBuilder.java | 4 +-
.../java/org/apache/sshd/common/util/OsUtils.java | 64 +-
.../java/org/apache/sshd/common/util/Readable.java | 4 +-
.../org/apache/sshd/common/util/SelectorUtils.java | 295 ++++---
.../apache/sshd/common/util/SshdEventListener.java | 8 +-
.../org/apache/sshd/common/util/VersionInfo.java | 15 +-
.../org/apache/sshd/common/util/buffer/Buffer.java | 209 +++--
.../sshd/common/util/buffer/BufferException.java | 2 +-
.../sshd/common/util/buffer/BufferUtils.java | 248 +++---
.../sshd/common/util/buffer/ByteArrayBuffer.java | 52 +-
.../buffer/keys/AbstractBufferPublicKeyParser.java | 14 +-
.../util/buffer/keys/BufferPublicKeyParser.java | 17 +-
.../util/buffer/keys/ECBufferPublicKeyParser.java | 13 +-
.../buffer/keys/ED25519BufferPublicKeyParser.java | 1 +
.../buffer/keys/OpenSSHCertPublicKeyParser.java | 21 +-
.../buffer/keys/SkECBufferPublicKeyParser.java | 3 +-
.../keys/SkED25519BufferPublicKeyParser.java | 6 +-
.../common/util/closeable/AbstractCloseable.java | 17 +-
.../util/closeable/AbstractInnerCloseable.java | 2 +-
.../apache/sshd/common/util/closeable/Builder.java | 2 +-
.../common/util/closeable/FuturesCloseable.java | 6 +-
.../common/util/closeable/IoBaseCloseable.java | 2 +-
.../common/util/closeable/ParallelCloseable.java | 10 +-
.../common/util/closeable/SequentialCloseable.java | 6 +-
.../common/util/closeable/SimpleCloseable.java | 2 +-
.../sshd/common/util/functors/UnaryEquator.java | 61 +-
.../util/helper/LazyIterablesConcatenator.java | 25 +-
.../util/helper/LazyMatchingTypeIterable.java | 26 +-
.../util/helper/LazyMatchingTypeIterator.java | 26 +-
.../common/util/io/CloseableEmptyInputStream.java | 6 +-
.../sshd/common/util/io/DirectoryScanner.java | 252 +++---
.../sshd/common/util/io/EmptyInputStream.java | 3 +-
.../sshd/common/util/io/FileInfoExtractor.java | 4 +-
.../org/apache/sshd/common/util/io/IoUtils.java | 239 +++---
.../sshd/common/util/io/LimitInputStream.java | 4 +-
.../common/util/io/LoggingFilterOutputStream.java | 4 +-
.../sshd/common/util/io/ModifiableFileWatcher.java | 68 +-
.../sshd/common/util/io/NullInputStream.java | 3 +-
.../sshd/common/util/io/NullOutputStream.java | 3 +-
.../apache/sshd/common/util/io/der/ASN1Class.java | 21 +-
.../apache/sshd/common/util/io/der/ASN1Object.java | 50 +-
.../apache/sshd/common/util/io/der/ASN1Type.java | 21 +-
.../apache/sshd/common/util/io/der/DERParser.java | 47 +-
.../apache/sshd/common/util/io/der/DERWriter.java | 22 +-
.../sshd/common/util/io/functors/IOFunction.java | 52 +-
.../util/io/resource/AbstractIoResource.java | 4 +-
.../sshd/common/util/io/resource/IoResource.java | 11 +-
.../util/io/resource/ResourceStreamProvider.java | 2 +-
.../common/util/logging/AbstractLoggingBean.java | 12 +-
.../sshd/common/util/logging/LoggingUtils.java | 296 +++----
.../sshd/common/util/net/NetworkConnector.java | 4 +-
.../sshd/common/util/net/SshdSocketAddress.java | 195 ++---
.../AbstractSecurityProviderRegistrar.java | 27 +-
.../util/security/SecurityEntityFactory.java | 45 +-
.../util/security/SecurityProviderChoice.java | 13 +-
.../util/security/SecurityProviderRegistrar.java | 163 ++--
.../sshd/common/util/security/SecurityUtils.java | 177 ++--
.../BouncyCastleGeneratorHostKeyProvider.java | 4 +-
.../BouncyCastleKeyPairResourceParser.java | 34 +-
.../security/bouncycastle/BouncyCastleRandom.java | 11 +-
.../bouncycastle/BouncyCastleRandomFactory.java | 2 +-
.../BouncyCastleSecurityProviderRegistrar.java | 2 +-
.../security/eddsa/Ed25519PublicKeyDecoder.java | 21 +-
.../eddsa/EdDSASecurityProviderRegistrar.java | 2 +-
.../security/eddsa/EdDSASecurityProviderUtils.java | 27 +-
.../OpenSSHEd25519PrivateKeyEntryDecoder.java | 28 +-
.../util/security/eddsa/SignatureEd25519.java | 7 +-
.../util/threads/ExecutorServiceProvider.java | 5 +-
.../threads/ManagedExecutorServiceSupplier.java | 5 +-
.../sshd/common/util/threads/NoCloseExecutor.java | 6 +-
.../common/util/threads/SshThreadPoolExecutor.java | 12 +-
.../common/util/threads/SshdThreadFactory.java | 9 +-
.../sshd/common/util/threads/ThreadUtils.java | 73 +-
.../main/java/org/apache/sshd/server/Signal.java | 21 +-
.../AbstractGeneratorHostKeyProvider.java | 29 +-
.../sshd/server/shell/TtyFilterInputStream.java | 15 +-
.../sshd/server/shell/TtyFilterOutputStream.java | 17 +-
.../password/PasswordIdentityProviderTest.java | 6 +-
.../hosts/ConfigFileHostEntryResolverTest.java | 12 +-
.../client/config/hosts/HostConfigEntryTest.java | 58 +-
.../config/hosts/KnownHostHashEntryTest.java | 32 +-
.../config/hosts/KnownHostHashValueTest.java | 32 +-
.../keys/BuiltinClientIdentitiesWatcherTest.java | 9 +-
.../config/keys/ClientIdentityFileWatcherTest.java | 6 +-
.../client/config/keys/ClientIdentityTest.java | 4 +-
.../keys/LazyClientIdentityIteratorTest.java | 18 +-
.../common/PropertyResolverCommonValuesTest.java | 4 +-
.../common/PropertyResolverParseBooleanTest.java | 10 +-
.../org/apache/sshd/common/SshConstantsTest.java | 13 +-
.../sshd/common/channel/PtyModeValueTest.java | 4 +-
.../sshd/common/channel/SttySupportTest.java | 2 +-
.../apache/sshd/common/cipher/BaseCipherTest.java | 27 +-
.../compression/BuiltinCompressionsTest.java | 3 +-
.../sshd/common/config/TimeValueConfigTest.java | 10 +-
.../AuthorizedKeyEntryLoginOptionsParseTest.java | 7 +-
.../common/config/keys/BuiltinIdentitiesTest.java | 8 +-
.../keys/EcdsaPublicKeyEntryDecoderTest.java | 16 +-
.../sshd/common/config/keys/KeyRandomArtTest.java | 13 +-
.../sshd/common/config/keys/KeyUtilsCloneTest.java | 4 +-
.../KeyUtilsFingerprintCaseSensitivityTest.java | 23 +-
.../keys/KeyUtilsFingerprintGenerationTest.java | 94 +--
.../sshd/common/config/keys/KeyUtilsTest.java | 26 +-
.../common/config/keys/PublicKeyEntryTest.java | 12 +-
.../keys/loader/AESPrivateKeyObfuscatorTest.java | 2 +-
.../OpenSSHKeyPairResourceParserDecodingTest.java | 7 +-
.../OpenSSHKeyPairResourceParserPasswordTest.java | 18 +-
.../OpenSSHKeyPairResourceParserTestSupport.java | 4 +-
.../openssh/OpenSSHMaxBCryptRoundsSettingTest.java | 8 +-
.../pem/PKCS8PEMResourceKeyPairParserTest.java | 8 +-
.../Ssh2PublicKeyEntryDecoderByKeyTypeTest.java | 10 +-
.../sshd/common/file/root/AssertableFile.java | 1 +
.../file/root/RootedFileSystemProviderTest.java | 25 +-
.../apache/sshd/common/file/util/BasePathTest.java | 62 +-
.../sshd/common/kex/KexProposalOptionTest.java | 7 +-
.../KeyIdentityProviderResolutionTest.java | 22 +-
.../common/keyprovider/KeyPairProviderTest.java | 12 +-
.../keyprovider/MultiKeyIdentityProviderTest.java | 2 +-
.../apache/sshd/common/mac/BuiltinMacsTest.java | 3 +-
.../org/apache/sshd/common/mac/MacVectorsTest.java | 333 ++++----
.../sshd/common/random/RandomFactoryTest.java | 2 +-
.../common/signature/BuiltinSignaturesTest.java | 3 +-
.../common/signature/RSASignatureVariantsTest.java | 10 +-
.../sshd/common/signature/SignatureDSATest.java | 70 +-
.../common/signature/SignatureRSASHA1Test.java | 25 +-
.../common/signature/SignatureSkECDSATest.java | 16 +-
.../common/signature/SignatureSkED25519Test.java | 16 +-
.../signature/SignatureVariantTestSupport.java | 5 +-
.../common/signature/SignaturesDevelopment.java | 6 +-
.../sshd/common/util/EventListenerUtilsTest.java | 21 +-
.../apache/sshd/common/util/GenericUtilsTest.java | 36 +-
.../apache/sshd/common/util/NumberUtilsTest.java | 10 +-
.../org/apache/sshd/common/util/OsUtilsTest.java | 12 +-
.../apache/sshd/common/util/SelectorUtilsTest.java | 24 +-
.../apache/sshd/common/util/ThreadUtilsTest.java | 9 +-
.../apache/sshd/common/util/buffer/BufferTest.java | 2 +-
.../sshd/common/util/buffer/BufferUtilsTest.java | 2 +-
.../common/util/closeable/CloseableUtilsTest.java | 4 +-
.../util/helper/LazyIterablesConcatenatorTest.java | 12 +-
.../util/helper/LazyMatchingTypeIteratorTest.java | 46 +-
.../sshd/common/util/io/DirectoryScannerTest.java | 4 +-
.../common/util/io/ModifiableFileWatcherTest.java | 22 +-
.../common/util/io/NoCloseInputStreamTest.java | 3 +-
.../sshd/common/util/io/NoCloseWriterTest.java | 2 +-
.../sshd/common/util/io/der/ASN1ClassTest.java | 2 +-
.../sshd/common/util/io/der/ASN1TypeTest.java | 2 +-
.../sshd/common/util/io/der/DERWriterTest.java | 4 +-
.../common/util/net/SshdSocketIpv6AddressTest.java | 31 +-
.../SecurityProviderRegistrarCipherNameTest.java | 4 +-
.../SecurityProviderRegistrarTestSupport.java | 6 +-
.../common/util/security/SecurityUtilsTest.java | 41 +-
.../BouncyCastleGeneratorHostKeyProviderTest.java | 18 +-
.../util/security/eddsa/EDDSAProviderTest.java | 3 +-
.../util/security/eddsa/Ed25519VectorsTest.java | 222 ++---
.../eddsa/EdDSASecurityProviderRegistrarTest.java | 9 +-
.../AbstractGeneratorHostKeyProviderTest.java | 4 +-
.../PEMGeneratorHostKeyProviderTest.java | 19 +-
.../SimpleGeneratorHostKeyProviderTest.java | 15 +-
.../server/shell/TtyFilterInputStreamTest.java | 13 +-
.../server/shell/TtyFilterOutputStreamTest.java | 24 +-
.../sshd/util/test/CommonTestSupportUtils.java | 174 ++--
.../JUnit4ClassRunnerWithParametersFactory.java | 16 +-
.../util/test/JUnit4SingleInstanceClassRunner.java | 2 +-
.../apache/sshd/util/test/JUnitTestSupport.java | 91 +--
.../org/apache/sshd/util/test/NoIoTestCase.java | 4 +-
.../InteractivePasswordIdentityProvider.java | 25 +-
.../channel/throttle/ThrottlingPacketWriter.java | 32 +-
.../common/compression/DeflatingInputStream.java | 2 +-
...elIdTrackingUnknownChannelReferenceHandler.java | 24 +-
.../sshd/common/signature/LegacyDSASigner.java | 22 +-
.../io/ExposedBufferByteArrayOutputStream.java | 1 +
.../sshd/common/util/io/LineOutputStream.java | 4 +-
.../AndroidOpenSSLSecurityProviderRegistrar.java | 10 +-
.../scp/SimpleAccessControlScpEventListener.java | 42 +-
.../proxyprotocol/ProxyProtocolAcceptor.java | 17 +-
.../sftp/DetailedSftpErrorStatusDataHandler.java | 13 +-
.../sftp/SimpleAccessControlSftpEventListener.java | 75 +-
.../InteractivePasswordIdentityProviderTest.java | 40 +-
.../throttle/ThrottlingPacketWriterTest.java | 9 +-
.../sshd/common/signature/LegacyDSASignerTest.java | 19 +-
.../sshd/common/util/io/LineOutputStreamTest.java | 6 +-
.../SimpleAccessControlScpEventListenerTest.java | 6 +-
.../SimpleAccessControlSftpEventListenerTest.java | 17 +-
.../org/apache/sshd/agent/SshAgentConstants.java | 20 +-
.../org/apache/sshd/agent/SshAgentFactory.java | 30 +-
.../java/org/apache/sshd/agent/SshAgentServer.java | 10 +-
.../sshd/agent/common/AbstractAgentClient.java | 4 +-
.../sshd/agent/common/AbstractAgentProxy.java | 18 +-
.../sshd/agent/common/AgentForwardSupport.java | 11 +-
.../agent/common/DefaultAgentForwardSupport.java | 2 +-
.../sshd/agent/local/AgentForwardedChannel.java | 12 +-
.../apache/sshd/agent/local/AgentServerProxy.java | 7 +-
.../sshd/agent/local/ChannelAgentForwarding.java | 20 +-
.../agent/local/ChannelAgentForwardingFactory.java | 2 +-
.../apache/sshd/agent/local/LocalAgentFactory.java | 7 +-
.../apache/sshd/agent/local/ProxyAgentFactory.java | 4 +-
.../org/apache/sshd/agent/unix/AgentClient.java | 11 +-
.../sshd/agent/unix/AgentForwardedChannel.java | 9 +-
.../org/apache/sshd/agent/unix/AgentServer.java | 8 +-
.../apache/sshd/agent/unix/AgentServerProxy.java | 28 +-
.../org/apache/sshd/agent/unix/AprLibrary.java | 25 +-
.../sshd/agent/unix/ChannelAgentForwarding.java | 24 +-
.../agent/unix/ChannelAgentForwardingFactory.java | 5 +-
.../apache/sshd/agent/unix/UnixAgentFactory.java | 11 +-
.../sshd/client/ClientAuthenticationManager.java | 65 +-
.../java/org/apache/sshd/client/ClientBuilder.java | 107 ++-
.../apache/sshd/client/ClientFactoryManager.java | 45 +-
.../java/org/apache/sshd/client/SshClient.java | 273 +++----
.../sshd/client/auth/BuiltinUserAuthFactories.java | 18 +-
.../java/org/apache/sshd/client/auth/UserAuth.java | 14 +-
.../client/auth/hostbased/UserAuthHostBased.java | 51 +-
.../auth/keyboard/UserAuthKeyboardInteractive.java | 130 ++-
.../UserAuthKeyboardInteractiveFactory.java | 2 +-
.../sshd/client/auth/keyboard/UserInteraction.java | 83 +-
.../client/auth/password/UserAuthPassword.java | 55 +-
.../auth/password/UserAuthPasswordFactory.java | 2 +-
.../auth/pubkey/AbstractKeyPairIterator.java | 4 +-
.../sshd/client/auth/pubkey/KeyAgentIdentity.java | 6 +-
.../sshd/client/auth/pubkey/KeyPairIdentity.java | 12 +-
.../client/auth/pubkey/SessionKeyPairIterator.java | 4 +-
.../sshd/client/auth/pubkey/UserAuthPublicKey.java | 57 +-
.../auth/pubkey/UserAuthPublicKeyFactory.java | 2 +-
.../auth/pubkey/UserAuthPublicKeyIterator.java | 15 +-
.../sshd/client/channel/AbstractClientChannel.java | 68 +-
.../sshd/client/channel/ChannelDirectTcpip.java | 9 +-
.../apache/sshd/client/channel/ChannelExec.java | 1 +
.../apache/sshd/client/channel/ChannelSession.java | 26 +-
.../apache/sshd/client/channel/ChannelShell.java | 1 +
.../sshd/client/channel/ChannelSubsystem.java | 5 +-
.../apache/sshd/client/channel/ClientChannel.java | 52 +-
.../sshd/client/channel/ClientChannelEvent.java | 11 +-
.../channel/ClientChannelPendingMessagesQueue.java | 70 +-
.../client/channel/PtyCapableChannelSession.java | 54 +-
.../exit/AbstractChannelExitRequestHandler.java | 58 +-
.../exit/ExitSignalChannelRequestHandler.java | 9 +-
.../exit/ExitStatusChannelRequestHandler.java | 4 +-
.../client/config/SshClientConfigFileReader.java | 6 +-
.../org/apache/sshd/client/future/AuthFuture.java | 36 +-
.../apache/sshd/client/future/ConnectFuture.java | 21 +-
.../sshd/client/future/DefaultAuthFuture.java | 6 +-
.../sshd/client/future/DefaultOpenFuture.java | 6 +-
.../org/apache/sshd/client/future/OpenFuture.java | 21 +-
.../sshd/client/global/OpenSshHostKeysHandler.java | 12 +-
.../client/kex/AbstractDHClientKeyExchange.java | 6 +-
.../java/org/apache/sshd/client/kex/DHGClient.java | 90 ++-
.../org/apache/sshd/client/kex/DHGEXClient.java | 46 +-
.../DefaultKnownHostsServerKeyVerifier.java | 12 +-
.../keyverifier/DelegatingServerKeyVerifier.java | 7 +-
.../keyverifier/KnownHostsServerKeyVerifier.java | 362 +++++----
.../keyverifier/ModifiedServerKeyAcceptor.java | 22 +-
.../sshd/client/keyverifier/ServerKeyVerifier.java | 11 +-
.../keyverifier/StaticServerKeyVerifier.java | 4 +-
.../sshd/client/session/AbstractClientSession.java | 31 +-
.../client/session/ClientConnectionService.java | 18 +-
.../session/ClientConnectionServiceFactory.java | 9 +-
.../sshd/client/session/ClientProxyConnector.java | 25 +-
.../apache/sshd/client/session/ClientSession.java | 306 ++++---
.../sshd/client/session/ClientSessionCreator.java | 185 ++---
.../sshd/client/session/ClientSessionImpl.java | 37 +-
.../sshd/client/session/ClientUserAuthService.java | 49 +-
.../session/ClientUserAuthServiceFactory.java | 2 +-
.../apache/sshd/client/session/SessionFactory.java | 5 +-
.../forward/DynamicPortForwardingTracker.java | 2 +-
.../forward/ExplicitPortForwardingTracker.java | 9 +-
.../session/forward/PortForwardingTracker.java | 12 +-
.../simple/AbstractSimpleClientSessionCreator.java | 16 +-
.../apache/sshd/client/simple/SimpleClient.java | 10 +-
.../client/simple/SimpleClientConfigurator.java | 4 +-
.../sshd/client/simple/SimpleSessionClient.java | 94 +--
.../client/subsystem/AbstractSubsystemClient.java | 6 +-
.../sshd/client/subsystem/SubsystemClient.java | 8 +-
.../java/org/apache/sshd/common/BaseBuilder.java | 147 ++--
.../org/apache/sshd/common/FactoryManager.java | 185 ++---
.../main/java/org/apache/sshd/common/Service.java | 8 +-
.../org/apache/sshd/common/ServiceFactory.java | 13 +-
.../common/auth/AbstractUserAuthMethodFactory.java | 6 +-
.../sshd/common/channel/AbstractChannel.java | 160 ++--
.../common/channel/AbstractRequestHandler.java | 4 +-
.../common/channel/BufferedIoOutputStream.java | 28 +-
.../org/apache/sshd/common/channel/Channel.java | 95 +--
.../common/channel/ChannelAsyncInputStream.java | 6 +-
.../common/channel/ChannelAsyncOutputStream.java | 12 +-
.../apache/sshd/common/channel/ChannelFactory.java | 14 +-
.../sshd/common/channel/ChannelListener.java | 43 +-
.../common/channel/ChannelListenerManager.java | 5 +-
.../sshd/common/channel/ChannelOutputStream.java | 42 +-
.../common/channel/ChannelPipedInputStream.java | 9 +-
.../sshd/common/channel/ChannelPipedSink.java | 6 +-
.../sshd/common/channel/IoWriteFutureImpl.java | 2 +-
.../apache/sshd/common/channel/RequestHandler.java | 32 +-
.../org/apache/sshd/common/channel/Window.java | 88 +-
.../ChannelStreamPacketWriterResolver.java | 14 +-
.../sshd/common/config/SshConfigFileReader.java | 222 +++--
.../apache/sshd/common/file/FileSystemFactory.java | 4 +-
.../file/nativefs/NativeFileSystemFactory.java | 7 +-
.../file/virtualfs/VirtualFileSystemFactory.java | 4 +-
.../common/forward/DefaultForwarderFactory.java | 3 +-
.../common/forward/DefaultForwardingFilter.java | 227 +++---
.../sshd/common/forward/ForwardingFilter.java | 16 +-
.../common/forward/ForwardingFilterFactory.java | 5 +-
.../sshd/common/forward/LocalForwardingEntry.java | 19 +-
.../forward/PortForwardingEventListener.java | 107 ++-
.../PortForwardingEventListenerManager.java | 13 +-
.../PortForwardingEventListenerManagerHolder.java | 7 +-
.../forward/PortForwardingInformationProvider.java | 46 +-
.../sshd/common/forward/PortForwardingManager.java | 36 +-
.../org/apache/sshd/common/forward/SocksProxy.java | 34 +-
.../sshd/common/forward/TcpipClientChannel.java | 22 +-
.../forward/TcpipForwardingExceptionMarker.java | 4 +-
.../common/future/DefaultKeyExchangeFuture.java | 6 +-
.../sshd/common/future/KeyExchangeFuture.java | 5 +-
.../global/AbstractOpenSshHostKeysHandler.java | 8 +-
.../common/helpers/AbstractFactoryManager.java | 18 +-
.../sshd/common/io/AbstractIoServiceFactory.java | 4 +-
.../common/io/AbstractIoServiceFactoryFactory.java | 4 +-
.../io/BuiltinIoServiceFactoryFactories.java | 4 +-
.../common/io/DefaultIoServiceFactoryFactory.java | 12 +-
.../apache/sshd/common/io/nio2/Nio2Acceptor.java | 60 +-
.../sshd/common/io/nio2/Nio2CompletionHandler.java | 6 +-
.../apache/sshd/common/io/nio2/Nio2Connector.java | 27 +-
.../common/io/nio2/Nio2DefaultIoWriteFuture.java | 2 +-
.../apache/sshd/common/io/nio2/Nio2Service.java | 17 +-
.../common/io/nio2/Nio2ServiceFactoryFactory.java | 5 +-
.../apache/sshd/common/io/nio2/Nio2Session.java | 73 +-
.../org/apache/sshd/common/kex/AbstractDH.java | 42 +-
.../sshd/common/kex/AbstractKexFactoryManager.java | 16 +-
.../apache/sshd/common/kex/BuiltinDHFactories.java | 68 +-
.../main/java/org/apache/sshd/common/kex/DHG.java | 16 +-
.../org/apache/sshd/common/kex/DHGroupData.java | 160 ++--
.../main/java/org/apache/sshd/common/kex/ECDH.java | 6 +-
.../apache/sshd/common/kex/KexFactoryManager.java | 13 +-
.../org/apache/sshd/common/kex/KeyExchange.java | 20 +-
.../apache/sshd/common/kex/KeyExchangeFactory.java | 5 +-
.../DefaultClientKexExtensionHandler.java | 86 +-
.../common/kex/extension/KexExtensionHandler.java | 128 ++-
.../session/AbstractConnectionServiceFactory.java | 3 +-
.../sshd/common/session/ConnectionService.java | 4 +-
.../session/ReservedSessionMessagesHandler.java | 48 +-
.../org/apache/sshd/common/session/Session.java | 211 +++--
.../common/session/SessionDisconnectHandler.java | 133 ++-
.../apache/sshd/common/session/SessionHolder.java | 4 +-
.../sshd/common/session/SessionListener.java | 60 +-
.../common/session/SessionListenerManager.java | 15 +-
.../session/UnknownChannelReferenceHandler.java | 19 +-
.../UnknownChannelReferenceHandlerManager.java | 12 +-
.../session/helpers/AbstractConnectionService.java | 134 ++-
.../AbstractConnectionServiceRequestHandler.java | 3 +-
.../common/session/helpers/AbstractSession.java | 496 ++++++------
.../session/helpers/AbstractSessionFactory.java | 9 +-
.../session/helpers/AbstractSessionIoHandler.java | 5 +-
.../DefaultUnknownChannelReferenceHandler.java | 27 +-
.../helpers/MissingAttachedSessionException.java | 4 +-
.../helpers/MultipleAttachedSessionException.java | 5 +-
.../common/session/helpers/PendingWriteFuture.java | 2 +-
.../ReservedSessionMessagesHandlerAdapter.java | 7 +-
.../sshd/common/session/helpers/SessionHelper.java | 299 ++++---
.../session/helpers/SessionTimeoutListener.java | 10 +-
.../apache/sshd/server/ChannelSessionAware.java | 3 +-
.../java/org/apache/sshd/server/Environment.java | 18 +-
.../sshd/server/ServerAuthenticationManager.java | 146 ++--
.../java/org/apache/sshd/server/ServerBuilder.java | 114 ++-
.../apache/sshd/server/ServerFactoryManager.java | 52 +-
.../java/org/apache/sshd/server/SessionAware.java | 4 +-
.../org/apache/sshd/server/SignalListener.java | 2 +-
.../java/org/apache/sshd/server/SshServer.java | 85 +-
.../apache/sshd/server/StandardEnvironment.java | 22 +-
.../sshd/server/auth/AsyncAuthException.java | 2 +-
.../sshd/server/auth/BuiltinUserAuthFactories.java | 18 +-
.../java/org/apache/sshd/server/auth/UserAuth.java | 27 +-
.../sshd/server/auth/UserAuthNoneFactory.java | 2 +-
.../sshd/server/auth/WelcomeBannerPhase.java | 13 +-
.../sshd/server/auth/gss/CredentialHelper.java | 9 +-
.../sshd/server/auth/gss/GSSAuthenticator.java | 30 +-
.../apache/sshd/server/auth/gss/UserAuthGSS.java | 21 +-
.../sshd/server/auth/gss/UserAuthGSSFactory.java | 2 +-
.../auth/hostbased/HostBasedAuthenticator.java | 20 +-
.../hostbased/StaticHostBasedAuthenticator.java | 19 +-
.../server/auth/hostbased/UserAuthHostBased.java | 37 +-
.../auth/hostbased/UserAuthHostBasedFactory.java | 2 +-
.../DefaultKeyboardInteractiveAuthenticator.java | 7 +-
.../server/auth/keyboard/InteractiveChallenge.java | 9 +-
.../keyboard/KeyboardInteractiveAuthenticator.java | 39 +-
.../auth/keyboard/UserAuthKeyboardInteractive.java | 25 +-
.../UserAuthKeyboardInteractiveFactory.java | 2 +-
.../password/AcceptAllPasswordAuthenticator.java | 2 +-
.../auth/password/PasswordAuthenticator.java | 34 +-
.../password/PasswordChangeRequiredException.java | 7 +-
.../password/RejectAllPasswordAuthenticator.java | 2 +-
.../auth/password/StaticPasswordAuthenticator.java | 2 +-
.../server/auth/password/UserAuthPassword.java | 77 +-
.../auth/password/UserAuthPasswordFactory.java | 2 +-
.../pubkey/AcceptAllPublickeyAuthenticator.java | 2 +-
.../auth/pubkey/CachingPublicKeyAuthenticator.java | 19 +-
.../auth/pubkey/KeySetPublickeyAuthenticator.java | 2 +-
.../server/auth/pubkey/PublickeyAuthenticator.java | 31 +-
.../pubkey/RejectAllPublickeyAuthenticator.java | 2 +-
.../auth/pubkey/StaticPublickeyAuthenticator.java | 8 +-
.../sshd/server/auth/pubkey/UserAuthPublicKey.java | 37 +-
.../auth/pubkey/UserAuthPublicKeyFactory.java | 2 +-
.../sshd/server/channel/AbstractServerChannel.java | 15 +-
.../sshd/server/channel/ChannelDataReceiver.java | 76 +-
.../apache/sshd/server/channel/ChannelSession.java | 186 ++---
.../sshd/server/channel/ChannelSessionFactory.java | 2 +-
.../sshd/server/channel/PipeDataReceiver.java | 7 +-
.../sshd/server/channel/PuttyRequestHandler.java | 39 +-
.../server/command/AbstractCommandSupport.java | 17 +-
.../command/AbstractDelegatingCommandFactory.java | 13 +-
.../server/command/AbstractFileSystemCommand.java | 4 +-
.../apache/sshd/server/command/AsyncCommand.java | 3 +-
.../org/apache/sshd/server/command/Command.java | 8 +-
.../apache/sshd/server/command/CommandFactory.java | 21 +-
.../sshd/server/command/CommandLifecycle.java | 17 +-
.../server/config/AllowTcpForwardingValue.java | 6 +-
.../server/config/SshServerConfigFileReader.java | 15 +-
.../config/keys/AuthorizedKeysAuthenticator.java | 46 +-
.../keys/DefaultAuthorizedKeysAuthenticator.java | 29 +-
.../sshd/server/config/keys/ServerIdentity.java | 110 ++-
.../server/forward/AcceptAllForwardingFilter.java | 2 +-
.../sshd/server/forward/AgentForwardingFilter.java | 11 +-
.../sshd/server/forward/DirectTcpipFactory.java | 2 +-
.../sshd/server/forward/ForwardedTcpipFactory.java | 2 +-
.../sshd/server/forward/ForwardingFilter.java | 8 +-
.../server/forward/RejectAllForwardingFilter.java | 2 +-
.../forward/StaticDecisionForwardingFilter.java | 14 +-
.../sshd/server/forward/TcpForwardingFilter.java | 58 +-
.../sshd/server/forward/TcpipServerChannel.java | 122 +--
.../sshd/server/forward/X11ForwardingFilter.java | 11 +-
.../server/global/CancelTcpipForwardHandler.java | 4 +-
.../sshd/server/global/KeepAliveHandler.java | 2 +-
.../sshd/server/global/NoMoreSessionsHandler.java | 4 +-
.../sshd/server/global/OpenSshHostKeysHandler.java | 13 +-
.../sshd/server/global/TcpipForwardHandler.java | 6 +-
.../server/jaas/JaasPasswordAuthenticator.java | 2 +-
.../server/kex/AbstractDHServerKeyExchange.java | 4 +-
.../org/apache/sshd/server/kex/DHGEXServer.java | 61 +-
.../java/org/apache/sshd/server/kex/DHGServer.java | 15 +-
.../java/org/apache/sshd/server/kex/Moduli.java | 6 +-
.../sshd/server/session/AbstractServerSession.java | 136 ++--
.../session/ServerConnectionServiceFactory.java | 8 +-
.../sshd/server/session/ServerProxyAcceptor.java | 40 +-
.../apache/sshd/server/session/ServerSession.java | 50 +-
.../sshd/server/session/ServerSessionImpl.java | 2 +-
.../sshd/server/session/ServerUserAuthService.java | 144 ++--
.../session/ServerUserAuthServiceFactory.java | 2 +-
.../apache/sshd/server/session/SessionFactory.java | 5 +-
.../shell/InteractiveProcessShellFactory.java | 2 +-
.../apache/sshd/server/shell/InvertedShell.java | 15 +-
.../sshd/server/shell/InvertedShellWrapper.java | 44 +-
.../org/apache/sshd/server/shell/ProcessShell.java | 19 +-
.../sshd/server/shell/ProcessShellFactory.java | 5 +-
.../org/apache/sshd/server/shell/ShellFactory.java | 8 +-
.../apache/sshd/server/shell/UnknownCommand.java | 5 +-
.../sshd/server/subsystem/SubsystemFactory.java | 26 +-
.../sshd/server/x11/ChannelForwardedX11.java | 10 +-
.../sshd/server/x11/DefaultX11ForwardSupport.java | 27 +-
.../apache/sshd/server/x11/X11ForwardSupport.java | 27 +-
.../server/x11/X11ForwardingExceptionMarker.java | 4 +-
.../test/java/org/apache/sshd/KeepAliveTest.java | 77 +-
.../java/org/apache/sshd/KeyReExchangeTest.java | 61 +-
.../src/test/java/org/apache/sshd/LoadTest.java | 7 +-
.../src/test/java/org/apache/sshd/ProxyTest.java | 97 ++-
.../java/org/apache/sshd/WindowAdjustTest.java | 27 +-
.../test/java/org/apache/sshd/agent/AgentTest.java | 6 +-
.../client/ClientAuthenticationManagerTest.java | 14 +-
.../org/apache/sshd/client/ClientDeadlockTest.java | 3 +-
.../sshd/client/ClientSessionListenerTest.java | 9 +-
.../java/org/apache/sshd/client/ClientTest.java | 316 ++++----
.../client/auth/BuiltinUserAuthFactoriesTest.java | 7 +-
.../sshd/client/channel/ChannelExecTest.java | 2 +-
.../config/hosts/HostConfigEntryResolverTest.java | 20 +-
.../java/org/apache/sshd/client/kex/KexTest.java | 14 +-
.../KnownHostsServerKeyVerifierTest.java | 32 +-
.../keyverifier/StaticServerKeyVerifierTest.java | 5 +-
.../sshd/client/session/ClientSessionTest.java | 20 +-
.../client/simple/SimpleSessionClientTest.java | 4 +-
.../apache/sshd/common/ForwardingFilterTest.java | 9 +-
.../sshd/common/PropertyResolverUtilsTest.java | 14 +-
.../org/apache/sshd/common/SshBuilderTest.java | 26 +-
.../sshd/common/auth/AuthenticationTest.java | 221 ++---
.../sshd/common/auth/SinglePublicKeyAuthTest.java | 8 +-
.../apache/sshd/common/channel/WindowInitTest.java | 14 +-
.../org/apache/sshd/common/channel/WindowTest.java | 40 +-
.../sshd/common/channel/WindowTimeoutTest.java | 2 +-
.../sshd/common/cipher/BuiltinCiphersTest.java | 15 +-
.../org/apache/sshd/common/cipher/CipherTest.java | 58 +-
.../sshd/common/compression/CompressionTest.java | 9 +-
.../common/config/SshConfigFileReaderTest.java | 54 +-
.../common/config/keys/AuthorizedKeyEntryTest.java | 18 +-
.../config/keys/AuthorizedKeysTestSupport.java | 12 +-
.../forward/AbstractServerCloseTestSupport.java | 19 +-
.../forward/ApacheServerApacheClientTest.java | 2 +-
.../common/forward/ApacheServerJSchClientTest.java | 7 +-
.../common/forward/ConcurrentConnectionTest.java | 13 +-
.../common/forward/LocalForwardingEntryTest.java | 8 +-
.../sshd/common/forward/NoServerNoClientTest.java | 2 +-
.../common/forward/PortForwardingLoadTest.java | 77 +-
.../sshd/common/forward/PortForwardingTest.java | 190 +++--
.../io/BuiltinIoServiceFactoryFactoriesTest.java | 2 +-
.../io/DefaultIoServiceFactoryFactoryTest.java | 7 +-
.../sshd/common/io/nio2/Nio2ServiceTest.java | 11 +-
.../org/apache/sshd/common/kex/AbstractDHTest.java | 5 +-
.../sshd/common/kex/BuiltinDHFactoriesTest.java | 3 +-
.../sshd/common/kex/DHGroupDataParseTest.java | 6 +-
.../apache/sshd/common/kex/KeyExchangeTest.java | 3 +-
.../kex/extension/KexExtensionHandlerTest.java | 22 +-
.../apache/sshd/common/mac/EncryptThenMacTest.java | 6 +-
.../sshd/common/mac/MacCompatibilityTest.java | 21 +-
.../ReservedSessionMessagesHandlerTest.java | 9 +-
.../session/helpers/AbstractSessionTest.java | 43 +-
.../common/signature/OpenSSHCertificateTest.java | 20 +-
.../common/signature/SignatureFactoriesTest.java | 23 +-
.../sshd/server/PasswordAuthenticatorTest.java | 2 +-
.../sshd/server/PublickeyAuthenticatorTest.java | 20 +-
.../server/ServerAuthenticationManagerTest.java | 5 +-
.../sshd/server/ServerProxyAcceptorTest.java | 20 +-
.../sshd/server/ServerSessionListenerTest.java | 18 +-
.../java/org/apache/sshd/server/ServerTest.java | 141 ++--
.../sshd/server/auth/AsyncAuthInteractiveTest.java | 7 +-
.../org/apache/sshd/server/auth/AsyncAuthTest.java | 7 +-
.../apache/sshd/server/auth/AsyncAuthTestBase.java | 6 +-
.../server/auth/BuiltinUserAuthFactoriesTest.java | 7 +-
.../sshd/server/auth/WelcomeBannerPhaseTest.java | 5 +-
.../apache/sshd/server/auth/WelcomeBannerTest.java | 11 +-
.../sshd/server/channel/ChannelSessionTest.java | 33 +-
.../server/command/CommandFactorySplitterTest.java | 18 +-
.../keys/AuthorizedKeysAuthenticatorTest.java | 24 +-
.../DefaultAuthorizedKeysAuthenticatorTest.java | 5 +-
.../server/jaas/JaasPasswordAuthenticatorTest.java | 9 +-
.../server/shell/InvertedShellWrapperTest.java | 8 +-
.../org/apache/sshd/spring/SpringConfigTest.java | 8 +-
.../org/apache/sshd/util/test/BaseTestSupport.java | 33 +-
.../sshd/util/test/BogusPasswordAuthenticator.java | 6 +-
.../sshd/util/test/CommandExecutionHelper.java | 6 +-
.../java/org/apache/sshd/util/test/EchoShell.java | 2 +-
.../java/org/apache/sshd/util/test/JSchLogger.java | 7 +-
.../org/apache/sshd/util/test/SimpleUserInfo.java | 2 +-
.../apache/sshd/util/test/TestChannelListener.java | 2 +-
.../org/apache/sshd/git/AbstractGitCommand.java | 16 +-
.../apache/sshd/git/AbstractGitCommandFactory.java | 14 +-
.../org/apache/sshd/git/GitLocationResolver.java | 21 +-
.../org/apache/sshd/git/pack/GitPackCommand.java | 10 +-
.../apache/sshd/git/pgm/EmbeddedCommandRunner.java | 39 +-
.../org/apache/sshd/git/pgm/GitPgmCommand.java | 12 +-
.../apache/sshd/git/transport/GitSshdSession.java | 29 +-
.../sshd/git/transport/GitSshdSessionFactory.java | 16 +-
.../sshd/git/transport/GitSshdSessionProcess.java | 10 +-
.../apache/sshd/git/pack/GitPackCommandTest.java | 9 +-
.../org/apache/sshd/git/pgm/GitPgmCommandTest.java | 7 +-
.../sshd/common/util/net/LdapNetworkConnector.java | 165 ++--
.../auth/password/LdapPasswordAuthenticator.java | 43 +-
.../auth/pubkey/LdapPublickeyAuthenticator.java | 96 +--
.../sshd/server/auth/BaseAuthenticatorTest.java | 6 +-
.../password/LdapPasswordAuthenticatorTest.java | 8 +-
.../pubkey/LdapPublickeyAuthenticatorTest.java | 12 +-
.../apache/sshd/common/io/mina/MinaAcceptor.java | 8 +-
.../apache/sshd/common/io/mina/MinaConnector.java | 23 +-
.../apache/sshd/common/io/mina/MinaService.java | 13 +-
.../sshd/common/io/mina/MinaServiceFactory.java | 3 +-
.../common/io/mina/MinaServiceFactoryFactory.java | 4 +-
.../apache/sshd/common/io/mina/MinaSession.java | 41 +-
.../sshd/common/io/mina/MinaSessionTest.java | 2 +-
.../org/apache/sshd/netty/NettyIoAcceptor.java | 87 +-
.../org/apache/sshd/netty/NettyIoConnector.java | 95 +--
.../java/org/apache/sshd/netty/NettyIoService.java | 13 +-
.../apache/sshd/netty/NettyIoServiceFactory.java | 7 +-
.../sshd/netty/NettyIoServiceFactoryFactory.java | 3 +-
.../java/org/apache/sshd/netty/NettyIoSession.java | 45 +-
.../java/org/apache/sshd/netty/NettySupport.java | 3 +-
.../openpgp/PGPAuthorizedEntriesTracker.java | 36 +-
.../openpgp/PGPAuthorizedKeyEntriesLoader.java | 29 +-
.../keys/loader/openpgp/PGPKeyFileWatcher.java | 4 +-
.../config/keys/loader/openpgp/PGPKeyLoader.java | 8 +-
.../loader/openpgp/PGPKeyPairResourceParser.java | 44 +-
.../loader/openpgp/PGPPrivateKeyExtractor.java | 12 +-
.../openpgp/PGPPublicKeyEntryDataResolver.java | 19 +-
.../keys/loader/openpgp/PGPPublicKeyExtractor.java | 14 +-
.../loader/openpgp/PGPPublicKeyFileWatcher.java | 8 +-
.../keys/loader/openpgp/PGPPublicRingWatcher.java | 85 +-
.../config/keys/loader/openpgp/PGPUtils.java | 69 +-
.../openpgp/PGPKeyPairResourceParserTest.java | 20 +-
.../loader/openpgp/PGPPublicRingWatcherTest.java | 10 +-
.../loader/openpgp/PGPUtilsKeyFingerprintTest.java | 30 +-
.../keys/loader/putty/AbstractPuttyKeyDecoder.java | 50 +-
.../keys/loader/putty/DSSPuttyKeyDecoder.java | 4 +-
.../keys/loader/putty/ECDSAPuttyKeyDecoder.java | 21 +-
.../keys/loader/putty/EdDSAPuttyKeyDecoder.java | 11 +-
.../loader/putty/PuttyKeyPairResourceParser.java | 46 +-
.../config/keys/loader/putty/PuttyKeyReader.java | 8 +-
.../keys/loader/putty/RSAPuttyKeyDecoder.java | 6 +-
.../keys/loader/putty/PuttyKeyUtilsTest.java | 22 +-
.../apache/sshd/client/scp/AbstractScpClient.java | 75 +-
.../apache/sshd/client/scp/CloseableScpClient.java | 3 +-
.../apache/sshd/client/scp/DefaultScpClient.java | 22 +-
.../sshd/client/scp/DefaultScpStreamResolver.java | 8 +-
.../java/org/apache/sshd/client/scp/ScpClient.java | 33 +-
.../apache/sshd/client/scp/ScpClientCreator.java | 62 +-
.../apache/sshd/client/scp/SimpleScpClient.java | 114 +--
.../sshd/client/scp/SimpleScpClientImpl.java | 11 +-
.../AbstractScpTransferEventListenerAdapter.java | 22 +-
.../org/apache/sshd/common/scp/ScpFileOpener.java | 183 +++--
.../sshd/common/scp/ScpFileOpenerHolder.java | 6 +-
.../java/org/apache/sshd/common/scp/ScpHelper.java | 115 +--
.../org/apache/sshd/common/scp/ScpLocation.java | 49 +-
.../sshd/common/scp/ScpReceiveLineHandler.java | 8 +-
.../sshd/common/scp/ScpSourceStreamResolver.java | 42 +-
.../sshd/common/scp/ScpTargetStreamResolver.java | 50 +-
.../org/apache/sshd/common/scp/ScpTimestamp.java | 21 +-
.../sshd/common/scp/ScpTransferEventListener.java | 56 +-
.../common/scp/helpers/DefaultScpFileOpener.java | 20 +-
.../helpers/LocalFileScpSourceStreamResolver.java | 4 +-
.../helpers/LocalFileScpTargetStreamResolver.java | 19 +-
.../org/apache/sshd/server/scp/ScpCommand.java | 47 +-
.../apache/sshd/server/scp/ScpCommandFactory.java | 40 +-
.../java/org/apache/sshd/client/scp/ScpTest.java | 219 ++---
.../sshd/client/scp/SimpleScpClientTest.java | 4 +-
.../sshd/server/scp/ScpCommandFactoryTest.java | 16 +-
.../sshd/client/subsystem/sftp/RawSftpClient.java | 10 +-
.../sshd/client/subsystem/sftp/SftpClient.java | 328 ++++----
.../client/subsystem/sftp/SftpClientFactory.java | 45 +-
.../subsystem/sftp/SftpDirEntryIterator.java | 32 +-
.../subsystem/sftp/SftpInputStreamWithChannel.java | 5 +-
.../subsystem/sftp/SftpIterableDirEntry.java | 7 +-
.../sftp/SftpOutputStreamWithChannel.java | 5 +-
.../subsystem/sftp/SftpRemotePathChannel.java | 95 +--
.../client/subsystem/sftp/SftpVersionSelector.java | 69 +-
.../client/subsystem/sftp/SimpleSftpClient.java | 114 +--
.../extensions/BuiltinSftpClientExtensions.java | 54 +-
.../sftp/extensions/CheckFileHandleExtension.java | 23 +-
.../sftp/extensions/CheckFileNameExtension.java | 23 +-
.../sftp/extensions/CopyDataExtension.java | 2 +-
.../sftp/extensions/CopyFileExtension.java | 11 +-
.../sftp/extensions/MD5FileExtension.java | 17 +-
.../sftp/extensions/MD5HandleExtension.java | 17 +-
.../sftp/extensions/SpaceAvailableExtension.java | 3 +-
.../helpers/AbstractCheckFileExtension.java | 13 +-
.../helpers/AbstractMD5HashExtension.java | 10 +-
.../helpers/AbstractSftpClientExtension.java | 48 +-
.../helpers/CheckFileHandleExtensionImpl.java | 5 +-
.../helpers/CheckFileNameExtensionImpl.java | 5 +-
.../extensions/helpers/CopyDataExtensionImpl.java | 9 +-
.../extensions/helpers/CopyFileExtensionImpl.java | 6 +-
.../extensions/helpers/MD5FileExtensionImpl.java | 3 +-
.../extensions/helpers/MD5HandleExtensionImpl.java | 3 +-
.../helpers/SpaceAvailableExtensionImpl.java | 3 +-
.../extensions/openssh/OpenSSHFsyncExtension.java | 2 +-
.../openssh/OpenSSHStatExtensionInfo.java | 27 +-
.../openssh/OpenSSHStatPathExtension.java | 4 +-
.../AbstractOpenSSHStatCommandExtension.java | 6 +-
.../subsystem/sftp/fs/SftpDirectoryStream.java | 4 +-
.../client/subsystem/sftp/fs/SftpFileStore.java | 8 +-
.../client/subsystem/sftp/fs/SftpFileSystem.java | 39 +-
.../subsystem/sftp/fs/SftpFileSystemChannel.java | 3 +-
.../fs/SftpFileSystemClientSessionInitializer.java | 43 +-
.../fs/SftpFileSystemInitializationContext.java | 5 +-
.../subsystem/sftp/fs/SftpFileSystemProvider.java | 142 ++--
.../client/subsystem/sftp/fs/SftpPathIterator.java | 2 +-
.../sftp/fs/SftpPosixFileAttributeView.java | 2 +-
.../subsystem/sftp/fs/SftpPosixFileAttributes.java | 2 +-
.../subsystem/sftp/impl/AbstractSftpClient.java | 255 +++---
.../sftp/impl/AbstractSftpFileAttributeView.java | 3 +-
.../sftp/impl/DefaultCloseableHandle.java | 4 +-
.../subsystem/sftp/impl/DefaultSftpClient.java | 75 +-
.../sftp/impl/DefaultSftpClientFactory.java | 7 +-
.../subsystem/sftp/impl/SimpleSftpClientImpl.java | 15 +-
.../sshd/common/subsystem/sftp/SftpConstants.java | 48 +-
.../sshd/common/subsystem/sftp/SftpHelper.java | 252 +++---
.../subsystem/sftp/SftpUniversalOwnerAndGroup.java | 27 +-
.../subsystem/sftp/extensions/AbstractParser.java | 4 +-
.../sftp/extensions/AclSupportedParser.java | 19 +-
.../subsystem/sftp/extensions/ExtensionParser.java | 4 +-
.../subsystem/sftp/extensions/NewlineParser.java | 3 +-
.../subsystem/sftp/extensions/ParserUtils.java | 75 +-
.../extensions/SpaceAvailableExtensionInfo.java | 19 +-
.../sftp/extensions/Supported2Parser.java | 18 +-
.../subsystem/sftp/extensions/SupportedParser.java | 16 +-
.../subsystem/sftp/extensions/VendorIdParser.java | 3 +-
.../subsystem/sftp/extensions/VersionsParser.java | 13 +-
.../openssh/AbstractOpenSSHExtensionParser.java | 2 +-
.../extensions/openssh/FsyncExtensionParser.java | 2 +-
.../openssh/HardLinkExtensionParser.java | 2 +-
.../openssh/LSetStatExtensionParser.java | 5 +-
.../openssh/PosixRenameExtensionParser.java | 2 +-
.../extensions/openssh/StatVfsExtensionParser.java | 2 +-
.../sftp/AbstractSftpEventListenerAdapter.java | 80 +-
.../sftp/AbstractSftpSubsystemHelper.java | 897 ++++++++++-----------
.../server/subsystem/sftp/DirectoryHandle.java | 2 +-
.../sshd/server/subsystem/sftp/FileHandle.java | 24 +-
.../apache/sshd/server/subsystem/sftp/Handle.java | 5 +-
.../subsystem/sftp/SftpErrorStatusDataHandler.java | 56 +-
.../server/subsystem/sftp/SftpEventListener.java | 330 ++++----
.../subsystem/sftp/SftpEventListenerManager.java | 13 +-
.../subsystem/sftp/SftpFileSystemAccessor.java | 154 ++--
.../sshd/server/subsystem/sftp/SftpSubsystem.java | 204 ++---
.../subsystem/sftp/SftpSubsystemEnvironment.java | 8 +-
.../subsystem/sftp/SftpSubsystemFactory.java | 8 +-
.../sshd/server/subsystem/sftp/UnixDateFormat.java | 12 +-
.../subsystem/sftp/UnsupportedAttributePolicy.java | 6 +-
.../sshd/client/subsystem/sftp/ClientTest.java | 22 +-
.../subsystem/sftp/DefaultCloseableHandleTest.java | 3 +-
.../subsystem/sftp/SftpRemotePathChannelTest.java | 35 +-
.../sshd/client/subsystem/sftp/SftpTest.java | 255 +++---
.../subsystem/sftp/SftpVersionSelectorTest.java | 38 +-
.../client/subsystem/sftp/SftpVersionsTest.java | 129 +--
.../subsystem/sftp/SimpleSftpClientTest.java | 9 +-
.../BuiltinSftpClientExtensionsTest.java | 6 +-
.../sftp/extensions/UnsupportedExtensionTest.java | 8 +-
.../sftp/extensions/VersionParserTest.java | 8 +-
.../helpers/AbstractCheckFileExtensionTest.java | 61 +-
.../helpers/AbstractMD5HashExtensionTest.java | 37 +-
.../helpers/CopyDataExtensionImplTest.java | 67 +-
.../helpers/CopyFileExtensionImplTest.java | 2 +-
.../helpers/SpaceAvailableExtensionImplTest.java | 12 +-
.../openssh/helpers/OpenSSHExtensionsTest.java | 19 +-
.../subsystem/sftp/fs/SftpFileSystemTest.java | 52 +-
.../subsystem/sftp/fs/SftpFileSystemURITest.java | 41 +-
.../common/subsystem/sftp/SftpConstantsTest.java | 8 +-
.../sftp/SftpUniversalOwnerAndGroupTest.java | 2 +-
.../subsystem/sftp/SftpSubsystemFactoryTest.java | 22 +-
.../sftp/ApacheSshdSftpSessionFactory.java | 71 +-
.../spring/integration/sftp/SpringSftpSession.java | 3 +-
.../sftp/ApacheSshdSftpSessionFactoryTest.java | 34 +-
945 files changed, 16609 insertions(+), 16674 deletions(-)
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/CliSupport.java b/sshd-cli/src/main/java/org/apache/sshd/cli/CliSupport.java
index f3920a8..3c3863a 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/CliSupport.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/CliSupport.java
@@ -73,11 +73,11 @@ public abstract class CliSupport {
return true;
}
- public static <S extends SessionContext,
- M extends UserAuthInstance<S>, F extends UserAuthMethodFactory<S, M>,
- I extends UserAuthFactoriesManager<S, M, F>>
- void setupUserAuthFactories(
- I manager, PropertyResolver options) {
+ public static <
+ S extends SessionContext,
+ M extends UserAuthInstance<S>, F extends UserAuthMethodFactory<S, M>,
+ I extends UserAuthFactoriesManager<S, M, F>> void setupUserAuthFactories(
+ I manager, PropertyResolver options) {
String methods = options.getString(ConfigFileReaderSupport.PREFERRED_AUTHS_CONFIG_PROP);
if (GenericUtils.isNotEmpty(methods)) {
manager.setUserAuthFactoriesNameList(methods);
@@ -86,13 +86,12 @@ public abstract class CliSupport {
}
/**
- * Scans the arguments for the "-io" command line option and sets the I/O
- * service accordingly. If no specific option specified then {@link #DEFAULT_IO_SERVICE_FACTORY}
- * is used.
+ * Scans the arguments for the "-io" command line option and sets the I/O service accordingly. If no
+ * specific option specified then {@link #DEFAULT_IO_SERVICE_FACTORY} is used.
*
- * @param stderr Error stream for output of error messages
- * @param args The arguments to scan
- * @return The resolved I/O service factory - {@code null} if errors encountered
+ * @param stderr Error stream for output of error messages
+ * @param args The arguments to scan
+ * @return The resolved I/O service factory - {@code null} if errors encountered
*/
public static BuiltinIoServiceFactoryFactories resolveIoServiceFactory(PrintStream stderr, String... args) {
int numArgs = GenericUtils.length(args);
@@ -131,11 +130,10 @@ public abstract class CliSupport {
public static BuiltinIoServiceFactoryFactories resolveBuiltinIoServiceFactory(
PrintStream stderr, String argName, String provider) {
- BuiltinIoServiceFactoryFactories factory =
- BuiltinIoServiceFactoryFactories.fromFactoryName(provider);
+ BuiltinIoServiceFactoryFactories factory = BuiltinIoServiceFactoryFactories.fromFactoryName(provider);
if (factory == null) {
System.err.println(argName + " - unknown provider (" + provider + ")"
- + " should be one of " + BuiltinIoServiceFactoryFactories.VALUES);
+ + " should be one of " + BuiltinIoServiceFactoryFactories.VALUES);
}
return factory;
}
@@ -178,24 +176,24 @@ public abstract class CliSupport {
@Override
public void connectionEstablished(
IoConnector connector, SocketAddress local, AttributeRepository context, SocketAddress remote)
- throws IOException {
+ throws IOException {
out.append("Connection established via ").append(Objects.toString(connector))
- .append("- local=").append(Objects.toString(local))
- .append(", remote=").append(Objects.toString(remote))
- .append(System.lineSeparator());
+ .append("- local=").append(Objects.toString(local))
+ .append(", remote=").append(Objects.toString(remote))
+ .append(System.lineSeparator());
}
@Override
public void abortEstablishedConnection(
IoConnector connector, SocketAddress local, AttributeRepository context,
SocketAddress remote, Throwable reason)
- throws IOException {
+ throws IOException {
out.append("Abort established connection ").append(Objects.toString(connector))
- .append(" - local=").append(Objects.toString(local))
- .append(", remote=").append(Objects.toString(remote))
- .append(": (").append(reason.getClass().getSimpleName()).append(')')
- .append(' ').append(reason.getMessage())
- .append(System.lineSeparator());
+ .append(" - local=").append(Objects.toString(local))
+ .append(", remote=").append(Objects.toString(remote))
+ .append(": (").append(reason.getClass().getSimpleName()).append(')')
+ .append(' ').append(reason.getMessage())
+ .append(System.lineSeparator());
printStackTrace(out, reason);
}
@@ -203,26 +201,26 @@ public abstract class CliSupport {
public void connectionAccepted(
IoAcceptor acceptor, SocketAddress local,
SocketAddress remote, SocketAddress service)
- throws IOException {
+ throws IOException {
out.append("Connection accepted via ").append(Objects.toString(acceptor))
- .append(" - local=").append(Objects.toString(local))
- .append(", remote=").append(Objects.toString(remote))
- .append(", service=").append(Objects.toString(service))
- .append(System.lineSeparator());
+ .append(" - local=").append(Objects.toString(local))
+ .append(", remote=").append(Objects.toString(remote))
+ .append(", service=").append(Objects.toString(service))
+ .append(System.lineSeparator());
}
@Override
public void abortAcceptedConnection(
IoAcceptor acceptor, SocketAddress local, SocketAddress remote,
SocketAddress service, Throwable reason)
- throws IOException {
+ throws IOException {
out.append("Abort accepted connection ").append(Objects.toString(acceptor))
- .append(" - local=").append(Objects.toString(local))
- .append(", remote=").append(Objects.toString(remote))
- .append(", service=").append(Objects.toString(service))
- .append(": (").append(reason.getClass().getSimpleName()).append(')')
- .append(' ').append(reason.getMessage())
- .append(System.lineSeparator());
+ .append(" - local=").append(Objects.toString(local))
+ .append(", remote=").append(Objects.toString(remote))
+ .append(", service=").append(Objects.toString(service))
+ .append(": (").append(reason.getClass().getSimpleName()).append(')')
+ .append(' ').append(reason.getMessage())
+ .append(System.lineSeparator());
printStackTrace(out, reason);
}
};
@@ -236,8 +234,8 @@ public abstract class CliSupport {
Session session, String version, List<String> extraLines) {
try {
out.append(Objects.toString(session))
- .append(" peer identification=").append(version)
- .append(System.lineSeparator());
+ .append(" peer identification=").append(version)
+ .append(System.lineSeparator());
if (GenericUtils.isNotEmpty(extraLines)) {
for (String l : extraLines) {
out.append(" => ").append(l).append(System.lineSeparator());
@@ -249,7 +247,8 @@ public abstract class CliSupport {
}
@Override
- public void sessionNegotiationEnd(Session session,
+ public void sessionNegotiationEnd(
+ Session session,
Map<KexProposalOption, String> clientProposal,
Map<KexProposalOption, String> serverProposal,
Map<KexProposalOption, String> negotiatedOptions,
@@ -260,13 +259,13 @@ public abstract class CliSupport {
try {
out.append(Objects.toString(session))
- .append(" KEX negotiation results:")
- .append(System.lineSeparator());
+ .append(" KEX negotiation results:")
+ .append(System.lineSeparator());
for (KexProposalOption opt : KexProposalOption.VALUES) {
String value = negotiatedOptions.get(opt);
out.append(" ").append(opt.getDescription())
- .append(": ").append(value)
- .append(System.lineSeparator());
+ .append(": ").append(value)
+ .append(System.lineSeparator());
}
} catch (IOException e) {
// ignored
@@ -277,9 +276,9 @@ public abstract class CliSupport {
public void sessionException(Session session, Throwable t) {
try {
out.append(Objects.toString(session))
- .append(' ').append(t.getClass().getSimpleName())
- .append(": ").append(t.getMessage())
- .append(System.lineSeparator());
+ .append(' ').append(t.getClass().getSimpleName())
+ .append(": ").append(t.getMessage())
+ .append(System.lineSeparator());
printStackTrace(out, t);
} catch (IOException e) {
// ignored
@@ -290,8 +289,8 @@ public abstract class CliSupport {
public void sessionClosed(Session session) {
try {
out.append(Objects.toString(session))
- .append(" closed")
- .append(System.lineSeparator());
+ .append(" closed")
+ .append(System.lineSeparator());
} catch (IOException e) {
// ignored
}
@@ -319,16 +318,16 @@ public abstract class CliSupport {
}
/**
- * Looks for the {@link ConfigFileReaderSupport#LOG_LEVEL_CONFIG_PROP} in the options.
- * If found, then uses it as the result. Otherwise, invokes {@link #resolveLoggingVerbosity(String...)}
+ * Looks for the {@link ConfigFileReaderSupport#LOG_LEVEL_CONFIG_PROP} in the options. If found, then uses it as the
+ * result. Otherwise, invokes {@link #resolveLoggingVerbosity(String...)}
*
- * @param resolver The {@code -o} options specified by the user
- * @param args The command line arguments
- * @return The resolved verbosity level
+ * @param resolver The {@code -o} options specified by the user
+ * @param args The command line arguments
+ * @return The resolved verbosity level
*/
public static Level resolveLoggingVerbosity(PropertyResolver resolver, String... args) {
String levelValue = PropertyResolverUtils.getString(
- resolver, ConfigFileReaderSupport.LOG_LEVEL_CONFIG_PROP);
+ resolver, ConfigFileReaderSupport.LOG_LEVEL_CONFIG_PROP);
if (GenericUtils.isEmpty(levelValue)) {
return resolveLoggingVerbosity(args);
}
@@ -336,7 +335,7 @@ public abstract class CliSupport {
LogLevelValue level = LogLevelValue.fromName(levelValue);
if (level == null) {
throw new IllegalArgumentException(
- "Unknown " + ConfigFileReaderSupport.LOG_LEVEL_CONFIG_PROP + " option value: " + levelValue);
+ "Unknown " + ConfigFileReaderSupport.LOG_LEVEL_CONFIG_PROP + " option value: " + levelValue);
}
return level.getLoggingLevel();
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/client/ScpCommandMain.java b/sshd-cli/src/main/java/org/apache/sshd/cli/client/ScpCommandMain.java
index 3f11c19..1e40469 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/client/ScpCommandMain.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/client/ScpCommandMain.java
@@ -57,7 +57,7 @@ public class ScpCommandMain extends SshClientCliSupport {
public static final String SCP_PORT_OPTION = "-P";
public ScpCommandMain() {
- super(); // in case someone wants to extend it
+ super(); // in case someone wants to extend it
}
//////////////////////////////////////////////////////////////////////////
@@ -152,8 +152,8 @@ public class ScpCommandMain extends SshClientCliSupport {
return ScpClientCreator.class.cast(clazz.newInstance());
} catch (Exception e) {
stderr.append("WARNING: Failed (").append(e.getClass().getSimpleName()).append(')')
- .append(" to instantiate ").append(className)
- .append(": ").println(e.getMessage());
+ .append(" to instantiate ").append(className)
+ .append(": ").println(e.getMessage());
stderr.flush();
return null;
}
@@ -180,11 +180,11 @@ public class ScpCommandMain extends SshClientCliSupport {
ScpClientCreator creator = resolveScpClientCreator(stderr, args);
ClientSession session = ((logStream == null) || (creator == null) || GenericUtils.isEmpty(args))
- ? null : setupClientSession(SCP_PORT_OPTION, stdin, level, stdout, stderr, args);
+ ? null : setupClientSession(SCP_PORT_OPTION, stdin, level, stdout, stderr, args);
if (session == null) {
stderr.println("usage: scp [" + SCP_PORT_OPTION + " port] [-i identity] [-io nio2|mina|netty]"
- + " [-v[v][v]] [-E logoutput] [-r] [-p] [-q] [-o option=value] [-o creator=class name]"
- + " [-c cipherlist] [-m maclist] [-w password] [-C] <source> <target>");
+ + " [-v[v][v]] [-E logoutput] [-r] [-p] [-q] [-o option=value] [-o creator=class name]"
+ + " [-c cipherlist] [-m maclist] [-w password] [-C] <source> <target>");
stderr.println();
stderr.println("Where <source> or <target> are either 'user@host:file' or a local file path");
stderr.println("NOTE: exactly ONE of the source or target must be remote and the other one local");
@@ -217,7 +217,8 @@ public class ScpCommandMain extends SshClientCliSupport {
@Override
public void endFolderEvent(
- Session session, FileOperation op, Path file, Set<PosixFilePermission> perms, Throwable thrown) {
+ Session session, FileOperation op, Path file, Set<PosixFilePermission> perms,
+ Throwable thrown) {
logEvent("endFolderEvent", session, op, file, -1L, perms, thrown);
}
@@ -229,7 +230,8 @@ public class ScpCommandMain extends SshClientCliSupport {
@Override
public void endFileEvent(
- Session session, FileOperation op, Path file, long length, Set<PosixFilePermission> perms, Throwable thrown) {
+ Session session, FileOperation op, Path file, long length, Set<PosixFilePermission> perms,
+ Throwable thrown) {
logEvent("endFileEvent", session, op, file, length, perms, thrown);
}
@@ -238,16 +240,17 @@ public class ScpCommandMain extends SshClientCliSupport {
Collection<PosixFilePermission> perms, Throwable thrown) {
PrintStream ps = (thrown == null) ? stdout : stderr;
ps.append(" ").append(name)
- .append('[').append(session.toString()).append(']')
- .append('[').append(op.name()).append(']')
- .append(' ').append(file.toString());
+ .append('[').append(session.toString()).append(']')
+ .append('[').append(op.name()).append(']')
+ .append(' ').append(file.toString());
if (length > 0L) {
ps.append(' ').append("length=").append(Long.toString(length));
}
ps.append(' ').append(String.valueOf(perms));
if (thrown != null) {
- ps.append(" - ").append(thrown.getClass().getSimpleName()).append(": ").append(thrown.getMessage());
+ ps.append(" - ").append(thrown.getClass().getSimpleName()).append(": ")
+ .append(thrown.getMessage());
}
ps.println();
}
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SftpCommandExecutor.java b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SftpCommandExecutor.java
index fb1a762..c5809ab 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SftpCommandExecutor.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SftpCommandExecutor.java
@@ -31,4 +31,4 @@ import org.apache.sshd.common.NamedResource;
public interface SftpCommandExecutor extends NamedResource {
// return value is whether to stop running
boolean executeCommand(String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr) throws Exception;
-}
\ No newline at end of file
+}
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SftpCommandMain.java b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SftpCommandMain.java
index 26d471d..a4641d3 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SftpCommandMain.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SftpCommandMain.java
@@ -119,8 +119,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
new GetCommandExecutor(),
new PutCommandExecutor(),
new ProgressCommandExecutor(),
- new HelpCommandExecutor()
- )) {
+ new HelpCommandExecutor())) {
String name = e.getName();
ValidateUtils.checkTrue(map.put(name, e) == null, "Multiple commands named '%s'", name);
}
@@ -213,14 +212,14 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
protected <A extends Appendable> A appendFileAttributes(
A stdout, SftpClient sftp, String path, Attributes attrs)
- throws IOException {
+ throws IOException {
stdout.append(" ").append(Long.toString(attrs.getSize()))
- .append(" ").append(SftpFileSystemProvider.getRWXPermissions(attrs.getPermissions()));
+ .append(" ").append(SftpFileSystemProvider.getRWXPermissions(attrs.getPermissions()));
if (attrs.isSymbolicLink()) {
String linkValue = sftp.readLink(path);
stdout.append(" => ")
- .append('(').append(attrs.isDirectory() ? "dir" : "file").append(')')
- .append(' ').append(linkValue);
+ .append('(').append(attrs.isDirectory() ? "dir" : "file").append(')')
+ .append(' ').append(linkValue);
}
return stdout;
@@ -292,8 +291,8 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
return SftpClientFactory.class.cast(clazz.newInstance());
} catch (Throwable t) {
System.err.append("Failed (").append(t.getClass().getSimpleName()).append(')')
- .append(" to instantiate ").append(optValue)
- .append(": ").println(t.getMessage());
+ .append(" to instantiate ").append(optValue)
+ .append(": ").println(t.getMessage());
System.err.flush();
throw GenericUtils.toRuntimeException(t, true);
}
@@ -326,12 +325,12 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
}
ClientSession session = (logStream == null)
- ? null
- : setupClientSession(SFTP_PORT_OPTION, stdin, level, stdout, stderr, args);
+ ? null
+ : setupClientSession(SFTP_PORT_OPTION, stdin, level, stdout, stderr, args);
if (session == null) {
System.err.println("usage: sftp [-v[v][v]] [-E logoutput] [-i identity] [-io nio2|mina|netty]"
- + " [-l login] [" + SFTP_PORT_OPTION + " port] [-o option=value]"
- + " [-w password] [-c cipherlist] [-m maclist] [-C] hostname/user@host");
+ + " [-l login] [" + SFTP_PORT_OPTION + " port] [-o option=value]"
+ + " [-w password] [-c cipherlist] [-m maclist] [-C] hostname/user@host");
System.exit(-1);
return;
}
@@ -367,7 +366,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
ValidateUtils.checkTrue(GenericUtils.isEmpty(args), "Unexpected arguments: %s", args);
stdout.println("Exiting");
return true;
@@ -387,7 +386,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
ValidateUtils.checkTrue(GenericUtils.isEmpty(args), "Unexpected arguments: %s", args);
stdout.append(" ").append("Remote: ").println(getCurrentRemoteDirectory());
stdout.append(" ").append("Local: ").println(getCurrentLocalDirectory());
@@ -408,7 +407,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
ValidateUtils.checkTrue(GenericUtils.isEmpty(args), "Unexpected arguments: %s", args);
SftpClient sftp = getClient();
ClientSession session = sftp.getSession();
@@ -438,7 +437,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
ValidateUtils.checkTrue(GenericUtils.isEmpty(args), "Unexpected arguments: %s", args);
SftpClient sftp = getClient();
ClientSession session = sftp.getSession();
@@ -470,19 +469,27 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
ValidateUtils.checkTrue(GenericUtils.isEmpty(args), "Unexpected arguments: %s", args);
SftpClient sftp = getClient();
ClientSession session = sftp.getSession();
ClientFactoryManager manager = session.getFactoryManager();
- appendInfoValue(stdout, IoServiceFactory.class.getSimpleName(), manager.getIoServiceFactory().getClass().getSimpleName()).println();
- appendInfoValue(stdout, CipherFactory.class.getSimpleName(), NamedResource.getNames(manager.getCipherFactories())).println();
- appendInfoValue(stdout, KeyExchange.class.getSimpleName(), NamedResource.getNames(manager.getKeyExchangeFactories())).println();
- appendInfoValue(stdout, SignatureFactory.class.getSimpleName(), NamedResource.getNames(manager.getSignatureFactories())).println();
- appendInfoValue(stdout, MacFactory.class.getSimpleName(), NamedResource.getNames(manager.getMacFactories())).println();
- appendInfoValue(stdout, CompressionFactory.class.getSimpleName(), NamedResource.getNames(manager.getCompressionFactories())).println();
- appendInfoValue(stdout, ChannelFactory.class.getSimpleName(), NamedResource.getNames(manager.getChannelFactories())).println();
- appendInfoValue(stdout, ServiceFactory.class.getSimpleName(), NamedResource.getNames(manager.getServiceFactories())).println();
+ appendInfoValue(stdout, IoServiceFactory.class.getSimpleName(),
+ manager.getIoServiceFactory().getClass().getSimpleName()).println();
+ appendInfoValue(stdout, CipherFactory.class.getSimpleName(), NamedResource.getNames(manager.getCipherFactories()))
+ .println();
+ appendInfoValue(stdout, KeyExchange.class.getSimpleName(),
+ NamedResource.getNames(manager.getKeyExchangeFactories())).println();
+ appendInfoValue(stdout, SignatureFactory.class.getSimpleName(),
+ NamedResource.getNames(manager.getSignatureFactories())).println();
+ appendInfoValue(stdout, MacFactory.class.getSimpleName(), NamedResource.getNames(manager.getMacFactories()))
+ .println();
+ appendInfoValue(stdout, CompressionFactory.class.getSimpleName(),
+ NamedResource.getNames(manager.getCompressionFactories())).println();
+ appendInfoValue(stdout, ChannelFactory.class.getSimpleName(), NamedResource.getNames(manager.getChannelFactories()))
+ .println();
+ appendInfoValue(stdout, ServiceFactory.class.getSimpleName(), NamedResource.getNames(manager.getServiceFactories()))
+ .println();
return false;
}
}
@@ -500,7 +507,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
ValidateUtils.checkTrue(GenericUtils.isEmpty(args), "Unexpected arguments: %s", args);
SftpClient sftp = getClient();
Session session = sftp.getSession();
@@ -540,7 +547,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
ValidateUtils.checkTrue(GenericUtils.isEmpty(args), "Unexpected arguments: %s", args);
SftpClient sftp = getClient();
stdout.append(" ").println(sftp.getVersion());
@@ -561,7 +568,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
ValidateUtils.checkNotNullAndNotEmpty(args, "No remote directory specified");
String newPath = resolveRemotePath(args);
@@ -584,7 +591,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
if (GenericUtils.isEmpty(args)) {
setCurrentLocalDirectory(System.getProperty("user.home"));
} else {
@@ -611,7 +618,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
ValidateUtils.checkNotNullAndNotEmpty(args, "No remote directory specified");
String path = resolveRemotePath(args);
@@ -634,7 +641,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
String[] comps = GenericUtils.split(args, ' ');
int numComps = GenericUtils.length(comps);
String pathArg = (numComps <= 0) ? null : GenericUtils.trimToEmpty(comps[numComps - 1]);
@@ -648,7 +655,8 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
String path = resolveRemotePath(pathArg);
SftpClient sftp = getClient();
int version = sftp.getVersion();
- boolean showLongName = (version == SftpConstants.SFTP_V3) && (GenericUtils.length(flags) > 1) && (flags.indexOf('l') > 0);
+ boolean showLongName
+ = (version == SftpConstants.SFTP_V3) && (GenericUtils.length(flags) > 1) && (flags.indexOf('l') > 0);
for (SftpClient.DirEntry entry : sftp.readDir(path)) {
String fileName = entry.getFilename();
SftpClient.Attributes attrs = entry.getAttributes();
@@ -675,7 +683,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
String[] comps = GenericUtils.split(args, ' ');
int numArgs = GenericUtils.length(comps);
ValidateUtils.checkTrue(numArgs >= 1, "No arguments");
@@ -690,8 +698,8 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
for (int index = 1; index < remotePath.length(); index++) {
char ch = remotePath.charAt(index);
- switch(ch) {
- case 'r' :
+ switch (ch) {
+ case 'r':
recursive = true;
break;
case 'v':
@@ -722,7 +730,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
private void removeRecursive(
SftpClient sftp, String path, Attributes attrs, PrintStream stdout, boolean verbose)
- throws IOException {
+ throws IOException {
if (attrs.isDirectory()) {
for (DirEntry entry : sftp.readDir(path)) {
String name = entry.getFilename();
@@ -762,7 +770,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
ValidateUtils.checkNotNullAndNotEmpty(args, "No remote directory specified");
String path = resolveRemotePath(args);
@@ -785,7 +793,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
String[] comps = GenericUtils.split(args, ' ');
ValidateUtils.checkTrue(GenericUtils.length(comps) == 2, "Invalid number of arguments: %s", args);
@@ -810,7 +818,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
String[] comps = GenericUtils.split(args, ' ');
int numArgs = GenericUtils.length(comps);
ValidateUtils.checkTrue(numArgs <= 1, "Invalid number of arguments: %s", args);
@@ -820,7 +828,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
ValidateUtils.checkTrue(ext.isSupported(), "Extension not supported by server: %s", ext.getName());
String remPath = resolveRemotePath(
- (numArgs >= 1) ? GenericUtils.trimToEmpty(comps[0]) : GenericUtils.trimToEmpty(args));
+ (numArgs >= 1) ? GenericUtils.trimToEmpty(comps[0]) : GenericUtils.trimToEmpty(args));
OpenSSHStatExtensionInfo info = ext.stat(remPath);
Field[] fields = info.getClass().getFields();
for (Field f : fields) {
@@ -851,7 +859,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
String[] comps = GenericUtils.split(args, ' ');
ValidateUtils.checkTrue(GenericUtils.length(comps) <= 1, "Invalid number of arguments: %s", args);
@@ -874,7 +882,8 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
}
@Override
- public boolean executeCommand(String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr) throws Exception {
+ public boolean executeCommand(String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
+ throws Exception {
String[] comps = GenericUtils.split(args, ' ');
ValidateUtils.checkTrue(GenericUtils.length(comps) <= 1, "Invalid number of arguments: %s", args);
@@ -900,7 +909,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@SuppressWarnings("synthetic-access")
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
ValidateUtils.checkTrue(GenericUtils.isEmpty(args), "Unexpected arguments: %s", args);
for (String cmd : commandsMap.keySet()) {
stdout.append(" ").println(cmd);
@@ -916,14 +925,16 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
protected void createDirectories(
SftpClient sftp, String remotePath, PrintStream stdout, boolean verbose)
- throws IOException {
+ throws IOException {
try {
Attributes attrs = sftp.stat(remotePath);
- ValidateUtils.checkTrue(attrs.isDirectory(), "Remote path already exists but is not a directory: %s", remotePath);
+ ValidateUtils.checkTrue(attrs.isDirectory(), "Remote path already exists but is not a directory: %s",
+ remotePath);
return;
} catch (SftpException e) {
int status = e.getStatus();
- ValidateUtils.checkTrue(status == SftpConstants.SSH_FX_NO_SUCH_FILE, "Failed to get status of %s: %s", remotePath, e.getMessage());
+ ValidateUtils.checkTrue(status == SftpConstants.SSH_FX_NO_SUCH_FILE, "Failed to get status of %s: %s",
+ remotePath, e.getMessage());
}
int pos = remotePath.lastIndexOf('/');
@@ -933,7 +944,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
protected void transferFile(
SftpClient sftp, Path localPath, String remotePath, boolean upload, PrintStream stdout, boolean verbose)
- throws IOException {
+ throws IOException {
// Create the file's hierarchy
if (upload) {
int pos = remotePath.lastIndexOf('/');
@@ -942,8 +953,8 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
if (verbose) {
stdout.append(" Uploading ").append(Long.toString(Files.size(localPath)))
- .append(" bytes from ").append(localPath.toString())
- .append(" to ").println(remotePath);
+ .append(" bytes from ").append(localPath.toString())
+ .append(" to ").println(remotePath);
}
} else {
Files.createDirectories(localPath.getParent());
@@ -951,8 +962,8 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
if (verbose) {
Attributes attrs = sftp.stat(remotePath);
stdout.append(" Downloading ").append(Long.toString(attrs.getSize()))
- .append(" bytes from ").append(remotePath)
- .append(" to ").println(localPath);
+ .append(" bytes from ").append(remotePath)
+ .append(" to ").println(localPath);
}
}
@@ -975,15 +986,16 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
if (verbose) {
stdout.append(" Copied ").append(Long.toString(copySize)).append(" bytes")
- .append(" in ").append(Long.toString(TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - startTime)))
- .append(" seconds from ").append(upload ? localPath.toString() : remotePath)
- .append(" to ").println(upload ? remotePath : localPath.toString());
+ .append(" in ")
+ .append(Long.toString(TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - startTime)))
+ .append(" seconds from ").append(upload ? localPath.toString() : remotePath)
+ .append(" to ").println(upload ? remotePath : localPath.toString());
}
}
protected void transferRemoteDir(
SftpClient sftp, Path localPath, String remotePath, Attributes attrs, PrintStream stdout, boolean verbose)
- throws IOException {
+ throws IOException {
if (attrs.isDirectory()) {
for (DirEntry entry : sftp.readDir(remotePath)) {
String name = entry.getFilename();
@@ -991,7 +1003,8 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
continue;
}
- transferRemoteDir(sftp, localPath.resolve(name), remotePath + "/" + name, entry.getAttributes(), stdout, verbose);
+ transferRemoteDir(sftp, localPath.resolve(name), remotePath + "/" + name, entry.getAttributes(), stdout,
+ verbose);
}
} else if (attrs.isRegularFile()) {
transferFile(sftp, localPath, remotePath, false, stdout, verbose);
@@ -1004,7 +1017,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
protected void transferLocalDir(
SftpClient sftp, Path localPath, String remotePath, PrintStream stdout, boolean verbose)
- throws IOException {
+ throws IOException {
if (Files.isDirectory(localPath)) {
try (DirectoryStream<Path> ds = Files.newDirectoryStream(localPath)) {
for (Path entry : ds) {
@@ -1037,8 +1050,8 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
for (int index = 1; index < src.length(); index++) {
char ch = src.charAt(index);
- switch(ch) {
- case 'r' :
+ switch (ch) {
+ case 'r':
recursive = true;
break;
case 'v':
@@ -1068,7 +1081,8 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
String remote = resolveRemotePath(remotePath);
if (recursive) {
if (upload) {
- ValidateUtils.checkTrue(Files.isDirectory(local), "Local path not a directory or does not exist: %s", local);
+ ValidateUtils.checkTrue(Files.isDirectory(local), "Local path not a directory or does not exist: %s",
+ local);
transferLocalDir(sftp, local, remote, stdout, verbose);
} else {
Attributes attrs = sftp.stat(remote);
@@ -1100,7 +1114,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
executeCommand(args, false, stdout);
return false;
}
@@ -1119,7 +1133,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
executeCommand(args, true, stdout);
return false;
}
@@ -1138,7 +1152,7 @@ public class SftpCommandMain extends SshClientCliSupport implements Channel {
@Override
public boolean executeCommand(
String args, BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
String[] comps = GenericUtils.split(args, ' ');
int numArgs = GenericUtils.length(comps);
if (numArgs <= 0) {
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java
index 3b7c0e4..fe4b92b 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java
@@ -104,21 +104,21 @@ public abstract class SshClientCliSupport extends CliSupport {
public static boolean isArgumentedOption(String portOption, String argName) {
return portOption.equals(argName)
- || "-io".equals(argName)
- || "-i".equals(argName)
- || "-o".equals(argName)
- || "-l".equals(argName)
- || "-w".equals(argName)
- || "-c".equals(argName)
- || "-m".equals(argName)
- || "-E".equals(argName);
+ || "-io".equals(argName)
+ || "-i".equals(argName)
+ || "-o".equals(argName)
+ || "-l".equals(argName)
+ || "-w".equals(argName)
+ || "-c".equals(argName)
+ || "-m".equals(argName)
+ || "-E".equals(argName);
}
// NOTE: ClientSession#getFactoryManager is the SshClient
public static ClientSession setupClientSession(
String portOption, BufferedReader stdin, Level level,
PrintStream stdout, PrintStream stderr, String... args)
- throws Exception {
+ throws Exception {
int port = -1;
String host = null;
String login = null;
@@ -177,12 +177,12 @@ public abstract class SshClientCliSupport extends CliSupport {
identities.add(idFile);
} else if ("-C".equals(argName)) {
compressions = setupCompressions(argName,
- GenericUtils.join(
- Arrays.asList(
- BuiltinCompressions.Constants.ZLIB,
- BuiltinCompressions.Constants.DELAYED_ZLIB),
- ','),
- compressions, stderr);
+ GenericUtils.join(
+ Arrays.asList(
+ BuiltinCompressions.Constants.ZLIB,
+ BuiltinCompressions.Constants.DELAYED_ZLIB),
+ ','),
+ compressions, stderr);
if (GenericUtils.isEmpty(compressions)) {
error = true;
break;
@@ -221,7 +221,7 @@ public abstract class SshClientCliSupport extends CliSupport {
}
host = argName;
- int pos = host.indexOf('@'); // check if user@host
+ int pos = host.indexOf('@'); // check if user@host
if (pos > 0) {
if (login == null) {
login = host.substring(0, pos);
@@ -242,11 +242,10 @@ public abstract class SshClientCliSupport extends CliSupport {
return null;
}
- PropertyResolver resolver =
- PropertyResolverUtils.toPropertyResolver(options);
+ PropertyResolver resolver = PropertyResolverUtils.toPropertyResolver(options);
SshClient client = setupClient(
- resolver, ciphers, macs, compressions, identities,
- stdin, stdout, stderr, level, args);
+ resolver, ciphers, macs, compressions, identities,
+ stdin, stdout, stderr, level, args);
if (client == null) {
return null;
}
@@ -264,13 +263,13 @@ public abstract class SshClientCliSupport extends CliSupport {
// TODO use a configurable wait time
ClientSession session = client.connect(login, host, port)
- .verify()
- .getSession();
+ .verify()
+ .getSession();
try {
if (GenericUtils.length(password) > 0) {
session.addPasswordIdentity(password);
}
- session.auth().verify(FactoryManager.DEFAULT_AUTH_TIMEOUT); // TODO use a configurable wait time
+ session.auth().verify(FactoryManager.DEFAULT_AUTH_TIMEOUT); // TODO use a configurable wait time
return session;
} catch (Exception e) {
session.close(true);
@@ -295,7 +294,7 @@ public abstract class SshClientCliSupport extends CliSupport {
public static Map<String, ?> resolveClientEnvironment(PropertyResolver resolver) {
return resolveClientEnvironment(
- (resolver == null) ? Collections.emptyMap() : resolver.getProperties());
+ (resolver == null) ? Collections.emptyMap() : resolver.getProperties());
}
public static Map<String, ?> resolveClientEnvironment(Map<String, ?> options) {
@@ -304,7 +303,7 @@ public abstract class SshClientCliSupport extends CliSupport {
}
Map<String, Object> env = Collections.emptyMap();
- for (String propName : new String[] {SshClientConfigFileReader.SETENV_PROP, SshClientConfigFileReader.SENDENV_PROP}) {
+ for (String propName : new String[] { SshClientConfigFileReader.SETENV_PROP, SshClientConfigFileReader.SENDENV_PROP }) {
Object v = options.get(propName);
String s = Objects.toString(v, null);
if (GenericUtils.isEmpty(s)) {
@@ -322,7 +321,7 @@ public abstract class SshClientCliSupport extends CliSupport {
Object prev = env.put(key, value);
if (prev != null) {
- continue; // debug breakpoint
+ continue; // debug breakpoint
}
}
}
@@ -333,14 +332,14 @@ public abstract class SshClientCliSupport extends CliSupport {
public static PtyChannelConfiguration resolveClientPtyOptions(PropertyResolver resolver)
throws IOException, InterruptedException {
return resolveClientPtyOptions(
- (resolver == null) ? Collections.emptyMap() : resolver.getProperties());
+ (resolver == null) ? Collections.emptyMap() : resolver.getProperties());
}
public static PtyChannelConfiguration resolveClientPtyOptions(Map<String, ?> options)
throws IOException, InterruptedException {
Object v = GenericUtils.isEmpty(options)
- ? null
- : options.get(SshClientConfigFileReader.REQUEST_TTY_OPTION);
+ ? null
+ : options.get(SshClientConfigFileReader.REQUEST_TTY_OPTION);
String s = Objects.toString(v, "auto");
boolean autoDetect = "auto".equalsIgnoreCase(s);
Boolean ptyEnabled = autoDetect ? Boolean.TRUE : PropertyResolverUtils.parseBoolean(s);
@@ -376,12 +375,12 @@ public abstract class SshClientCliSupport extends CliSupport {
int pos = kve.indexOf('=');
String key = (pos >= 0) ? kve.substring(0, pos) : kve;
PtyMode mode = ValidateUtils.checkNotNull(
- PtyMode.fromName(key), "Unknown PTY mode: %s", key);
+ PtyMode.fromName(key), "Unknown PTY mode: %s", key);
s = (pos >= 0) ? kve.substring(pos + 1) : "";
Integer value = GenericUtils.isEmpty(s) ? Integer.valueOf(1) : Integer.valueOf(s);
Integer prev = ptyModes.put(mode, value);
if (prev != null) {
- continue; // debug breakpoint
+ continue; // debug breakpoint
}
}
@@ -392,7 +391,7 @@ public abstract class SshClientCliSupport extends CliSupport {
PropertyResolver resolver, Level level,
PrintStream stdout, PrintStream stderr, String... args) {
SshClient client = setupIoServiceFactory(
- SshClient.setUpDefaultClient(), resolver, level, stdout, stderr, args);
+ SshClient.setUpDefaultClient(), resolver, level, stdout, stderr, args);
SshClientConfigFileReader.setupClientHeartbeat(client, resolver);
return client;
}
@@ -407,7 +406,7 @@ public abstract class SshClientCliSupport extends CliSupport {
Collection<? extends Path> identities,
BufferedReader stdin, PrintStream stdout, PrintStream stderr,
Level level, String[] args)
- throws Exception {
+ throws Exception {
if (GenericUtils.isEmpty(ciphers)) {
ciphers = setupCiphers(resolver, stderr);
if (ciphers == null) {
@@ -474,7 +473,7 @@ public abstract class SshClientCliSupport extends CliSupport {
public static FileKeyPairProvider setupSessionIdentities(
ClientFactoryManager client, Collection<? extends Path> identities,
BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Throwable {
+ throws Throwable {
client.setFilePasswordProvider((session, file, index) -> {
stdout.print("Enter password for private key file=" + file + ": ");
return stdin.readLine();
@@ -528,7 +527,7 @@ public abstract class SshClientCliSupport extends CliSupport {
}
} catch (IOException e) {
stderr.append("WARNING: ").append(e.getClass().getSimpleName())
- .append(" while read prompts: ").println(e.getMessage());
+ .append(" while read prompts: ").println(e.getMessage());
}
return answers;
}
@@ -540,7 +539,7 @@ public abstract class SshClientCliSupport extends CliSupport {
return stdin.readLine();
} catch (IOException e) {
stderr.append("WARNING: ").append(e.getClass().getSimpleName())
- .append(" while read password: ").println(e.getMessage());
+ .append(" while read password: ").println(e.getMessage());
return null;
}
}
@@ -552,10 +551,10 @@ public abstract class SshClientCliSupport extends CliSupport {
public static void setupSessionExtensions(
KexFactoryManager manager, PropertyResolver resolver,
BufferedReader stdin, PrintStream stdout, PrintStream stderr)
- throws Exception {
+ throws Exception {
Map<String, ?> options = resolver.getProperties();
String kexExtension = Objects.toString(
- options.remove(KexExtensionHandler.class.getSimpleName()), null);
+ options.remove(KexExtensionHandler.class.getSimpleName()), null);
if (GenericUtils.isEmpty(kexExtension)) {
return;
}
@@ -567,13 +566,12 @@ public abstract class SshClientCliSupport extends CliSupport {
ClassLoader cl = ThreadUtils.resolveDefaultClassLoader(KexExtensionHandler.class);
try {
Class<?> clazz = cl.loadClass(kexExtension);
- KexExtensionHandler handler =
- KexExtensionHandler.class.cast(clazz.newInstance());
+ KexExtensionHandler handler = KexExtensionHandler.class.cast(clazz.newInstance());
manager.setKexExtensionHandler(handler);
} catch (Exception e) {
stderr.append("ERROR: Failed (").append(e.getClass().getSimpleName()).append(')')
- .append(" to instantiate KEX extension handler=").append(kexExtension)
- .append(": ").println(e.getMessage());
+ .append(" to instantiate KEX extension handler=").append(kexExtension)
+ .append(": ").println(e.getMessage());
stderr.flush();
throw e;
}
@@ -592,38 +590,37 @@ public abstract class SshClientCliSupport extends CliSupport {
}
Map<String, ?> options = resolver.getProperties();
- String strictValue =
- Objects.toString(
+ String strictValue = Objects.toString(
options.remove(KnownHostsServerKeyVerifier.STRICT_CHECKING_OPTION), "true");
if (!ConfigFileReaderSupport.parseBooleanValue(strictValue)) {
return current;
}
String filePath = Objects.toString(
- options.remove(KnownHostsServerKeyVerifier.KNOWN_HOSTS_FILE_OPTION), null);
+ options.remove(KnownHostsServerKeyVerifier.KNOWN_HOSTS_FILE_OPTION), null);
if (GenericUtils.isEmpty(filePath)) {
current = new DefaultKnownHostsServerKeyVerifier(current);
- } else { // if user specifies a different location than default be lenient
+ } else { // if user specifies a different location than default be lenient
current = new DefaultKnownHostsServerKeyVerifier(current, false, Paths.get(filePath));
}
((KnownHostsServerKeyVerifier) current).setModifiedServerKeyAcceptor(
- (clientSession, remoteAddress, entry, expected, actual) -> {
- stderr.append("WARNING: Mismatched keys presented by ").append(Objects.toString(remoteAddress))
- .append(" for entry=").println(entry);
- stderr.append(" ").append("Expected=").append(KeyUtils.getKeyType(expected))
- .append('-').println(KeyUtils.getFingerPrint(expected));
- stderr.append(" ").append("Actual=").append(KeyUtils.getKeyType(actual))
- .append('-').println(KeyUtils.getFingerPrint(actual));
- stderr.flush(); // just making sure
-
- stdout.append("Accept key and update known hosts: y/[N]");
- stdout.flush(); // just making sure
-
- String ans = GenericUtils.trimToEmpty(stdin.readLine());
- return (GenericUtils.length(ans) > 0)
- && (Character.toLowerCase(ans.charAt(0)) == 'y');
- });
+ (clientSession, remoteAddress, entry, expected, actual) -> {
+ stderr.append("WARNING: Mismatched keys presented by ").append(Objects.toString(remoteAddress))
+ .append(" for entry=").println(entry);
+ stderr.append(" ").append("Expected=").append(KeyUtils.getKeyType(expected))
+ .append('-').println(KeyUtils.getFingerPrint(expected));
+ stderr.append(" ").append("Actual=").append(KeyUtils.getKeyType(actual))
+ .append('-').println(KeyUtils.getFingerPrint(actual));
+ stderr.flush(); // just making sure
+
+ stdout.append("Accept key and update known hosts: y/[N]");
+ stdout.flush(); // just making sure
+
+ String ans = GenericUtils.trimToEmpty(stdin.readLine());
+ return (GenericUtils.length(ans) > 0)
+ && (Character.toLowerCase(ans.charAt(0)) == 'y');
+ });
manager.setServerKeyVerifier(current);
return current;
@@ -653,7 +650,8 @@ public abstract class SshClientCliSupport extends CliSupport {
Path path = Paths.get(argVal).normalize().toAbsolutePath();
return Files.newOutputStream(path);
} catch (IOException e) {
- showError(stderr, "Failed (" + e.getClass().getSimpleName() + ") to open " + argVal + ": " + e.getMessage());
+ showError(stderr,
+ "Failed (" + e.getClass().getSimpleName() + ") to open " + argVal + ": " + e.getMessage());
return null;
}
}
@@ -664,7 +662,7 @@ public abstract class SshClientCliSupport extends CliSupport {
public static List<NamedFactory<Compression>> setupCompressions(PropertyResolver options, PrintStream stderr) {
String argVal = PropertyResolverUtils.getString(
- options, ConfigFileReaderSupport.COMPRESSION_PROP);
+ options, ConfigFileReaderSupport.COMPRESSION_PROP);
if (GenericUtils.isEmpty(argVal)) {
return Collections.emptyList();
}
@@ -685,8 +683,7 @@ public abstract class SshClientCliSupport extends CliSupport {
return null;
}
- BuiltinCompressions.ParseResult result =
- BuiltinCompressions.parseCompressionsList(argVal);
+ BuiltinCompressions.ParseResult result = BuiltinCompressions.parseCompressionsList(argVal);
Collection<? extends NamedFactory<Compression>> available = result.getParsedFactories();
if (GenericUtils.isEmpty(available)) {
showError(stderr, "No known compressions in " + argVal);
@@ -696,7 +693,7 @@ public abstract class SshClientCliSupport extends CliSupport {
Collection<String> unsupported = result.getUnsupportedFactories();
if (GenericUtils.size(unsupported) > 0) {
stderr.append("WARNING: Ignored unsupported compressions: ")
- .println(GenericUtils.join(unsupported, ','));
+ .println(GenericUtils.join(unsupported, ','));
}
return new ArrayList<>(available);
@@ -706,8 +703,8 @@ public abstract class SshClientCliSupport extends CliSupport {
String argVal = PropertyResolverUtils.getString(
options, ConfigFileReaderSupport.MACS_CONFIG_PROP);
return GenericUtils.isEmpty(argVal)
- ? Collections.emptyList()
- : setupMacs(ConfigFileReaderSupport.MACS_CONFIG_PROP, argVal, null, stderr);
+ ? Collections.emptyList()
+ : setupMacs(ConfigFileReaderSupport.MACS_CONFIG_PROP, argVal, null, stderr);
}
public static List<NamedFactory<Mac>> setupMacs(
@@ -727,7 +724,7 @@ public abstract class SshClientCliSupport extends CliSupport {
Collection<String> unsupported = result.getUnsupportedFactories();
if (GenericUtils.size(unsupported) > 0) {
stderr.append("WARNING: Ignored unsupported MACs: ")
- .println(GenericUtils.join(unsupported, ','));
+ .println(GenericUtils.join(unsupported, ','));
}
return new ArrayList<>(available);
@@ -737,8 +734,8 @@ public abstract class SshClientCliSupport extends CliSupport {
String argVal = PropertyResolverUtils.getString(
options, ConfigFileReaderSupport.CIPHERS_CONFIG_PROP);
return GenericUtils.isEmpty(argVal)
- ? Collections.emptyList()
- : setupCiphers(ConfigFileReaderSupport.CIPHERS_CONFIG_PROP, argVal, null, stderr);
+ ? Collections.emptyList()
+ : setupCiphers(ConfigFileReaderSupport.CIPHERS_CONFIG_PROP, argVal, null, stderr);
}
// returns null - e.g., re-specified or no supported cipher found
@@ -759,7 +756,7 @@ public abstract class SshClientCliSupport extends CliSupport {
Collection<String> unsupported = result.getUnsupportedFactories();
if (GenericUtils.size(unsupported) > 0) {
stderr.append("WARNING: Ignored unsupported ciphers: ")
- .println(GenericUtils.join(unsupported, ','));
+ .println(GenericUtils.join(unsupported, ','));
}
return new ArrayList<>(available);
@@ -792,7 +789,7 @@ public abstract class SshClientCliSupport extends CliSupport {
StringWriter sw = new StringWriter();
try (PrintWriter pw = new PrintWriter(sw)) {
pw.println();
- t.printStackTrace(pw); // NOPMD
+ t.printStackTrace(pw); // NOPMD
}
throwable = sw.toString();
}
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientMain.java b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientMain.java
index e62b071..75d28e2 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientMain.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientMain.java
@@ -48,7 +48,7 @@ import org.apache.sshd.common.util.net.SshdSocketAddress;
*/
public class SshClientMain extends SshClientCliSupport {
protected SshClientMain() {
- super(); // in case someone wants to extend it
+ super(); // in case someone wants to extend it
}
//////////////////////////////////////////////////////////////////////////
@@ -122,12 +122,12 @@ public class SshClientMain extends SshClientCliSupport {
ClientSession session = null;
try (BufferedReader stdin = new BufferedReader(
new InputStreamReader(
- new NoCloseInputStream(System.in), Charset.defaultCharset()))) {
+ new NoCloseInputStream(System.in), Charset.defaultCharset()))) {
if (!error) {
setupLogging(level, stdout, stderr, logStream);
session = setupClientSession(
- SSH_CLIENT_PORT_OPTION, stdin, level, stdout, stderr, args);
+ SSH_CLIENT_PORT_OPTION, stdin, level, stdout, stderr, args);
if (session == null) {
error = true;
}
@@ -135,33 +135,25 @@ public class SshClientMain extends SshClientCliSupport {
if (error) {
System.err.println("usage: ssh [-A|-a] [-v[v][v]] [-E logoutputfile] [-D socksPort]"
- + " [-l login] [" + SSH_CLIENT_PORT_OPTION + " port] [-o option=value]"
- + " [-w password] [-c cipherslist] [-m maclist] [-C]"
- + " hostname/user@host [command]");
+ + " [-l login] [" + SSH_CLIENT_PORT_OPTION + " port] [-o option=value]"
+ + " [-w password] [-c cipherslist] [-m maclist] [-C]"
+ + " hostname/user@host [command]");
System.exit(-1);
return;
}
try (SshClient client = (SshClient) session.getFactoryManager()) {
/*
- String authSock = System.getenv(SshAgent.SSH_AUTHSOCKET_ENV_NAME);
- if (authSock == null && provider != null) {
- Iterable<KeyPair> keys = provider.loadKeys();
- AgentServer server = new AgentServer();
- authSock = server.start();
- SshAgent agent = new AgentClient(authSock);
- for (KeyPair key : keys) {
- agent.addIdentity(key, "");
- }
- agent.close();
- props.put(SshAgent.SSH_AUTHSOCKET_ENV_NAME, authSock);
- }
- */
+ * String authSock = System.getenv(SshAgent.SSH_AUTHSOCKET_ENV_NAME); if (authSock == null && provider
+ * != null) { Iterable<KeyPair> keys = provider.loadKeys(); AgentServer server = new AgentServer();
+ * authSock = server.start(); SshAgent agent = new AgentClient(authSock); for (KeyPair key : keys) {
+ * agent.addIdentity(key, ""); } agent.close(); props.put(SshAgent.SSH_AUTHSOCKET_ENV_NAME, authSock); }
+ */
try {
if (socksPort >= 0) {
session.startDynamicPortForwarding(
- new SshdSocketAddress(SshdSocketAddress.LOCALHOST_NAME, socksPort));
+ new SshdSocketAddress(SshdSocketAddress.LOCALHOST_NAME, socksPort));
Thread.sleep(Long.MAX_VALUE);
} else {
Map<String, ?> env = resolveClientEnvironment(client);
@@ -173,7 +165,7 @@ public class SshClientMain extends SshClientCliSupport {
channel.setIn(new NoCloseInputStream(System.in));
} else {
channel = session.createExecChannel(
- String.join(" ", command).trim(), ptyConfig, env);
+ String.join(" ", command).trim(), ptyConfig, env);
}
try (OutputStream channelOut = new NoCloseOutputStream(System.out);
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java
index 3115ef7..4e9513d 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java
@@ -87,7 +87,8 @@ import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.common.util.security.SecurityUtils;
/**
- * A naive implementation of <A HREF="https://www.freebsd.org/cgi/man.cgi?query=ssh-keyscan&sektion=1">ssh-keyscan(1)</A>
+ * A naive implementation of
+ * <A HREF="https://www.freebsd.org/cgi/man.cgi?query=ssh-keyscan&sektion=1">ssh-keyscan(1)</A>
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
@@ -95,11 +96,10 @@ public class SshKeyScanMain implements Channel, Callable<Void>, ServerKeyVerifie
/**
* Default key types if not overridden from the command line
*/
- public static final List<String> DEFAULT_KEY_TYPES =
- Collections.unmodifiableList(
+ public static final List<String> DEFAULT_KEY_TYPES = Collections.unmodifiableList(
Arrays.asList(
- BuiltinIdentities.Constants.RSA,
- BuiltinIdentities.Constants.ECDSA));
+ BuiltinIdentities.Constants.RSA,
+ BuiltinIdentities.Constants.ECDSA));
public static final long DEFAULT_TIMEOUT = TimeUnit.SECONDS.toMillis(5L);
public static final Level DEFAULT_LEVEL = Level.INFO;
@@ -183,10 +183,8 @@ public class SshKeyScanMain implements Channel, Callable<Void>, ServerKeyVerifie
Collection<String> typeNames = getKeyTypes();
Map<String, List<KeyPair>> pairsMap = createKeyPairs(typeNames);
/*
- * We will need to switch signature factories for each specific
- * key type in order to force the server to send ONLY that specific
- * key, so pre-create the factories map according to the selected
- * key types
+ * We will need to switch signature factories for each specific key type in order to force the server to send
+ * ONLY that specific key, so pre-create the factories map according to the selected key types
*/
SortedMap<String, List<NamedFactory<Signature>>> sigFactories = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
Collection<String> sigTypes = GenericUtils.asSortedSet(sigFactories.comparator(), pairsMap.keySet());
@@ -297,9 +295,10 @@ public class SshKeyScanMain implements Channel, Callable<Void>, ServerKeyVerifie
return null;
}
- protected void resolveServerKeys(SshClient client, String host,
+ protected void resolveServerKeys(
+ SshClient client, String host,
Map<String, List<KeyPair>> pairsMap, Map<String, List<NamedFactory<Signature>>> sigFactories)
- throws IOException {
+ throws IOException {
// Cannot use forEach because of the potential for throwing IOException by the invoked code
for (Map.Entry<String, List<KeyPair>> pe : pairsMap.entrySet()) {
String kt = pe.getKey();
@@ -310,9 +309,8 @@ public class SshKeyScanMain implements Channel, Callable<Void>, ServerKeyVerifie
List<NamedFactory<Signature>> current = client.getSignatureFactories();
try {
/*
- * Replace whatever factories there are right now with the
- * specific one for the key in order to extract only the
- * specific host key type
+ * Replace whatever factories there are right now with the specific one for the key in order to extract
+ * only the specific host key type
*/
List<NamedFactory<Signature>> forced = sigFactories.get(kt);
client.setSignatureFactories(forced);
@@ -326,7 +324,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, ServerKeyVerifie
return; // makes no sense to try again with another key type...
}
} finally {
- client.setSignatureFactories(current); // don't have to, but be nice...
+ client.setSignatureFactories(current); // don't have to, but be nice...
}
}
}
@@ -340,9 +338,10 @@ public class SshKeyScanMain implements Channel, Callable<Void>, ServerKeyVerifie
ConnectFuture future = client.connect(UUID.randomUUID().toString(), host, connectPort);
long waitTime = getTimeout();
if (!future.await(waitTime)) {
- throw new ConnectException("Failed to connect to " + host + ":" + connectPort
- + " within " + waitTime + " msec."
- + " to retrieve key type=" + kt);
+ throw new ConnectException(
+ "Failed to connect to " + host + ":" + connectPort
+ + " within " + waitTime + " msec."
+ + " to retrieve key type=" + kt);
}
try (ClientSession session = future.getSession()) {
@@ -424,7 +423,8 @@ public class SshKeyScanMain implements Channel, Callable<Void>, ServerKeyVerifie
}
@Override
- public void sessionNegotiationEnd(Session session, Map<KexProposalOption, String> clientProposal,
+ public void sessionNegotiationEnd(
+ Session session, Map<KexProposalOption, String> clientProposal,
Map<KexProposalOption, String> serverProposal, Map<KexProposalOption, String> negotiatedOptions,
Throwable reason) {
if (reason == null) {
@@ -505,8 +505,8 @@ public class SshKeyScanMain implements Channel, Callable<Void>, ServerKeyVerifie
log(Level.FINER, "Resolve signature factory for curve=" + n);
}
- NamedFactory<Signature> f =
- ValidateUtils.checkNotNull(BuiltinSignatures.fromString(n), "Unknown curve signature: %s", n);
+ NamedFactory<Signature> f
+ = ValidateUtils.checkNotNull(BuiltinSignatures.fromString(n), "Unknown curve signature: %s", n);
factories.add(f);
}
@@ -526,7 +526,8 @@ public class SshKeyScanMain implements Channel, Callable<Void>, ServerKeyVerifie
Map<String, List<KeyPair>> pairsMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
for (String kt : typeNames) {
if ("*".equalsIgnoreCase(kt) || "all".equalsIgnoreCase(kt)) {
- ValidateUtils.checkTrue(typeNames.size() == 1, "Wildcard key type must be the only one specified: %s", typeNames);
+ ValidateUtils.checkTrue(typeNames.size() == 1, "Wildcard key type must be the only one specified: %s",
+ typeNames);
return createKeyPairs(BuiltinIdentities.NAMES);
}
@@ -679,14 +680,14 @@ public class SshKeyScanMain implements Channel, Callable<Void>, ServerKeyVerifie
}
String provider = args[++index];
- BuiltinIoServiceFactoryFactories factory =
- CliSupport.resolveBuiltinIoServiceFactory(System.err, optName, provider);
+ BuiltinIoServiceFactoryFactories factory
+ = CliSupport.resolveBuiltinIoServiceFactory(System.err, optName, provider);
if (factory != null) {
System.setProperty(IoServiceFactory.class.getName(), factory.getFactoryClassName());
} else {
break;
}
- } else { // stop at first non-option - assume the rest are host names/addresses
+ } else { // stop at first non-option - assume the rest are host names/addresses
ValidateUtils.checkTrue(optName.charAt(0) != '-', "Unknown option: %s", optName);
int remaining = numArgs - index;
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/client/helper/SftpFileTransferProgressOutputStream.java b/sshd-cli/src/main/java/org/apache/sshd/cli/client/helper/SftpFileTransferProgressOutputStream.java
index 26330bc..127ff31 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/client/helper/SftpFileTransferProgressOutputStream.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/client/helper/SftpFileTransferProgressOutputStream.java
@@ -40,7 +40,7 @@ public class SftpFileTransferProgressOutputStream extends FilterOutputStream {
private final char markerChar;
private final int markersPerLine;
private final Appendable stdout;
- private final byte[] workBuf = {0};
+ private final byte[] workBuf = { 0 };
private long byteCount;
private long lastMarkOffset;
private int curMarkersInLine;
@@ -50,7 +50,8 @@ public class SftpFileTransferProgressOutputStream extends FilterOutputStream {
}
public SftpFileTransferProgressOutputStream(
- OutputStream out, int markerSize, char markerChar, int markersPerLine, Appendable stdout) {
+ OutputStream out, int markerSize, char markerChar, int markersPerLine,
+ Appendable stdout) {
super(Objects.requireNonNull(out, "No target stream"));
ValidateUtils.checkTrue(markerSize > 0, "Invalid marker size: %d", markerSize);
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerCliSupport.java b/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerCliSupport.java
index 3095497..b1a613c 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerCliSupport.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerCliSupport.java
@@ -78,7 +78,7 @@ public abstract class SshServerCliSupport extends CliSupport {
public static KeyPairProvider resolveServerKeys(
PrintStream stderr, String hostKeyType, int hostKeySize, Collection<String> keyFiles)
- throws Exception {
+ throws Exception {
if (GenericUtils.isEmpty(keyFiles)) {
AbstractGeneratorHostKeyProvider hostKeyProvider;
Path hostKeyFile;
@@ -95,7 +95,7 @@ public abstract class SshServerCliSupport extends CliSupport {
}
List<KeyPair> keys = ValidateUtils.checkNotNullAndNotEmpty(
- hostKeyProvider.loadKeys(null), "Failed to load keys from %s", hostKeyFile);
+ hostKeyProvider.loadKeys(null), "Failed to load keys from %s", hostKeyFile);
KeyPair kp = keys.get(0);
PublicKey pubKey = kp.getPublic();
String keyAlgorithm = pubKey.getAlgorithm();
@@ -122,8 +122,8 @@ public abstract class SshServerCliSupport extends CliSupport {
ids = SecurityUtils.loadKeyPairIdentities(null, location, inputStream, null);
} catch (Exception e) {
stderr.append("ERROR: Failed (").append(e.getClass().getSimpleName()).append(')')
- .append(" to load host key file=").append(keyFilePath)
- .append(": ").println(e.getMessage());
+ .append(" to load host key file=").append(keyFilePath)
+ .append(": ").println(e.getMessage());
stderr.flush();
throw e;
}
@@ -136,14 +136,14 @@ public abstract class SshServerCliSupport extends CliSupport {
for (KeyPair kp : ids) {
if (kp == null) {
stderr.append("WARNING: empty key found in ").println(keyFilePath);
- continue; // debug breakpoint
+ continue; // debug breakpoint
}
pairs.add(kp);
}
}
return new MappedKeyPairProvider(
- ValidateUtils.checkNotNullAndNotEmpty(pairs, "No key pairs loaded for provided key files"));
+ ValidateUtils.checkNotNullAndNotEmpty(pairs, "No key pairs loaded for provided key files"));
}
}
@@ -165,7 +165,7 @@ public abstract class SshServerCliSupport extends CliSupport {
public static List<SubsystemFactory> resolveServerSubsystems(
ServerFactoryManager server, Level level, PrintStream stdout, PrintStream stderr, PropertyResolver options)
- throws Exception {
+ throws Exception {
ClassLoader cl = ThreadUtils.resolveDefaultClassLoader(SubsystemFactory.class);
String classList = System.getProperty(SubsystemFactory.class.getName());
if (GenericUtils.isNotEmpty(classList)) {
@@ -176,12 +176,12 @@ public abstract class SshServerCliSupport extends CliSupport {
Class<?> clazz = cl.loadClass(fqcn);
SubsystemFactory factory = SubsystemFactory.class.cast(clazz.newInstance());
factory = registerSubsystemFactoryListeners(
- server, level, stdout, stderr, options, factory);
+ server, level, stdout, stderr, options, factory);
subsystems.add(factory);
} catch (Exception e) {
stderr.append("ERROR: Failed (").append(e.getClass().getSimpleName()).append(')')
- .append(" to instantiate subsystem=").append(fqcn)
- .append(": ").println(e.getMessage());
+ .append(" to instantiate subsystem=").append(fqcn)
+ .append(": ").println(e.getMessage());
stderr.flush();
throw e;
}
@@ -190,17 +190,16 @@ public abstract class SshServerCliSupport extends CliSupport {
return subsystems;
}
- String nameList =
- (options == null) ? null : options.getString(ConfigFileReaderSupport.SUBSYSTEM_CONFIG_PROP);
+ String nameList = (options == null) ? null : options.getString(ConfigFileReaderSupport.SUBSYSTEM_CONFIG_PROP);
if (PropertyResolverUtils.isNoneValue(nameList)) {
return Collections.emptyList();
}
boolean havePreferences = GenericUtils.isNotEmpty(nameList);
Collection<String> preferredNames = (!havePreferences)
- ? Collections.emptySet()
- : Stream.of(GenericUtils.split(nameList, ','))
- .collect(Collectors.toCollection(() -> new TreeSet<>(String.CASE_INSENSITIVE_ORDER)));
+ ? Collections.emptySet()
+ : Stream.of(GenericUtils.split(nameList, ','))
+ .collect(Collectors.toCollection(() -> new TreeSet<>(String.CASE_INSENSITIVE_ORDER)));
ServiceLoader<SubsystemFactory> loader = ServiceLoader.load(SubsystemFactory.class, cl);
List<SubsystemFactory> subsystems = new ArrayList<>();
for (SubsystemFactory factory : loader) {
@@ -210,7 +209,7 @@ public abstract class SshServerCliSupport extends CliSupport {
}
factory = registerSubsystemFactoryListeners(
- server, level, stdout, stderr, options, factory);
+ server, level, stdout, stderr, options, factory);
subsystems.add(factory);
}
@@ -218,8 +217,9 @@ public abstract class SshServerCliSupport extends CliSupport {
}
public static <F extends SubsystemFactory> F registerSubsystemFactoryListeners(
- ServerFactoryManager server, Level level, PrintStream stdout, PrintStream stderr, PropertyResolver options, F factory)
- throws Exception {
+ ServerFactoryManager server, Level level, PrintStream stdout, PrintStream stderr, PropertyResolver options,
+ F factory)
+ throws Exception {
if (factory instanceof SftpSubsystemFactory) {
if (isEnabledVerbosityLogging(level)) {
SftpEventListener listener = new SftpServerSubSystemEventListener(stdout, stderr);
@@ -249,8 +249,8 @@ public abstract class SshServerCliSupport extends CliSupport {
return ShellFactory.class.cast(instance);
} catch (Exception e) {
stderr.append("ERROR: Failed (").append(e.getClass().getSimpleName()).append(')')
- .append(" to instantiate shell factory=").append(factory)
- .append(": ").println(e.getMessage());
+ .append(" to instantiate shell factory=").append(factory)
+ .append(": ").println(e.getMessage());
stderr.flush();
throw e;
}
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerMain.java b/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerMain.java
index f79ea84..9361ee6 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerMain.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerMain.java
@@ -55,7 +55,7 @@ import org.apache.sshd.server.subsystem.SubsystemFactory;
*/
public class SshServerMain extends SshServerCliSupport {
public SshServerMain() {
- super(); // in case someone wants to extend it
+ super(); // in case someone wants to extend it
}
//////////////////////////////////////////////////////////////////////////
@@ -161,16 +161,17 @@ public class SshServerMain extends SshServerCliSupport {
PropertyResolver resolver = PropertyResolverUtils.toPropertyResolver(options);
Level level = resolveLoggingVerbosity(resolver, args);
SshServer sshd = error
- ? null
- : setupIoServiceFactory(
- SshServer.setUpDefaultServer(), resolver,
- level, System.out, System.err, args);
+ ? null
+ : setupIoServiceFactory(
+ SshServer.setUpDefaultServer(), resolver,
+ level, System.out, System.err, args);
if (sshd == null) {
error = true;
}
if (error) {
- System.err.println("usage: sshd [-p port] [-io mina|nio2|netty] [-key-type RSA|DSA|EC] [-key-size NNNN] [-key-file <path>] [-o option=value]");
+ System.err.println(
+ "usage: sshd [-p port] [-io mina|nio2|netty] [-key-type RSA|DSA|EC] [-key-size NNNN] [-key-file <path>] [-o option=value]");
System.exit(-1);
}
@@ -178,12 +179,11 @@ public class SshServerMain extends SshServerCliSupport {
props.putAll(options);
SshServerConfigFileReader.setupServerHeartbeat(sshd, resolver);
- KeyPairProvider hostKeyProvider =
- resolveServerKeys(System.err, hostKeyType, hostKeySize, keyFiles);
+ KeyPairProvider hostKeyProvider = resolveServerKeys(System.err, hostKeyType, hostKeySize, keyFiles);
sshd.setKeyPairProvider(hostKeyProvider);
if (GenericUtils.isNotEmpty(certFiles)) {
HostKeyCertificateProvider certProvider = new FileHostKeyCertificateProvider(
- certFiles.stream().map(Paths::get).collect(Collectors.toList()));
+ certFiles.stream().map(Paths::get).collect(Collectors.toList()));
sshd.setHostKeyCertificateProvider(certProvider);
}
// Should come AFTER key pair provider setup so auto-welcome can be generated if needed
@@ -206,11 +206,10 @@ public class SshServerMain extends SshServerCliSupport {
setupUserAuthFactories(sshd, resolver);
setupServerForwarding(sshd, level, System.out, System.err, resolver);
sshd.setCommandFactory(new ScpCommandFactory.Builder()
- .withDelegate(ProcessShellCommandFactory.INSTANCE)
- .build());
+ .withDelegate(ProcessShellCommandFactory.INSTANCE)
+ .build());
- List<SubsystemFactory> subsystems =
- resolveServerSubsystems(sshd, level, System.out, System.err, resolver);
+ List<SubsystemFactory> subsystems = resolveServerSubsystems(sshd, level, System.out, System.err, resolver);
if (GenericUtils.isNotEmpty(subsystems)) {
System.out.append("Setup subsystems=").println(NamedResource.getNames(subsystems));
sshd.setSubsystemFactories(subsystems);
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/ServerEventListenerHelper.java b/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/ServerEventListenerHelper.java
index f4de148..f3417ea 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/ServerEventListenerHelper.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/ServerEventListenerHelper.java
@@ -60,8 +60,8 @@ public abstract class ServerEventListenerHelper implements NamedResource {
protected String outputMessage(Appendable out, String format, Object... args) throws IOException {
String message = String.format(format, args);
out.append(getName())
- .append(": ").append(message)
- .append(System.lineSeparator());
+ .append(": ").append(message)
+ .append(System.lineSeparator());
if (out instanceof Flushable) {
((Flushable) out).flush();
}
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/ServerPortForwardingEventListener.java b/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/ServerPortForwardingEventListener.java
index fc072b8..c6afab4 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/ServerPortForwardingEventListener.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/ServerPortForwardingEventListener.java
@@ -34,50 +34,54 @@ public class ServerPortForwardingEventListener extends ServerEventListenerHelper
public void establishedExplicitTunnel(
Session session, SshdSocketAddress local, SshdSocketAddress remote,
boolean localForwarding, SshdSocketAddress boundAddress, Throwable reason)
- throws IOException {
+ throws IOException {
if (reason == null) {
outputDebugMessage("Estalibshed explicit tunnel for session=%s: local=%s, remote=%s, bound=%s, localForward=%s",
- session, local, remote, boundAddress, localForwarding);
+ session, local, remote, boundAddress, localForwarding);
} else {
- outputErrorMessage("Failed (%s) to establish explicit tunnel for session=%s, local=%s, remote=%s, bound=%s, localForward=%s: %s",
- reason.getClass().getSimpleName(), session, local, remote, boundAddress, localForwarding, reason.getMessage());
+ outputErrorMessage(
+ "Failed (%s) to establish explicit tunnel for session=%s, local=%s, remote=%s, bound=%s, localForward=%s: %s",
+ reason.getClass().getSimpleName(), session, local, remote, boundAddress, localForwarding,
+ reason.getMessage());
}
}
@Override
public void tornDownExplicitTunnel(
- Session session, SshdSocketAddress address, boolean localForwarding, SshdSocketAddress remoteAddress, Throwable reason)
- throws IOException {
+ Session session, SshdSocketAddress address, boolean localForwarding, SshdSocketAddress remoteAddress,
+ Throwable reason)
+ throws IOException {
if (reason == null) {
outputDebugMessage("Torn down explicit tunnel for session=%s: address=%s, remote=%s, localForward=%s",
- session, address, remoteAddress, localForwarding);
+ session, address, remoteAddress, localForwarding);
} else {
- outputErrorMessage("Failed (%s) to tear down explicit tunnel for session=%s, address=%s, remote=%s, localForward=%s: %s",
- reason.getClass().getSimpleName(), session, address, remoteAddress, localForwarding, reason.getMessage());
+ outputErrorMessage(
+ "Failed (%s) to tear down explicit tunnel for session=%s, address=%s, remote=%s, localForward=%s: %s",
+ reason.getClass().getSimpleName(), session, address, remoteAddress, localForwarding, reason.getMessage());
}
}
@Override
public void establishedDynamicTunnel(
Session session, SshdSocketAddress local, SshdSocketAddress boundAddress, Throwable reason)
- throws IOException {
+ throws IOException {
if (reason == null) {
outputDebugMessage("Estalibshed dynamic tunnel for session=%s: local=%s, bound=%s", session, local, boundAddress);
} else {
outputErrorMessage("Failed (%s) to establish dynamic tunnel for session=%s, bound=%s: %s",
- reason.getClass().getSimpleName(), session, local, boundAddress, reason.getMessage());
+ reason.getClass().getSimpleName(), session, local, boundAddress, reason.getMessage());
}
}
@Override
public void tornDownDynamicTunnel(
Session session, SshdSocketAddress address, Throwable reason)
- throws IOException {
+ throws IOException {
if (reason == null) {
outputDebugMessage("Tornd down dynamic tunnel for session=%s: address=%s", session);
} else {
outputErrorMessage("Failed (%s) to tear down dynamic tunnel for session=%s, address=%s: %s",
- reason.getClass().getSimpleName(), session, address, reason.getMessage());
+ reason.getClass().getSimpleName(), session, address, reason.getMessage());
}
}
}
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/SftpServerSubSystemEventListener.java b/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/SftpServerSubSystemEventListener.java
index 7410511..1ebb5a5 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/SftpServerSubSystemEventListener.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/server/helper/SftpServerSubSystemEventListener.java
@@ -34,7 +34,7 @@ import org.apache.sshd.server.subsystem.sftp.SftpEventListener;
*/
public class SftpServerSubSystemEventListener extends ServerEventListenerHelper implements SftpEventListener {
public SftpServerSubSystemEventListener(Appendable stdout, Appendable stderr) {
- super(SftpConstants.SFTP_SUBSYSTEM_NAME, stdout, stderr);
+ super(SftpConstants.SFTP_SUBSYSTEM_NAME, stdout, stderr);
}
@Override
@@ -50,25 +50,25 @@ public class SftpServerSubSystemEventListener extends ServerEventListenerHelper
@Override
public void created(
ServerSession session, Path path, Map<String, ?> attrs, Throwable thrown)
- throws IOException {
+ throws IOException {
if (thrown == null) {
outputDebugMessage("Session %s created directory %s with attributes=%s", session, path, attrs);
} else {
outputErrorMessage("Failed (%s) to create directory %s in session %s: %s",
- thrown.getClass().getSimpleName(), path, session, thrown.getMessage());
+ thrown.getClass().getSimpleName(), path, session, thrown.getMessage());
}
}
@Override
public void moved(
ServerSession session, Path srcPath, Path dstPath, Collection<CopyOption> opts, Throwable thrown)
- throws IOException {
+ throws IOException {
if (thrown == null) {
outputDebugMessage("Session %s moved %s to %s with options=%s",
- session, srcPath, dstPath, opts);
+ session, srcPath, dstPath, opts);
} else {
outputErrorMessage("Failed (%s) to move %s to %s using options=%s in session %s: %s",
- thrown.getClass().getSimpleName(), srcPath, dstPath, opts, session, thrown.getMessage());
+ thrown.getClass().getSimpleName(), srcPath, dstPath, opts, session, thrown.getMessage());
}
}
@@ -78,7 +78,7 @@ public class SftpServerSubSystemEventListener extends ServerEventListenerHelper
outputDebugMessage("Session %s removed %s", session, path);
} else {
outputErrorMessage("Failed (%s) to remove %s in session %s: %s",
- thrown.getClass().getSimpleName(), path, session, thrown.getMessage());
+ thrown.getClass().getSimpleName(), path, session, thrown.getMessage());
}
}
}
diff --git a/sshd-cli/src/test/java/org/apache/sshd/cli/client/ChannelExecMain.java b/sshd-cli/src/test/java/org/apache/sshd/cli/client/ChannelExecMain.java
index 7bc2b7c..93da3ba 100644
--- a/sshd-cli/src/test/java/org/apache/sshd/cli/client/ChannelExecMain.java
+++ b/sshd-cli/src/test/java/org/apache/sshd/cli/client/ChannelExecMain.java
@@ -40,7 +40,8 @@ public class ChannelExecMain extends BaseTestSupport {
}
public static void doExecuteCommands(
- BufferedReader stdin, PrintStream stdout, PrintStream stderr, ClientSession session) throws Exception {
+ BufferedReader stdin, PrintStream stdout, PrintStream stderr, ClientSession session)
+ throws Exception {
while (true) {
stdout.print("> ");
@@ -77,10 +78,11 @@ public class ChannelExecMain extends BaseTestSupport {
PrintStream stderr = System.err;
try (BufferedReader stdin = new BufferedReader(
new InputStreamReader(new NoCloseInputStream(System.in), Charset.defaultCharset()))) {
- ClientSession session = SshClientCliSupport.setupClientSession("-P", stdin, CliSupport.resolveLoggingVerbosity(args), stdout, stderr, args);
+ ClientSession session = SshClientCliSupport.setupClientSession("-P", stdin,
+ CliSupport.resolveLoggingVerbosity(args), stdout, stderr, args);
if (session == null) {
System.err.println("usage: channelExec [-i identity] [-l login] [-P port] [-o option=value]"
- + " [-w password] [-c cipherlist] [-m maclist] [-C] hostname/user@host");
+ + " [-w password] [-c cipherlist] [-m maclist] [-C] hostname/user@host");
System.exit(-1);
return;
}
diff --git a/sshd-cli/src/test/java/org/apache/sshd/cli/client/ScpCommandMainDevelopment.java b/sshd-cli/src/test/java/org/apache/sshd/cli/client/ScpCommandMainDevelopment.java
index 833dca2..7c1f970 100644
--- a/sshd-cli/src/test/java/org/apache/sshd/cli/client/ScpCommandMainDevelopment.java
+++ b/sshd-cli/src/test/java/org/apache/sshd/cli/client/ScpCommandMainDevelopment.java
@@ -20,8 +20,8 @@
package org.apache.sshd.cli.client;
/**
- * Just a test class used to invoke {@link ScpCommandMain#main(String[])} in
- * order to have logging - which is in {@code test} scope
+ * Just a test class used to invoke {@link ScpCommandMain#main(String[])} in order to have logging - which is in
+ * {@code test} scope
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
diff --git a/sshd-cli/src/test/java/org/apache/sshd/cli/client/SftpCommandMainDevelopment.java b/sshd-cli/src/test/java/org/apache/sshd/cli/client/SftpCommandMainDevelopment.java
index 07fb170..8d74a8d 100644
--- a/sshd-cli/src/test/java/org/apache/sshd/cli/client/SftpCommandMainDevelopment.java
+++ b/sshd-cli/src/test/java/org/apache/sshd/cli/client/SftpCommandMainDevelopment.java
@@ -20,8 +20,8 @@
package org.apache.sshd.cli.client;
/**
- * Just a test class used to invoke {@link SftpCommandMain#main(String[])} in
- * order to have logging - which is in {@code test} scope
+ * Just a test class used to invoke {@link SftpCommandMain#main(String[])} in order to have logging - which is in
+ * {@code test} scope
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
diff --git a/sshd-cli/src/test/java/org/apache/sshd/cli/client/SshClientMainDevelopment.java b/sshd-cli/src/test/java/org/apache/sshd/cli/client/SshClientMainDevelopment.java
index e36776a..15ffb56 100644
--- a/sshd-cli/src/test/java/org/apache/sshd/cli/client/SshClientMainDevelopment.java
+++ b/sshd-cli/src/test/java/org/apache/sshd/cli/client/SshClientMainDevelopment.java
@@ -20,8 +20,8 @@
package org.apache.sshd.cli.client;
/**
- * Just a test class used to invoke {@link SshClientMain#main(String[])} in
- * order to have logging - which is in {@code test} scope
+ * Just a test class used to invoke {@link SshClientMain#main(String[])} in order to have logging - which is in
+ * {@code test} scope
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
diff --git a/sshd-cli/src/test/java/org/apache/sshd/cli/client/SshKeyScanMainDevelopment.java b/sshd-cli/src/test/java/org/apache/sshd/cli/client/SshKeyScanMainDevelopment.java
index 9d38925..ad6f7e0 100644
--- a/sshd-cli/src/test/java/org/apache/sshd/cli/client/SshKeyScanMainDevelopment.java
+++ b/sshd-cli/src/test/java/org/apache/sshd/cli/client/SshKeyScanMainDevelopment.java
@@ -20,8 +20,8 @@
package org.apache.sshd.cli.client;
/**
- * Just a test class used to invoke {@link SshKeyScanMain#main(String[])} in
- * order to have logging - which is in {@code test} scope
+ * Just a test class used to invoke {@link SshKeyScanMain#main(String[])} in order to have logging - which is in
+ * {@code test} scope
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
diff --git a/sshd-cli/src/test/java/org/apache/sshd/cli/server/SshFsMounter.java b/sshd-cli/src/test/java/org/apache/sshd/cli/server/SshFsMounter.java
index d75ab14..dd33d61 100644
--- a/sshd-cli/src/test/java/org/apache/sshd/cli/server/SshFsMounter.java
+++ b/sshd-cli/src/test/java/org/apache/sshd/cli/server/SshFsMounter.java
@@ -194,7 +194,8 @@ public final class SshFsMounter extends SshServerCliSupport {
stdin.close();
log.info("destroy(" + username + ")[" + command + "] stdin closed");
} catch (IOException e) {
- log.warn("destroy(" + username + ")[" + command + "] failed (" + e.getClass().getSimpleName() + ") to close stdin: " + e.getMessage());
+ log.warn("destroy(" + username + ")[" + command + "] failed (" + e.getClass().getSimpleName()
+ + ") to close stdin: " + e.getMessage());
if (log.isDebugEnabled()) {
log.debug("destroy(" + username + ")[" + command + "] failure details", e);
}
@@ -271,8 +272,8 @@ public final class SshFsMounter extends SshServerCliSupport {
}
String provider = args[++i];
- BuiltinIoServiceFactoryFactories factory =
- CliSupport.resolveBuiltinIoServiceFactory(System.err, argName, provider);
+ BuiltinIoServiceFactoryFactories factory
+ = CliSupport.resolveBuiltinIoServiceFactory(System.err, argName, provider);
if (factory != null) {
System.setProperty(IoServiceFactory.class.getName(), factory.getFactoryClassName());
} else {
@@ -298,10 +299,11 @@ public final class SshFsMounter extends SshServerCliSupport {
}
PropertyResolver resolver = PropertyResolverUtils.toPropertyResolver(options);
- SshServer sshd = error ? null : setupIoServiceFactory(
- CoreTestSupportUtils.setupTestServer(SshFsMounter.class), resolver,
- resolveLoggingVerbosity(resolver, args),
- System.out, System.err, args);
+ SshServer sshd = error
+ ? null : setupIoServiceFactory(
+ CoreTestSupportUtils.setupTestServer(SshFsMounter.class), resolver,
+ resolveLoggingVerbosity(resolver, args),
+ System.out, System.err, args);
if (sshd == null) {
error = true;
}
@@ -313,7 +315,8 @@ public final class SshFsMounter extends SshServerCliSupport {
Map<String, Object> props = sshd.getProperties();
props.putAll(options);
- Path targetFolder = Objects.requireNonNull(CommonTestSupportUtils.detectTargetFolder(MounterCommandFactory.class), "Failed to detect target folder");
+ Path targetFolder = Objects.requireNonNull(CommonTestSupportUtils.detectTargetFolder(MounterCommandFactory.class),
+ "Failed to detect target folder");
if (SecurityUtils.isBouncyCastleRegistered()) {
sshd.setKeyPairProvider(SecurityUtils.createGeneratorHostKeyProvider(targetFolder.resolve("key.pem")));
} else {
diff --git a/sshd-cli/src/test/java/org/apache/sshd/cli/server/SshServerMainDevelopment.java b/sshd-cli/src/test/java/org/apache/sshd/cli/server/SshServerMainDevelopment.java
index 28409fa..e4ed72c 100644
--- a/sshd-cli/src/test/java/org/apache/sshd/cli/server/SshServerMainDevelopment.java
+++ b/sshd-cli/src/test/java/org/apache/sshd/cli/server/SshServerMainDevelopment.java
@@ -20,8 +20,8 @@
package org.apache.sshd.cli.server;
/**
- * Just a test class used to invoke {@link SshServerMain#main(String[])} in
- * order to have logging - which is in {@code test} scope
+ * Just a test class used to invoke {@link SshServerMain#main(String[])} in order to have logging - which is in
+ * {@code test} scope
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/auth/AuthenticationIdentitiesProvider.java b/sshd-common/src/main/java/org/apache/sshd/client/auth/AuthenticationIdentitiesProvider.java
index 6ac1a93..3b54c9d 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/auth/AuthenticationIdentitiesProvider.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/auth/AuthenticationIdentitiesProvider.java
@@ -35,8 +35,8 @@ import org.apache.sshd.common.util.helper.LazyMatchingTypeIterable;
public interface AuthenticationIdentitiesProvider extends KeyIdentityProvider, PasswordIdentityProvider {
/**
- * Compares 2 password identities - returns zero ONLY if <U>both</U> compared
- * objects are {@link String}s and equal to each other
+ * Compares 2 password identities - returns zero ONLY if <U>both</U> compared objects are {@link String}s and equal
+ * to each other
*/
Comparator<Object> PASSWORD_IDENTITY_COMPARATOR = (o1, o2) -> {
if (!(o1 instanceof String) || !(o2 instanceof String)) {
@@ -47,8 +47,8 @@ public interface AuthenticationIdentitiesProvider extends KeyIdentityProvider, P
};
/**
- * Compares 2 {@link KeyPair} identities - returns zero ONLY if <U>both</U> compared
- * objects are {@link KeyPair}s and equal to each other
+ * Compares 2 {@link KeyPair} identities - returns zero ONLY if <U>both</U> compared objects are {@link KeyPair}s
+ * and equal to each other
*/
Comparator<Object> KEYPAIR_IDENTITY_COMPARATOR = (o1, o2) -> {
if ((!(o1 instanceof KeyPair)) || (!(o2 instanceof KeyPair))) {
@@ -77,8 +77,8 @@ public interface AuthenticationIdentitiesProvider extends KeyIdentityProvider, P
}
/**
- * @param identities The {@link Iterable} identities - OK if {@code null}/empty
- * @return An {@link AuthenticationIdentitiesProvider} wrapping the identities
+ * @param identities The {@link Iterable} identities - OK if {@code null}/empty
+ * @return An {@link AuthenticationIdentitiesProvider} wrapping the identities
*/
static AuthenticationIdentitiesProvider wrapIdentities(Iterable<?> identities) {
return new AuthenticationIdentitiesProvider() {
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/auth/hostbased/HostKeyIdentityProvider.java b/sshd-common/src/main/java/org/apache/sshd/client/auth/hostbased/HostKeyIdentityProvider.java
index 81c26ca..53b1aca 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/auth/hostbased/HostKeyIdentityProvider.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/auth/hostbased/HostKeyIdentityProvider.java
@@ -48,6 +48,7 @@ public interface HostKeyIdentityProvider {
}
static HostKeyIdentityProvider wrap(Iterable<? extends KeyPair> pairs) {
- return () -> GenericUtils.wrapIterable(pairs, kp -> new SimpleImmutableEntry<>(kp, Collections.<X509Certificate>emptyList()));
+ return () -> GenericUtils.wrapIterable(pairs,
+ kp -> new SimpleImmutableEntry<>(kp, Collections.<X509Certificate> emptyList()));
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/auth/password/PasswordIdentityProvider.java b/sshd-common/src/main/java/org/apache/sshd/client/auth/password/PasswordIdentityProvider.java
index f075bf8..a0d6eca 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/auth/password/PasswordIdentityProvider.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/auth/password/PasswordIdentityProvider.java
@@ -34,8 +34,7 @@ import org.apache.sshd.common.util.GenericUtils;
public interface PasswordIdentityProvider {
/**
- * An "empty" implementation of {@link PasswordIdentityProvider} that returns
- * and empty group of passwords
+ * An "empty" implementation of {@link PasswordIdentityProvider} that returns and empty group of passwords
*/
PasswordIdentityProvider EMPTY_PASSWORDS_PROVIDER = new PasswordIdentityProvider() {
@Override
@@ -50,11 +49,11 @@ public interface PasswordIdentityProvider {
};
/**
- * Invokes {@link PasswordIdentityProvider#loadPasswords()} and returns the result.
- * Ignores {@code null} providers (i.e., returns an empty iterable instance)
+ * Invokes {@link PasswordIdentityProvider#loadPasswords()} and returns the result. Ignores {@code null} providers
+ * (i.e., returns an empty iterable instance)
*/
- Function<PasswordIdentityProvider, Iterable<String>> LOADER = p ->
- (p == null) ? Collections.emptyList() : p.loadPasswords();
+ Function<PasswordIdentityProvider, Iterable<String>> LOADER
+ = p -> (p == null) ? Collections.emptyList() : p.loadPasswords();
/**
* @return The currently available passwords - ignored if {@code null}
@@ -62,13 +61,12 @@ public interface PasswordIdentityProvider {
Iterable<String> loadPasswords();
/**
- * Creates a "unified" {@link Iterator} of passwords out of 2 possible
- * {@link PasswordIdentityProvider}
+ * Creates a "unified" {@link Iterator} of passwords out of 2 possible {@link PasswordIdentityProvider}
*
- * @param identities The registered passwords
- * @param passwords Extra available passwords
- * @return The wrapping iterator
- * @see #resolvePasswordIdentityProvider(PasswordIdentityProvider, PasswordIdentityProvider)
+ * @param identities The registered passwords
+ * @param passwords Extra available passwords
+ * @return The wrapping iterator
+ * @see #resolvePasswordIdentityProvider(PasswordIdentityProvider, PasswordIdentityProvider)
*/
static Iterator<String> iteratorOf(PasswordIdentityProvider identities, PasswordIdentityProvider passwords) {
return iteratorOf(resolvePasswordIdentityProvider(identities, passwords));
@@ -77,27 +75,29 @@ public interface PasswordIdentityProvider {
/**
* Resolves a non-{@code null} iterator of the available passwords
*
- * @param provider The {@link PasswordIdentityProvider} - ignored if {@code null} (i.e.,
- * return an empty iterator)
- * @return A non-{@code null} iterator - which may be empty if no provider or no passwords
+ * @param provider The {@link PasswordIdentityProvider} - ignored if {@code null} (i.e., return an empty iterator)
+ * @return A non-{@code null} iterator - which may be empty if no provider or no passwords
*/
static Iterator<String> iteratorOf(PasswordIdentityProvider provider) {
return GenericUtils.iteratorOf((provider == null) ? null : provider.loadPasswords());
}
/**
- * <P>Creates a "unified" {@link PasswordIdentityProvider} out of 2 possible ones
- * as follows:</P></BR>
+ * <P>
+ * Creates a "unified" {@link PasswordIdentityProvider} out of 2 possible ones as follows:
+ * </P>
+ * </BR>
* <UL>
- * <LI>If both are {@code null} then return {@code null}.</LI>
- * <LI>If either one is {@code null} then use the non-{@code null} one.</LI>
- * <LI>If both are the same instance then use it.</U>
- * <LI>Otherwise, returns a wrapper that groups both providers.</LI>
+ * <LI>If both are {@code null} then return {@code null}.</LI>
+ * <LI>If either one is {@code null} then use the non-{@code null} one.</LI>
+ * <LI>If both are the same instance then use it.</U>
+ * <LI>Otherwise, returns a wrapper that groups both providers.</LI>
* </UL>
- * @param identities The registered passwords
- * @param passwords The extra available passwords
- * @return The resolved provider
- * @see #multiProvider(PasswordIdentityProvider...)
+ *
+ * @param identities The registered passwords
+ * @param passwords The extra available passwords
+ * @return The resolved provider
+ * @see #multiProvider(PasswordIdentityProvider...)
*/
static PasswordIdentityProvider resolvePasswordIdentityProvider(
PasswordIdentityProvider identities, PasswordIdentityProvider passwords) {
@@ -113,10 +113,9 @@ public interface PasswordIdentityProvider {
/**
* Wraps a group of {@link PasswordIdentityProvider} into a single one
*
- * @param providers The providers - ignored if {@code null}/empty (i.e., returns
- * {@link #EMPTY_PASSWORDS_PROVIDER}
- * @return The wrapping provider
- * @see #multiProvider(Collection)
+ * @param providers The providers - ignored if {@code null}/empty (i.e., returns {@link #EMPTY_PASSWORDS_PROVIDER}
+ * @return The wrapping provider
+ * @see #multiProvider(Collection)
*/
static PasswordIdentityProvider multiProvider(PasswordIdentityProvider... providers) {
return multiProvider(GenericUtils.asList(providers));
@@ -125,9 +124,8 @@ public interface PasswordIdentityProvider {
/**
* Wraps a group of {@link PasswordIdentityProvider} into a single one
*
- * @param providers The providers - ignored if {@code null}/empty (i.e., returns
- * {@link #EMPTY_PASSWORDS_PROVIDER}
- * @return The wrapping provider
+ * @param providers The providers - ignored if {@code null}/empty (i.e., returns {@link #EMPTY_PASSWORDS_PROVIDER}
+ * @return The wrapping provider
*/
static PasswordIdentityProvider multiProvider(Collection<? extends PasswordIdentityProvider> providers) {
return GenericUtils.isEmpty(providers) ? EMPTY_PASSWORDS_PROVIDER : wrapPasswords(iterableOf(providers));
@@ -136,21 +134,20 @@ public interface PasswordIdentityProvider {
/**
* Wraps a group of {@link PasswordIdentityProvider} into an {@link Iterable} of their combined passwords
*
- * @param providers The providers - ignored if {@code null}/empty (i.e., returns an empty iterable instance)
- * @return The wrapping iterable
+ * @param providers The providers - ignored if {@code null}/empty (i.e., returns an empty iterable instance)
+ * @return The wrapping iterable
*/
static Iterable<String> iterableOf(Collection<? extends PasswordIdentityProvider> providers) {
- Iterable<Supplier<Iterable<String>>> passwordSuppliers =
- GenericUtils.<PasswordIdentityProvider, Supplier<Iterable<String>>>wrapIterable(providers, p -> p::loadPasswords);
+ Iterable<Supplier<Iterable<String>>> passwordSuppliers = GenericUtils.<PasswordIdentityProvider,
+ Supplier<Iterable<String>>> wrapIterable(providers, p -> p::loadPasswords);
return GenericUtils.multiIterableSuppliers(passwordSuppliers);
}
/**
* Wraps a group of passwords into a {@link PasswordIdentityProvider}
*
- * @param passwords The passwords - ignored if {@code null}/empty
- * (i.e., returns {@link #EMPTY_PASSWORDS_PROVIDER})
- * @return The provider wrapper
+ * @param passwords The passwords - ignored if {@code null}/empty (i.e., returns {@link #EMPTY_PASSWORDS_PROVIDER})
+ * @return The provider wrapper
*/
static PasswordIdentityProvider wrapPasswords(String... passwords) {
return wrapPasswords(GenericUtils.asList(passwords));
@@ -159,9 +156,9 @@ public interface PasswordIdentityProvider {
/**
* Wraps a group of passwords into a {@link PasswordIdentityProvider}
*
- * @param passwords The passwords {@link Iterable} - ignored if {@code null}
- * (i.e., returns {@link #EMPTY_PASSWORDS_PROVIDER})
- * @return The provider wrapper
+ * @param passwords The passwords {@link Iterable} - ignored if {@code null} (i.e., returns
+ * {@link #EMPTY_PASSWORDS_PROVIDER})
+ * @return The provider wrapper
*/
static PasswordIdentityProvider wrapPasswords(Iterable<String> passwords) {
return (passwords == null) ? EMPTY_PASSWORDS_PROVIDER : () -> passwords;
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/auth/pubkey/PublicKeyIdentity.java b/sshd-common/src/main/java/org/apache/sshd/client/auth/pubkey/PublicKeyIdentity.java
index 9f055d3..97f9554 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/auth/pubkey/PublicKeyIdentity.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/auth/pubkey/PublicKeyIdentity.java
@@ -36,11 +36,11 @@ public interface PublicKeyIdentity {
/**
* Proves the public key identity by signing the given data
*
- * @param session The {@link SessionContext} for calling this method - may
- * be {@code null} if not called within a session context
- * @param data Data to sign
- * @return Signed data - using the identity
+ * @param session The {@link SessionContext} for calling this method - may be {@code null} if not called within a
+ * session context
+ * @param data Data to sign
+ * @return Signed data - using the identity
* @throws Exception If failed to sign the data
*/
byte[] sign(SessionContext session, byte[] data) throws Exception;
-}
\ No newline at end of file
+}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/ConfigFileHostEntryResolver.java b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/ConfigFileHostEntryResolver.java
index fe40b73..1159e50 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/ConfigFileHostEntryResolver.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/ConfigFileHostEntryResolver.java
@@ -53,10 +53,10 @@ public class ConfigFileHostEntryResolver extends ModifiableFileWatcher implement
@Override
public HostConfigEntry resolveEffectiveHost(
String host, int port, SocketAddress localAddress, String username, AttributeRepository context)
- throws IOException {
+ throws IOException {
try {
- HostConfigEntryResolver delegate =
- Objects.requireNonNull(resolveEffectiveResolver(host, port, username), "No delegate");
+ HostConfigEntryResolver delegate
+ = Objects.requireNonNull(resolveEffectiveResolver(host, port, username), "No delegate");
HostConfigEntry entry = delegate.resolveEffectiveHost(host, port, localAddress, username, context);
if (log.isDebugEnabled()) {
log.debug("resolveEffectiveHost({}@{}:{}) => {}", username, host, port, entry);
@@ -66,7 +66,7 @@ public class ConfigFileHostEntryResolver extends ModifiableFileWatcher implement
} catch (Throwable e) {
if (log.isDebugEnabled()) {
log.debug("resolveEffectiveHost({}@{}:{}) failed ({}) to resolve: {}",
- username, host, port, e.getClass().getSimpleName(), e.getMessage());
+ username, host, port, e.getClass().getSimpleName(), e.getMessage());
}
if (log.isTraceEnabled()) {
@@ -82,12 +82,11 @@ public class ConfigFileHostEntryResolver extends ModifiableFileWatcher implement
protected HostConfigEntryResolver resolveEffectiveResolver(String host, int port, String username) throws IOException {
if (checkReloadRequired()) {
- delegateHolder.set(HostConfigEntryResolver.EMPTY); // start fresh
+ delegateHolder.set(HostConfigEntryResolver.EMPTY); // start fresh
Path path = getPath();
if (exists()) {
- Collection<HostConfigEntry> entries =
- reloadHostConfigEntries(path, host, port, username);
+ Collection<HostConfigEntry> entries = reloadHostConfigEntries(path, host, port, username);
if (GenericUtils.size(entries) > 0) {
delegateHolder.set(HostConfigEntry.toHostConfigEntryResolver(entries));
}
@@ -101,9 +100,10 @@ public class ConfigFileHostEntryResolver extends ModifiableFileWatcher implement
protected List<HostConfigEntry> reloadHostConfigEntries(
Path path, String host, int port, String username)
- throws IOException {
+ throws IOException {
List<HostConfigEntry> entries = HostConfigEntry.readHostConfigEntries(path);
- log.info("resolveEffectiveResolver({}@{}:{}) loaded {} entries from {}", username, host, port, GenericUtils.size(entries), path);
+ log.info("resolveEffectiveResolver({}@{}:{}) loaded {} entries from {}", username, host, port,
+ GenericUtils.size(entries), path);
updateReloadAttributes();
return entries;
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/DefaultConfigFileHostEntryResolver.java b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/DefaultConfigFileHostEntryResolver.java
index 7fc500c..6b44026 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/DefaultConfigFileHostEntryResolver.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/DefaultConfigFileHostEntryResolver.java
@@ -27,9 +27,8 @@ import java.util.List;
import java.util.Map;
/**
- * Monitors the {@code ~/.ssh/config} file of the user currently running
- * the client, re-loading it if necessary. It also (optionally) enforces
- * the same permissions regime as {@code OpenSSH}
+ * Monitors the {@code ~/.ssh/config} file of the user currently running the client, re-loading it if necessary. It also
+ * (optionally) enforces the same permissions regime as {@code OpenSSH}
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
@@ -42,10 +41,9 @@ public class DefaultConfigFileHostEntryResolver extends ConfigFileHostEntryResol
private final boolean strict;
/**
- * @param strict If {@code true} then makes sure that the containing folder
- * has 0700 access and the file 0644. <B>Note:</B> for <I>Windows</I> it
- * does not check these permissions
- * @see #validateStrictConfigFilePermissions(Path, LinkOption...)
+ * @param strict If {@code true} then makes sure that the containing folder has 0700 access and the file 0644.
+ * <B>Note:</B> for <I>Windows</I> it does not check these permissions
+ * @see #validateStrictConfigFilePermissions(Path, LinkOption...)
*/
public DefaultConfigFileHostEntryResolver(boolean strict) {
this(HostConfigEntry.getDefaultHostConfigFile(), strict);
@@ -57,17 +55,17 @@ public class DefaultConfigFileHostEntryResolver extends ConfigFileHostEntryResol
}
/**
- * @return If {@code true} then makes sure that the containing folder
- * has 0700 access and the file 0644. <B>Note:</B> for <I>Windows</I> it
- * does not check these permissions
- * @see #validateStrictConfigFilePermissions(Path, LinkOption...)
+ * @return If {@code true} then makes sure that the containing folder has 0700 access and the file 0644.
+ * <B>Note:</B> for <I>Windows</I> it does not check these permissions
+ * @see #validateStrictConfigFilePermissions(Path, LinkOption...)
*/
public final boolean isStrict() {
return strict;
}
@Override
- protected List<HostConfigEntry> reloadHostConfigEntries(Path path, String host, int port, String username) throws IOException {
+ protected List<HostConfigEntry> reloadHostConfigEntries(Path path, String host, int port, String username)
+ throws IOException {
if (isStrict()) {
if (log.isDebugEnabled()) {
log.debug("reloadHostConfigEntries({}@{}:{}) check permissions of {}", username, host, port, path);
@@ -76,7 +74,7 @@ public class DefaultConfigFileHostEntryResolver extends ConfigFileHostEntryResol
Map.Entry<String, ?> violation = validateStrictConfigFilePermissions(path);
if (violation != null) {
log.warn("reloadHostConfigEntries({}@{}:{}) invalid file={} permissions: {}",
- username, host, port, path, violation.getKey());
+ username, host, port, path, violation.getKey());
updateReloadAttributes();
return Collections.emptyList();
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java
index 0ad02e8..6a5bb70 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java
@@ -60,11 +60,12 @@ import org.apache.sshd.common.util.io.NoCloseOutputStream;
import org.apache.sshd.common.util.io.NoCloseReader;
/**
- * Represents an entry in the client's configuration file as defined by
- * the <A HREF="https://linux.die.net/man/5/ssh_config">ssh_config</A>
- * configuration file format
+ * Represents an entry in the client's configuration file as defined by the
+ * <A HREF="https://linux.die.net/man/5/ssh_config">ssh_config</A> configuration file format
+ *
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- * @see <A HREF="https://www.cyberciti.biz/faq/create-ssh-config-file-on-linux-unix/">OpenSSH Config File Examples</A>
+ * @see <A HREF="https://www.cyberciti.biz/faq/create-ssh-config-file-on-linux-unix/">OpenSSH Config File
+ * Examples</A>
*/
public class HostConfigEntry extends HostPatternsHolder implements MutableUserHolder {
/**
@@ -86,12 +87,10 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
/**
* A case <U>insensitive</U> {@link NavigableSet} of the properties that receive special handling
*/
- public static final NavigableSet<String> EXPLICIT_PROPERTIES =
- Collections.unmodifiableNavigableSet(
+ public static final NavigableSet<String> EXPLICIT_PROPERTIES = Collections.unmodifiableNavigableSet(
GenericUtils.asSortedSet(String.CASE_INSENSITIVE_ORDER,
- HOST_CONFIG_PROP, HOST_NAME_CONFIG_PROP, PORT_CONFIG_PROP,
- USER_CONFIG_PROP, IDENTITY_FILE_CONFIG_PROP, EXCLUSIVE_IDENTITIES_CONFIG_PROP
- ));
+ HOST_CONFIG_PROP, HOST_NAME_CONFIG_PROP, PORT_CONFIG_PROP,
+ USER_CONFIG_PROP, IDENTITY_FILE_CONFIG_PROP, EXCLUSIVE_IDENTITIES_CONFIG_PROP));
public static final String MULTI_VALUE_SEPARATORS = " ,";
@@ -106,8 +105,7 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
public static final char REMOTE_PORT_MACRO = 'p';
private static final class LazyDefaultConfigFileHolder {
- private static final Path CONFIG_FILE =
- PublicKeyEntry.getDefaultKeysFolderPath().resolve(STD_CONFIG_FILENAME);
+ private static final Path CONFIG_FILE = PublicKeyEntry.getDefaultKeysFolderPath().resolve(STD_CONFIG_FILENAME);
private LazyDefaultConfigFileHolder() {
throw new UnsupportedOperationException("No instance allowed");
@@ -179,10 +177,9 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
/**
* Resolves the effective port to use
*
- * @param originalPort The original requested port
- * @return If the host entry port is positive, then it is used, otherwise
- * the original requested port
- * @see #resolvePort(int, int)
+ * @param originalPort The original requested port
+ * @return If the host entry port is positive, then it is used, otherwise the original requested port
+ * @see #resolvePort(int, int)
*/
public int resolvePort(int originalPort) {
return resolvePort(originalPort, getPort());
@@ -204,10 +201,10 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
/**
* Resolves the effective username
*
- * @param originalUser The original requested username
- * @return If the configured host entry username is not {@code null}/empty
- * then it is used, otherwise the original one.
- * @see #resolveUsername(String)
+ * @param originalUser The original requested username
+ * @return If the configured host entry username is not {@code null}/empty then it is used, otherwise
+ * the original one.
+ * @see #resolveUsername(String)
*/
public String resolveUsername(String originalUser) {
return resolveUsername(originalUser, getUsername());
@@ -221,8 +218,7 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * @param path A {@link Path} to a file that contains an identity key
- * - never {@code null}
+ * @param path A {@link Path} to a file that contains an identity key - never {@code null}
*/
public void addIdentity(Path path) {
addIdentity(Objects.requireNonNull(path, "No path").toAbsolutePath().normalize().toString());
@@ -257,28 +253,27 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * @return A {@link Map} of extra properties that have been read - may be
- * {@code null}/empty, or even contain some values that have been parsed
- * and set as members of the entry (e.g., host, port, etc.). <B>Note:</B>
- * multi-valued keys use a comma-separated list of values
+ * @return A {@link Map} of extra properties that have been read - may be {@code null}/empty, or even contain some
+ * values that have been parsed and set as members of the entry (e.g., host, port, etc.). <B>Note:</B>
+ * multi-valued keys use a comma-separated list of values
*/
public Map<String, String> getProperties() {
return properties;
}
/**
- * @param name Property name - never {@code null}/empty
- * @return Property value or {@code null} if no such property
- * @see #getProperty(String, String)
+ * @param name Property name - never {@code null}/empty
+ * @return Property value or {@code null} if no such property
+ * @see #getProperty(String, String)
*/
public String getProperty(String name) {
return getProperty(name, null);
}
/**
- * @param name Property name - never {@code null}/empty
- * @param defaultValue Default value to return if no such property
- * @return The property value or the default one if no such property
+ * @param name Property name - never {@code null}/empty
+ * @param defaultValue Default value to return if no such property
+ * @return The property value or the default one if no such property
*/
public String getProperty(String name, String defaultValue) {
String key = ValidateUtils.checkNotNullAndNotEmpty(name, "No property name");
@@ -296,12 +291,10 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * Updates the values that are <U>not</U> already configured with those
- * from the global entry
+ * Updates the values that are <U>not</U> already configured with those from the global entry
*
- * @param globalEntry The global entry - ignored if {@code null} or
- * same reference as this entry
- * @return {@code true} if anything updated
+ * @param globalEntry The global entry - ignored if {@code null} or same reference as this entry
+ * @return {@code true} if anything updated
*/
public boolean processGlobalValues(HostConfigEntry globalEntry) {
if ((globalEntry == null) || (this == globalEntry)) {
@@ -310,8 +303,7 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
boolean modified = false;
/*
- * NOTE !!! DO NOT TRY TO CHANGE THE ORDER OF THE OR-ing AS IT
- * WOULD CAUSE INVALID CODE EXECUTION
+ * NOTE !!! DO NOT TRY TO CHANGE THE ORDER OF THE OR-ing AS IT WOULD CAUSE INVALID CODE EXECUTION
*/
modified = updateGlobalPort(globalEntry.getPort()) || modified;
modified = updateGlobalHostName(globalEntry.getHostName()) || modified;
@@ -328,8 +320,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
/**
* Sets all the properties for which no current value exists in the entry
*
- * @param props The global properties - ignored if {@code null}/empty
- * @return A {@link Map} of the <U>updated</U> properties
+ * @param props The global properties - ignored if {@code null}/empty
+ * @return A {@link Map} of the <U>updated</U> properties
*/
public Map<String, String> updateGlobalProperties(Map<String, String> props) {
if (GenericUtils.isEmpty(props)) {
@@ -363,9 +355,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * @param ids Global identities - ignored if {@code null}/empty or already
- * have configured identities
- * @return {@code true} if updated identities
+ * @param ids Global identities - ignored if {@code null}/empty or already have configured identities
+ * @return {@code true} if updated identities
*/
public boolean updateGlobalIdentities(Collection<String> ids) {
if (GenericUtils.isEmpty(ids) || (GenericUtils.size(getIdentities()) > 0)) {
@@ -380,9 +371,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * @param user The global user name - ignored if {@code null}/empty or
- * already have a configured user
- * @return {@code true} if updated the username
+ * @param user The global user name - ignored if {@code null}/empty or already have a configured user
+ * @return {@code true} if updated the username
*/
public boolean updateGlobalUserName(String user) {
if (GenericUtils.isEmpty(user) || (GenericUtils.length(getUsername()) > 0)) {
@@ -394,9 +384,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * @param name The global host name - ignored if {@code null}/empty or
- * already have a configured target host
- * @return {@code true} if updated the target host
+ * @param name The global host name - ignored if {@code null}/empty or already have a configured target host
+ * @return {@code true} if updated the target host
*/
public boolean updateGlobalHostName(String name) {
if (GenericUtils.isEmpty(name) || (GenericUtils.length(getHostName()) > 0)) {
@@ -408,9 +397,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * @param portValue The global port value - ignored if not positive
- * or already have a configured port
- * @return {@code true} if updated the port value
+ * @param portValue The global port value - ignored if not positive or already have a configured port
+ * @return {@code true} if updated the port value
*/
public boolean updateGlobalPort(int portValue) {
if ((portValue <= 0) || (getPort() > 0)) {
@@ -422,9 +410,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * @param identitiesOnly Whether to use only the identities in this entry.
- * Ignored if already set
- * @return {@code true} if updated the option value
+ * @param identitiesOnly Whether to use only the identities in this entry. Ignored if already set
+ * @return {@code true} if updated the option value
*/
public boolean updateGlobalIdentityOnly(boolean identitiesOnly) {
if (exclusiveIdentites != null) {
@@ -436,17 +423,17 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * @param name Property name - never {@code null}/empty
- * @param valsList The available values for the property
- * @param ignoreAlreadyInitialized If {@code false} and one of the "known"
- * properties is encountered then throws an exception
- * @throws IllegalArgumentException If an existing value is overwritten and
- * <tt>ignoreAlreadyInitialized</tt> is {@code false} (except for {@link #IDENTITY_FILE_CONFIG_PROP}
- * which is <U>cumulative</U>
- * @see #HOST_NAME_CONFIG_PROP
- * @see #PORT_CONFIG_PROP
- * @see #USER_CONFIG_PROP
- * @see #IDENTITY_FILE_CONFIG_PROP
+ * @param name Property name - never {@code null}/empty
+ * @param valsList The available values for the property
+ * @param ignoreAlreadyInitialized If {@code false} and one of the "known" properties is encountered then
+ * throws an exception
+ * @throws IllegalArgumentException If an existing value is overwritten and <tt>ignoreAlreadyInitialized</tt> is
+ * {@code false} (except for {@link #IDENTITY_FILE_CONFIG_PROP} which is
+ * <U>cumulative</U>
+ * @see #HOST_NAME_CONFIG_PROP
+ * @see #PORT_CONFIG_PROP
+ * @see #USER_CONFIG_PROP
+ * @see #IDENTITY_FILE_CONFIG_PROP
*/
public void processProperty(String name, Collection<String> valsList, boolean ignoreAlreadyInitialized) {
String key = ValidateUtils.checkNotNullAndNotEmpty(name, "No property name");
@@ -457,7 +444,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
ValidateUtils.checkTrue(GenericUtils.size(valsList) == 1, "Multiple target hosts N/A: %s", joinedValue);
String curValue = getHostName();
- ValidateUtils.checkTrue(GenericUtils.isEmpty(curValue) || ignoreAlreadyInitialized, "Already initialized %s: %s", key, curValue);
+ ValidateUtils.checkTrue(GenericUtils.isEmpty(curValue) || ignoreAlreadyInitialized, "Already initialized %s: %s",
+ key, curValue);
setHostName(joinedValue);
} else if (PORT_CONFIG_PROP.equalsIgnoreCase(key)) {
ValidateUtils.checkTrue(GenericUtils.size(valsList) == 1, "Multiple target ports N/A: %s", joinedValue);
@@ -472,7 +460,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
ValidateUtils.checkTrue(GenericUtils.size(valsList) == 1, "Multiple target users N/A: %s", joinedValue);
String curValue = getUsername();
- ValidateUtils.checkTrue(GenericUtils.isEmpty(curValue) || ignoreAlreadyInitialized, "Already initialized %s: %s", key, curValue);
+ ValidateUtils.checkTrue(GenericUtils.isEmpty(curValue) || ignoreAlreadyInitialized, "Already initialized %s: %s",
+ key, curValue);
setUsername(joinedValue);
} else if (IDENTITY_FILE_CONFIG_PROP.equalsIgnoreCase(key)) {
ValidateUtils.checkTrue(GenericUtils.size(valsList) > 0, "No identity files specified");
@@ -481,18 +470,18 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
} else if (EXCLUSIVE_IDENTITIES_CONFIG_PROP.equalsIgnoreCase(key)) {
setIdentitiesOnly(
- ConfigFileReaderSupport.parseBooleanValue(
- ValidateUtils.checkNotNullAndNotEmpty(joinedValue, "No identities option value")));
+ ConfigFileReaderSupport.parseBooleanValue(
+ ValidateUtils.checkNotNullAndNotEmpty(joinedValue, "No identities option value")));
}
}
/**
- * Appends a value using a <U>comma</U> to an existing one. If no previous
- * value then same as calling {@link #setProperty(String, String)}.
+ * Appends a value using a <U>comma</U> to an existing one. If no previous value then same as calling
+ * {@link #setProperty(String, String)}.
*
- * @param name Property name - never {@code null}/empty
- * @param value The value to be appended - ignored if {@code null}/empty
- * @return The value <U>before</U> appending - {@code null} if no previous value
+ * @param name Property name - never {@code null}/empty
+ * @param value The value to be appended - ignored if {@code null}/empty
+ * @return The value <U>before</U> appending - {@code null} if no previous value
*/
public String appendPropertyValue(String name, String value) {
String key = ValidateUtils.checkNotNullAndNotEmpty(name, "No property name");
@@ -511,10 +500,9 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
/**
* Sets / Replaces the property value
*
- * @param name Property name - never {@code null}/empty
- * @param value Property value - if {@code null}/empty then
- * {@link #removeProperty(String)} is called
- * @return The previous property value - {@code null} if no such name
+ * @param name Property name - never {@code null}/empty
+ * @param value Property value - if {@code null}/empty then {@link #removeProperty(String)} is called
+ * @return The previous property value - {@code null} if no such name
*/
public String setProperty(String name, String value) {
if (GenericUtils.isEmpty(value)) {
@@ -530,8 +518,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * @param name Property name - never {@code null}/empty
- * @return The removed property value - {@code null} if no such property name
+ * @param name Property name - never {@code null}/empty
+ * @return The removed property value - {@code null} if no such property name
*/
public String removeProperty(String name) {
String key = ValidateUtils.checkNotNullAndNotEmpty(name, "No property name");
@@ -544,22 +532,23 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * @param properties The properties to set - if {@code null} then an empty
- * map is effectively set. <B>Note:</B> it is highly recommended to use a
- * <U>case insensitive</U> key mapper.
+ * @param properties The properties to set - if {@code null} then an empty map is effectively set. <B>Note:</B> it
+ * is highly recommended to use a <U>case insensitive</U> key mapper.
*/
public void setProperties(Map<String, String> properties) {
this.properties = (properties == null) ? Collections.emptyMap() : properties;
}
public <A extends Appendable> A append(A sb) throws IOException {
- sb.append(HOST_CONFIG_PROP).append(' ').append(ValidateUtils.checkNotNullAndNotEmpty(getHost(), "No host pattern")).append(IoUtils.EOL);
+ sb.append(HOST_CONFIG_PROP).append(' ').append(ValidateUtils.checkNotNullAndNotEmpty(getHost(), "No host pattern"))
+ .append(IoUtils.EOL);
appendNonEmptyProperty(sb, HOST_NAME_CONFIG_PROP, getHostName());
appendNonEmptyPort(sb, PORT_CONFIG_PROP, getPort());
appendNonEmptyProperty(sb, USER_CONFIG_PROP, getUsername());
appendNonEmptyValues(sb, IDENTITY_FILE_CONFIG_PROP, getIdentities());
if (exclusiveIdentites != null) {
- appendNonEmptyProperty(sb, EXCLUSIVE_IDENTITIES_CONFIG_PROP, ConfigFileReaderSupport.yesNoValueOf(exclusiveIdentites));
+ appendNonEmptyProperty(sb, EXCLUSIVE_IDENTITIES_CONFIG_PROP,
+ ConfigFileReaderSupport.yesNoValueOf(exclusiveIdentites));
}
appendNonEmptyProperties(sb, getProperties());
return sb;
@@ -571,13 +560,13 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * @param <A> The {@link Appendable} type
- * @param sb The target appender
- * @param name The property name - never {@code null}/empty
- * @param port The port value - ignored if non-positive
- * @return The target appender after having appended (or not) the value
+ * @param <A> The {@link Appendable} type
+ * @param sb The target appender
+ * @param name The property name - never {@code null}/empty
+ * @param port The port value - ignored if non-positive
+ * @return The target appender after having appended (or not) the value
* @throws IOException If failed to append the requested data
- * @see #appendNonEmptyProperty(Appendable, String, Object)
+ * @see #appendNonEmptyProperty(Appendable, String, Object)
*/
public static <A extends Appendable> A appendNonEmptyPort(A sb, String name, int port) throws IOException {
return appendNonEmptyProperty(sb, name, (port > 0) ? Integer.toString(port) : null);
@@ -586,12 +575,12 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
/**
* Appends the extra properties - while skipping the {@link #EXPLICIT_PROPERTIES} ones
*
- * @param <A> The {@link Appendable} type
- * @param sb The target appender
- * @param props The {@link Map} of properties - ignored if {@code null}/empty
- * @return The target appender after having appended (or not) the value
+ * @param <A> The {@link Appendable} type
+ * @param sb The target appender
+ * @param props The {@link Map} of properties - ignored if {@code null}/empty
+ * @return The target appender after having appended (or not) the value
* @throws IOException If failed to append the requested data
- * @see #appendNonEmptyProperty(Appendable, String, Object)
+ * @see #appendNonEmptyProperty(Appendable, String, Object)
*/
public static <A extends Appendable> A appendNonEmptyProperties(A sb, Map<String, ?> props) throws IOException {
if (GenericUtils.isEmpty(props)) {
@@ -612,16 +601,15 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * @param <A> The {@link Appendable} type
- * @param sb The target appender
- * @param name The property name - never {@code null}/empty
- * @param value The property value - ignored if {@code null}. <B>Note:</B>
- * if the string representation of the value contains any commas, they are
- * assumed to indicate a multi-valued property which is broken down to
- * <U>individual</U> lines - one per value.
- * @return The target appender after having appended (or not) the value
+ * @param <A> The {@link Appendable} type
+ * @param sb The target appender
+ * @param name The property name - never {@code null}/empty
+ * @param value The property value - ignored if {@code null}. <B>Note:</B> if the string representation of
+ * the value contains any commas, they are assumed to indicate a multi-valued property which is
+ * broken down to <U>individual</U> lines - one per value.
+ * @return The target appender after having appended (or not) the value
* @throws IOException If failed to append the requested data
- * @see #appendNonEmptyValues(Appendable, String, Object...)
+ * @see #appendNonEmptyValues(Appendable, String, Object...)
*/
public static <A extends Appendable> A appendNonEmptyProperty(A sb, String name, Object value) throws IOException {
String s = Objects.toString(value, null);
@@ -630,24 +618,24 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * @param <A> The {@link Appendable} type
- * @param sb The target appender
- * @param name The property name - never {@code null}/empty
- * @param values The values to be added - one per line - ignored if {@code null}/empty
- * @return The target appender after having appended (or not) the value
+ * @param <A> The {@link Appendable} type
+ * @param sb The target appender
+ * @param name The property name - never {@code null}/empty
+ * @param values The values to be added - one per line - ignored if {@code null}/empty
+ * @return The target appender after having appended (or not) the value
* @throws IOException If failed to append the requested data
- * @see #appendNonEmptyValues(Appendable, String, Collection)
+ * @see #appendNonEmptyValues(Appendable, String, Collection)
*/
public static <A extends Appendable> A appendNonEmptyValues(A sb, String name, Object... values) throws IOException {
return appendNonEmptyValues(sb, name, GenericUtils.isEmpty(values) ? Collections.emptyList() : Arrays.asList(values));
}
/**
- * @param <A> The {@link Appendable} type
- * @param sb The target appender
- * @param name The property name - never {@code null}/empty
- * @param values The values to be added - one per line - ignored if {@code null}/empty
- * @return The target appender after having appended (or not) the value
+ * @param <A> The {@link Appendable} type
+ * @param sb The target appender
+ * @param name The property name - never {@code null}/empty
+ * @param values The values to be added - one per line - ignored if {@code null}/empty
+ * @return The target appender after having appended (or not) the value
* @throws IOException If failed to append the requested data
*/
public static <A extends Appendable> A appendNonEmptyValues(A sb, String name, Collection<?> values) throws IOException {
@@ -664,8 +652,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * @param entries The entries - ignored if {@code null}/empty
- * @return A {@link HostConfigEntryResolver} wrapper using the entries
+ * @param entries The entries - ignored if {@code null}/empty
+ * @return A {@link HostConfigEntryResolver} wrapper using the entries
*/
public static HostConfigEntryResolver toHostConfigEntryResolver(Collection<? extends HostConfigEntry> entries) {
if (GenericUtils.isEmpty(entries)) {
@@ -680,7 +668,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
HostConfigEntry match = (numMatches == 1) ? matches.get(0) : findBestMatch(matches);
if (match == null) {
- ValidateUtils.throwIllegalArgumentException("No best match found for %s@%s:%d out of %d matches", username1, host1, port1, numMatches);
+ ValidateUtils.throwIllegalArgumentException("No best match found for %s@%s:%d out of %d matches", username1,
+ host1, port1, numMatches);
}
return normalizeEntry(match, host1, port1, username1);
@@ -689,21 +678,21 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * @param entry The original entry - ignored if {@code null}
- * @param host The original host name / address
- * @param port The original port
- * @param username The original user name
- * @return A <U>cloned</U> entry whose values are resolved - including
- * expanding macros in the identities files
+ * @param entry The original entry - ignored if {@code null}
+ * @param host The original host name / address
+ * @param port The original port
+ * @param username The original user name
+ * @return A <U>cloned</U> entry whose values are resolved - including expanding macros in the
+ * identities files
* @throws IOException If failed to normalize the entry
- * @see #resolveHostName(String)
- * @see #resolvePort(int)
- * @see #resolveUsername(String)
- * @see #resolveIdentityFilePath(String, String, int, String)
+ * @see #resolveHostName(String)
+ * @see #resolvePort(int)
+ * @see #resolveUsername(String)
+ * @see #resolveIdentityFilePath(String, String, int, String)
*/
public static HostConfigEntry normalizeEntry(
HostConfigEntry entry, String host, int port, String username)
- throws IOException {
+ throws IOException {
if (entry == null) {
return null;
}
@@ -717,9 +706,9 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
Map<String, String> props = entry.getProperties();
if (GenericUtils.size(props) > 0) {
normal.setProperties(
- NavigableMapBuilder.<String, String>builder(String.CASE_INSENSITIVE_ORDER)
- .putAll(props)
- .build());
+ NavigableMapBuilder.<String, String> builder(String.CASE_INSENSITIVE_ORDER)
+ .putAll(props)
+ .build());
}
Collection<String> ids = entry.getIdentities();
@@ -727,7 +716,7 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
return normal;
}
- normal.setIdentities(Collections.emptyList()); // start fresh
+ normal.setIdentities(Collections.emptyList()); // start fresh
for (String id : ids) {
String path = resolveIdentityFilePath(id, host, port, username);
normal.addIdentity(path);
@@ -739,10 +728,10 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
/**
* Resolves the effective target host
*
- * @param originalName The original requested host
- * @param entryName The configured host
- * @return If the configured host entry is not {@code null}/empty
- * then it is used, otherwise the original one.
+ * @param originalName The original requested host
+ * @param entryName The configured host
+ * @return If the configured host entry is not {@code null}/empty then it is used, otherwise the
+ * original one.
*/
public static String resolveHostName(String originalName, String entryName) {
if (GenericUtils.isEmpty(entryName)) {
@@ -755,10 +744,10 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
/**
* Resolves the effective username
*
- * @param originalUser The original requested username
- * @param entryUser The configured host entry username
- * @return If the configured host entry username is not {@code null}/empty
- * then it is used, otherwise the original one.
+ * @param originalUser The original requested username
+ * @param entryUser The configured host entry username
+ * @return If the configured host entry username is not {@code null}/empty then it is used, otherwise
+ * the original one.
*/
public static String resolveUsername(String originalUser, String entryUser) {
if (GenericUtils.isEmpty(entryUser)) {
@@ -771,10 +760,9 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
/**
* Resolves the effective port to use
*
- * @param originalPort The original requested port
- * @param entryPort The configured host entry port
- * @return If the host entry port is positive, then it is used, otherwise
- * the original requested port
+ * @param originalPort The original requested port
+ * @param entryPort The configured host entry port
+ * @return If the host entry port is positive, then it is used, otherwise the original requested port
*/
public static int resolvePort(int originalPort, int entryPort) {
if (entryPort <= 0) {
@@ -797,7 +785,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
public static List<HostConfigEntry> readHostConfigEntries(InputStream inStream, boolean okToClose) throws IOException {
- try (Reader reader = new InputStreamReader(NoCloseInputStream.resolveInputStream(inStream, okToClose), StandardCharsets.UTF_8)) {
+ try (Reader reader
+ = new InputStreamReader(NoCloseInputStream.resolveInputStream(inStream, okToClose), StandardCharsets.UTF_8)) {
return readHostConfigEntries(reader, true);
}
}
@@ -811,8 +800,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
/**
* Reads configuration entries
*
- * @param rdr The {@link BufferedReader} to use
- * @return The {@link List} of read {@link HostConfigEntry}-ies
+ * @param rdr The {@link BufferedReader} to use
+ * @return The {@link List} of read {@link HostConfigEntry}-ies
* @throws IOException If failed to parse the read configuration
*/
public static List<HostConfigEntry> readHostConfigEntries(BufferedReader rdr) throws IOException {
@@ -838,8 +827,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/*
- * Some options use '=', others use ' ' - try both
- * NOTE: we do not validate the format for each option separately
+ * Some options use '=', others use ' ' - try both NOTE: we do not validate the format for each option
+ * separately
*/
pos = line.indexOf(' ');
if (pos < 0) {
@@ -862,7 +851,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
// If the all-hosts pattern is used, make sure no global section already active
for (String name : valsList) {
if (ALL_HOSTS_PATTERN.equalsIgnoreCase(name) && (globalEntry != null)) {
- throw new StreamCorruptedException("Overriding the global section with a specific one at line " + lineNumber + ": " + line);
+ throw new StreamCorruptedException(
+ "Overriding the global section with a specific one at line " + lineNumber + ": " + line);
}
}
@@ -884,9 +874,10 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
try {
curEntry.processProperty(key, valsList, false);
} catch (RuntimeException e) {
- throw new StreamCorruptedException("Failed (" + e.getClass().getSimpleName() + ")"
- + " to process line #" + lineNumber + " (" + line + ")"
- + ": " + e.getMessage());
+ throw new StreamCorruptedException(
+ "Failed (" + e.getClass().getSimpleName() + ")"
+ + " to process line #" + lineNumber + " (" + line + ")"
+ + ": " + e.getMessage());
}
}
@@ -905,9 +896,9 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
/**
* Finds the best match out of the given ones.
*
- * @param matches The available matches - ignored if {@code null}/empty
- * @return The best match or {@code null} if no matches or no best match found
- * @see #findBestMatch(Iterator)
+ * @param matches The available matches - ignored if {@code null}/empty
+ * @return The best match or {@code null} if no matches or no best match found
+ * @see #findBestMatch(Iterator)
*/
public static HostConfigEntry findBestMatch(Collection<? extends HostConfigEntry> matches) {
if (GenericUtils.isEmpty(matches)) {
@@ -920,9 +911,9 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
/**
* Finds the best match out of the given ones.
*
- * @param matches The available matches - ignored if {@code null}/empty
- * @return The best match or {@code null} if no matches or no best match found
- * @see #findBestMatch(Iterator)
+ * @param matches The available matches - ignored if {@code null}/empty
+ * @return The best match or {@code null} if no matches or no best match found
+ * @see #findBestMatch(Iterator)
*/
public static HostConfigEntry findBestMatch(Iterable<? extends HostConfigEntry> matches) {
if (matches == null) {
@@ -933,14 +924,13 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
}
/**
- * Finds the best match out of the given ones. The best match is defined as one whose
- * pattern is as <U>specific</U> as possible (if more than one match is available).
- * I.e., a non-global match is preferred over global one, and a match with no wildcards
- * is preferred over one with such a pattern.
+ * Finds the best match out of the given ones. The best match is defined as one whose pattern is as <U>specific</U>
+ * as possible (if more than one match is available). I.e., a non-global match is preferred over global one, and a
+ * match with no wildcards is preferred over one with such a pattern.
*
- * @param matches The available matches - ignored if {@code null}/empty
- * @return The best match or {@code null} if no matches or no best match found
- * @see #isSpecificHostPattern(String)
+ * @param matches The available matches - ignored if {@code null}/empty
+ * @return The best match or {@code null} if no matches or no best match found
+ * @see #isSpecificHostPattern(String)
*/
public static HostConfigEntry findBestMatch(Iterator<? extends HostConfigEntry> matches) {
if ((matches == null) || (!matches.hasNext())) {
@@ -1003,7 +993,7 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
public static void writeHostConfigEntries(
Path path, Collection<? extends HostConfigEntry> entries, OpenOption... options)
- throws IOException {
+ throws IOException {
try (OutputStream outputStream = Files.newOutputStream(path, options)) {
writeHostConfigEntries(outputStream, true, entries);
}
@@ -1011,17 +1001,19 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
public static void writeHostConfigEntries(
OutputStream outputStream, boolean okToClose, Collection<? extends HostConfigEntry> entries)
- throws IOException {
+ throws IOException {
if (GenericUtils.isEmpty(entries)) {
return;
}
- try (Writer w = new OutputStreamWriter(NoCloseOutputStream.resolveOutputStream(outputStream, okToClose), StandardCharsets.UTF_8)) {
+ try (Writer w = new OutputStreamWriter(
+ NoCloseOutputStream.resolveOutputStream(outputStream, okToClose), StandardCharsets.UTF_8)) {
appendHostConfigEntries(w, entries);
}
}
- public static <A extends Appendable> A appendHostConfigEntries(A sb, Collection<? extends HostConfigEntry> entries) throws IOException {
+ public static <A extends Appendable> A appendHostConfigEntries(A sb, Collection<? extends HostConfigEntry> entries)
+ throws IOException {
if (GenericUtils.isEmpty(entries)) {
return sb;
}
@@ -1036,8 +1028,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
/**
* Checks if this is a multi-value - allow space and comma
*
- * @param value The value - ignored if {@code null}/empty (after trimming)
- * @return A {@link List} of the encountered values
+ * @param value The value - ignored if {@code null}/empty (after trimming)
+ * @return A {@link List} of the encountered values
*/
public static List<String> parseConfigValue(String value) {
String s = GenericUtils.replaceWhitespaceAndTrim(value);
@@ -1062,14 +1054,16 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
return Collections.singletonList(s);
}
- // The file name may use the tilde syntax to refer to a user’s home directory or one of the following escape characters:
- // '%d' (local user's home directory), '%u' (local user name), '%l' (local host name), '%h' (remote host name) or '%r' (remote user name).
+ // The file name may use the tilde syntax to refer to a user’s home directory or one of the following escape
+ // characters:
+ // '%d' (local user's home directory), '%u' (local user name), '%l' (local host name), '%h' (remote host name) or
+ // '%r' (remote user name).
public static String resolveIdentityFilePath(String id, String host, int port, String username) throws IOException {
if (GenericUtils.isEmpty(id)) {
return id;
}
- String path = id.replace('/', File.separatorChar); // make sure all separators are local
+ String path = id.replace('/', File.separatorChar); // make sure all separators are local
String[] elements = GenericUtils.split(path, File.separatorChar);
StringBuilder sb = new StringBuilder(path.length() + Long.SIZE);
for (int index = 0; index < elements.length; index++) {
@@ -1087,7 +1081,7 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
curPos++;
ValidateUtils.checkTrue(curPos < elem.length(), "Missing macro modifier in %s", id);
ch = elem.charAt(curPos);
- switch(ch) {
+ switch (ch) {
case PATH_MACRO_CHAR:
sb.append(ch);
break;
@@ -1096,7 +1090,8 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
appendUserHome(sb);
break;
case LOCAL_USER_MACRO:
- sb.append(ValidateUtils.checkNotNullAndNotEmpty(OsUtils.getCurrentUser(), "No local user name value"));
+ sb.append(ValidateUtils.checkNotNullAndNotEmpty(OsUtils.getCurrentUser(),
+ "No local user name value"));
break;
case LOCAL_HOST_MACRO: {
InetAddress address = Objects.requireNonNull(InetAddress.getLocalHost(), "No local address");
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntryResolver.java b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntryResolver.java
index ce36aae..d27c053 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntryResolver.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntryResolver.java
@@ -26,19 +26,18 @@ import org.apache.sshd.common.AttributeRepository;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- * @see <A HREF="https://linux.die.net/man/5/ssh_config">ssh_config</A>
+ * @see <A HREF="https://linux.die.net/man/5/ssh_config">ssh_config</A>
*/
@FunctionalInterface
public interface HostConfigEntryResolver {
/**
- * An "empty" implementation that does not resolve any entry - i.e.,
- * uses the original entry as-is
+ * An "empty" implementation that does not resolve any entry - i.e., uses the original entry as-is
*/
HostConfigEntryResolver EMPTY = new HostConfigEntryResolver() {
@Override
public HostConfigEntry resolveEffectiveHost(
String host, int port, SocketAddress localAddress, String username, AttributeRepository context)
- throws IOException {
+ throws IOException {
return null;
}
@@ -49,23 +48,21 @@ public interface HostConfigEntryResolver {
};
/**
- * Invoked when creating a new client session in order to allow for overriding
- * of the original parameters
+ * Invoked when creating a new client session in order to allow for overriding of the original parameters
*
- * @param host The requested host - never {@code null}/empty
- * @param port The requested port
- * @param localAddress Optional binding endpoint for the local peer
- * @param username The requested username
- * @param context An optional "context" provided during the connection
- * request (to be attached to the established session if successfully connected)
- * @return A {@link HostConfigEntry} for the actual target - {@code null} if use
- * original parameters. <B>Note:</B> if any identity files are attached to the
- * configuration then they must point to <U>existing</U> locations. This means
- * that any macros such as <code>~, %d, %h</code>, etc. must be resolved <U>prior</U>
- * to returning the value
- * @throws IOException If failed to resolve the configuration
+ * @param host The requested host - never {@code null}/empty
+ * @param port The requested port
+ * @param localAddress Optional binding endpoint for the local peer
+ * @param username The requested username
+ * @param context An optional "context" provided during the connection request (to be attached to
+ * the established session if successfully connected)
+ * @return A {@link HostConfigEntry} for the actual target - {@code null} if use original parameters.
+ * <B>Note:</B> if any identity files are attached to the configuration then they must point to
+ * <U>existing</U> locations. This means that any macros such as <code>~, %d, %h</code>, etc.
+ * must be resolved <U>prior</U> to returning the value
+ * @throws IOException If failed to resolve the configuration
*/
HostConfigEntry resolveEffectiveHost(
- String host, int port, SocketAddress localAddress, String username, AttributeRepository context)
+ String host, int port, SocketAddress localAddress, String username, AttributeRepository context)
throws IOException;
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternValue.java b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternValue.java
index 50a3820..16f63d2 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternValue.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternValue.java
@@ -26,9 +26,11 @@ import org.apache.sshd.common.util.GenericUtils;
/**
* Represents a pattern definition in the <U>known_hosts</U> file
+ *
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- * @see <A HREF="https://en.wikibooks.org/wiki/OpenSSH/Client_Configuration_Files#About_the_Contents_of_the_known_hosts_Files">
- * OpenSSH cookbook - About the Contents of the known hosts Files</A>
+ * @see <A HREF=
+ * "https://en.wikibooks.org/wiki/OpenSSH/Client_Configuration_Files#About_the_Contents_of_the_known_hosts_Files">
+ * OpenSSH cookbook - About the Contents of the known hosts Files</A>
*/
public class HostPatternValue {
private Pattern pattern;
@@ -86,8 +88,10 @@ public class HostPatternValue {
try {
KnownHostHashValue.appendHostPattern(sb, purePattern, portValue);
} catch (IOException e) {
- throw new RuntimeException("Unexpected (" + e.getClass().getSimpleName() + ") failure"
- + " to append host pattern of " + purePattern + ":" + portValue + ": " + e.getMessage(), e);
+ throw new RuntimeException(
+ "Unexpected (" + e.getClass().getSimpleName() + ") failure"
+ + " to append host pattern of " + purePattern + ":" + portValue + ": " + e.getMessage(),
+ e);
}
return sb.toString();
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternsHolder.java b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternsHolder.java
index 9d90dac..17cc645 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternsHolder.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternsHolder.java
@@ -56,7 +56,8 @@ public abstract class HostPatternsHolder {
/**
* The available pattern characters
*/
- public static final String PATTERN_CHARS = new String(new char[]{WILDCARD_PATTERN, SINGLE_CHAR_PATTERN, NEGATION_CHAR_PATTERN});
+ public static final String PATTERN_CHARS
+ = new String(new char[] { WILDCARD_PATTERN, SINGLE_CHAR_PATTERN, NEGATION_CHAR_PATTERN });
/** Port value separator if non-standard port pattern used */
public static final char PORT_VALUE_DELIMITER = ':';
@@ -84,21 +85,21 @@ public abstract class HostPatternsHolder {
/**
* Checks if a given host name / address matches the entry's host pattern(s)
*
- * @param host The host name / address - ignored if {@code null}/empty
- * @param port The connection port
- * @return {@code true} if the name / address matches the pattern(s)
- * @see #isHostMatch(String, Pattern)
+ * @param host The host name / address - ignored if {@code null}/empty
+ * @param port The connection port
+ * @return {@code true} if the name / address matches the pattern(s)
+ * @see #isHostMatch(String, Pattern)
*/
public boolean isHostMatch(String host, int port) {
return isHostMatch(host, port, getPatterns());
}
/**
- * @param pattern The pattern to check - ignored if {@code null}/empty
- * @return {@code true} if the pattern is not empty and contains no wildcard characters
- * @see #WILDCARD_PATTERN
- * @see #SINGLE_CHAR_PATTERN
- * @see #SINGLE_CHAR_PATTERN
+ * @param pattern The pattern to check - ignored if {@code null}/empty
+ * @return {@code true} if the pattern is not empty and contains no wildcard characters
+ * @see #WILDCARD_PATTERN
+ * @see #SINGLE_CHAR_PATTERN
+ * @see #SINGLE_CHAR_PATTERN
*/
public static boolean isSpecificHostPattern(String pattern) {
if (GenericUtils.isEmpty(pattern)) {
@@ -118,10 +119,10 @@ public abstract class HostPatternsHolder {
/**
* Locates all the matching entries for a give host name / address
*
- * @param host The host name / address - ignored if {@code null}/empty
- * @param entries The {@link HostConfigEntry}-ies to scan - ignored if {@code null}/empty
- * @return A {@link List} of all the matching entries
- * @see #isHostMatch(String, int)
+ * @param host The host name / address - ignored if {@code null}/empty
+ * @param entries The {@link HostConfigEntry}-ies to scan - ignored if {@code null}/empty
+ * @return A {@link List} of all the matching entries
+ * @see #isHostMatch(String, int)
*/
public static List<HostConfigEntry> findMatchingEntries(String host, HostConfigEntry... entries) {
// TODO in Java-8 use Stream(s) + predicate
@@ -135,10 +136,10 @@ public abstract class HostPatternsHolder {
/**
* Locates all the matching entries for a give host name / address
*
- * @param host The host name / address - ignored if {@code null}/empty
- * @param entries The {@link HostConfigEntry}-ies to scan - ignored if {@code null}/empty
- * @return A {@link List} of all the matching entries
- * @see #isHostMatch(String, int)
+ * @param host The host name / address - ignored if {@code null}/empty
+ * @param entries The {@link HostConfigEntry}-ies to scan - ignored if {@code null}/empty
+ * @return A {@link List} of all the matching entries
+ * @see #isHostMatch(String, int)
*/
public static List<HostConfigEntry> findMatchingEntries(String host, Collection<? extends HostConfigEntry> entries) {
// TODO in Java-8 use Stream(s) + predicate
@@ -149,11 +150,11 @@ public abstract class HostPatternsHolder {
List<HostConfigEntry> matches = null;
for (HostConfigEntry entry : entries) {
if (!entry.isHostMatch(host, 0 /* any port */)) {
- continue; // debug breakpoint
+ continue; // debug breakpoint
}
if (matches == null) {
- matches = new ArrayList<>(entries.size()); // in case ALL of them match
+ matches = new ArrayList<>(entries.size()); // in case ALL of them match
}
matches.add(entry);
@@ -188,8 +189,8 @@ public abstract class HostPatternsHolder {
/*
* According to https://www.freebsd.org/cgi/man.cgi?query=ssh_config&sektion=5:
*
- * If a negated entry is matched, then the Host entry is ignored,
- * regardless of whether any other patterns on the line match.
+ * If a negated entry is matched, then the Host entry is ignored, regardless of whether any other patterns
+ * on the line match.
*/
if (negated) {
return false;
@@ -209,9 +210,9 @@ public abstract class HostPatternsHolder {
/**
* Checks if a given host name / address matches a host pattern
*
- * @param host The host name / address - ignored if {@code null}/empty
- * @param pattern The host {@link Pattern} - ignored if {@code null}
- * @return {@code true} if the name / address matches the pattern
+ * @param host The host name / address - ignored if {@code null}/empty
+ * @param pattern The host {@link Pattern} - ignored if {@code null}
+ * @return {@code true} if the name / address matches the pattern
*/
public static boolean isHostMatch(String host, Pattern pattern) {
if (GenericUtils.isEmpty(host) || (pattern == null)) {
@@ -240,17 +241,17 @@ public abstract class HostPatternsHolder {
}
/**
- * Converts a host pattern string to a regular expression matcher.
- * <B>Note:</B> pattern matching is <U>case insensitive</U>
+ * Converts a host pattern string to a regular expression matcher. <B>Note:</B> pattern matching is <U>case
+ * insensitive</U>
*
- * @param patternString The original pattern string - ignored if {@code null}/empty
- * @return The regular expression matcher {@link Pattern} and the indication
- * whether it is a negating pattern or not - {@code null} if no original string
- * @see #NON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIM
- * @see #NON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIM
- * @see #WILDCARD_PATTERN
- * @see #SINGLE_CHAR_PATTERN
- * @see #NEGATION_CHAR_PATTERN
+ * @param patternString The original pattern string - ignored if {@code null}/empty
+ * @return The regular expression matcher {@link Pattern} and the indication whether it is a negating
+ * pattern or not - {@code null} if no original string
+ * @see #NON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIM
+ * @see #NON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIM
+ * @see #WILDCARD_PATTERN
+ * @see #SINGLE_CHAR_PATTERN
+ * @see #NEGATION_CHAR_PATTERN
*/
public static HostPatternValue toPattern(CharSequence patternString) {
String pattern = GenericUtils.replaceWhitespaceAndTrim(Objects.toString(patternString, null));
@@ -267,7 +268,7 @@ public abstract class HostPatternsHolder {
ValidateUtils.checkTrue(pos > 0, "Missing non-standard port value delimiter in %s", pattern);
ValidateUtils.checkTrue(pos < (patternLen - 1), "Missing non-standard port value number in %s", pattern);
ValidateUtils.checkTrue(pattern.charAt(pos - 1) == HostPatternsHolder.NON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIM,
- "Invalid non-standard port value host pattern enclosure delimiters in %s", pattern);
+ "Invalid non-standard port value host pattern enclosure delimiters in %s", pattern);
String csPort = pattern.substring(pos + 1, patternLen);
port = Integer.parseInt(csPort);
@@ -282,8 +283,8 @@ public abstract class HostPatternsHolder {
char ch = pattern.charAt(curPos);
ValidateUtils.checkTrue(isValidPatternChar(ch), "Invalid host pattern char in %s", pattern);
- switch(ch) {
- case '.': // need to escape it
+ switch (ch) {
+ case '.': // need to escape it
sb.append('\\').append(ch);
break;
case SINGLE_CHAR_PATTERN:
@@ -306,21 +307,20 @@ public abstract class HostPatternsHolder {
}
/**
- * Checks if the given character is valid for a host pattern. Valid
- * characters are:
+ * Checks if the given character is valid for a host pattern. Valid characters are:
* <UL>
- * <LI>A-Z</LI>
- * <LI>a-z</LI>
- * <LI>0-9</LI>
- * <LI>Underscore (_)</LI>
- * <LI>Hyphen (-)</LI>
- * <LI>Dot (.)</LI>
- * <LI>The {@link #WILDCARD_PATTERN}</LI>
- * <LI>The {@link #SINGLE_CHAR_PATTERN}</LI>
+ * <LI>A-Z</LI>
+ * <LI>a-z</LI>
+ * <LI>0-9</LI>
+ * <LI>Underscore (_)</LI>
+ * <LI>Hyphen (-)</LI>
+ * <LI>Dot (.)</LI>
+ * <LI>The {@link #WILDCARD_PATTERN}</LI>
+ * <LI>The {@link #SINGLE_CHAR_PATTERN}</LI>
* </UL>
*
- * @param ch The character to validate
- * @return {@code true} if valid pattern character
+ * @param ch The character to validate
+ * @return {@code true} if valid pattern character
*/
public static boolean isValidPatternChar(char ch) {
if ((ch <= ' ') || (ch >= 0x7E)) {
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostDigest.java b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostDigest.java
index c9777df..e974f5c 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostDigest.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostDigest.java
@@ -39,8 +39,7 @@ import org.apache.sshd.common.util.ValidateUtils;
public enum KnownHostDigest implements NamedFactory<Mac> {
SHA1("1", BuiltinMacs.hmacsha1);
- public static final Set<KnownHostDigest> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(KnownHostDigest.class));
+ public static final Set<KnownHostDigest> VALUES = Collections.unmodifiableSet(EnumSet.allOf(KnownHostDigest.class));
private final String name;
private final Factory<Mac> factory;
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostEntry.java b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostEntry.java
index bfb444f..077c00d 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostEntry.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostEntry.java
@@ -46,7 +46,7 @@ import org.apache.sshd.common.util.io.NoCloseReader;
* Contains a representation of an entry in the <code>known_hosts</code> file
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- * @see <A HREF="http://www.manpagez.com/man/8/sshd/">sshd(8) man page</A>
+ * @see <A HREF="http://www.manpagez.com/man/8/sshd/">sshd(8) man page</A>
*/
public class KnownHostEntry extends HostPatternsHolder {
/**
@@ -60,8 +60,7 @@ public class KnownHostEntry extends HostPatternsHolder {
public static final String STD_HOSTS_FILENAME = "known_hosts";
private static final class LazyDefaultConfigFileHolder {
- private static final Path HOSTS_FILE =
- PublicKeyEntry.getDefaultKeysFolderPath().resolve(STD_HOSTS_FILENAME);
+ private static final Path HOSTS_FILE = PublicKeyEntry.getDefaultKeysFolderPath().resolve(STD_HOSTS_FILENAME);
private LazyDefaultConfigFileHolder() {
throw new UnsupportedOperationException("No instance allowed");
@@ -155,7 +154,8 @@ public class KnownHostEntry extends HostPatternsHolder {
}
public static List<KnownHostEntry> readKnownHostEntries(InputStream inStream, boolean okToClose) throws IOException {
- try (Reader reader = new InputStreamReader(NoCloseInputStream.resolveInputStream(inStream, okToClose), StandardCharsets.UTF_8)) {
+ try (Reader reader
+ = new InputStreamReader(NoCloseInputStream.resolveInputStream(inStream, okToClose), StandardCharsets.UTF_8)) {
return readKnownHostEntries(reader, true);
}
}
@@ -169,8 +169,8 @@ public class KnownHostEntry extends HostPatternsHolder {
/**
* Reads configuration entries
*
- * @param rdr The {@link BufferedReader} to use
- * @return The {@link List} of read {@link KnownHostEntry}-ies
+ * @param rdr The {@link BufferedReader} to use
+ * @return The {@link List} of read {@link KnownHostEntry}-ies
* @throws IOException If failed to parse the read configuration
*/
public static List<KnownHostEntry> readKnownHostEntries(BufferedReader rdr) throws IOException {
@@ -203,9 +203,10 @@ public class KnownHostEntry extends HostPatternsHolder {
entries = new ArrayList<>();
}
entries.add(entry);
- } catch (RuntimeException | Error e) { // TODO consider consulting a user callback
- throw new StreamCorruptedException("Failed (" + e.getClass().getSimpleName() + ")"
- + " to parse line #" + lineNumber + " '" + line + "': " + e.getMessage());
+ } catch (RuntimeException | Error e) { // TODO consider consulting a user callback
+ throw new StreamCorruptedException(
+ "Failed (" + e.getClass().getSimpleName() + ")" + " to parse line #" + lineNumber + " '" + line + "': "
+ + e.getMessage());
}
}
@@ -244,8 +245,7 @@ public class KnownHostEntry extends HostPatternsHolder {
line = line.substring(pos + 1).trim();
if (hostPattern.charAt(0) == KnownHostHashValue.HASHED_HOST_DELIMITER) {
- KnownHostHashValue hash =
- ValidateUtils.checkNotNull(KnownHostHashValue.parse(hostPattern),
+ KnownHostHashValue hash = ValidateUtils.checkNotNull(KnownHostHashValue.parse(hostPattern),
"Failed to extract host hash value from line=%s", data);
entry.setHashedEntry(hash);
entry.setPatterns(null);
@@ -254,8 +254,7 @@ public class KnownHostEntry extends HostPatternsHolder {
entry.setPatterns(parsePatterns(GenericUtils.split(hostPattern, ',')));
}
- AuthorizedKeyEntry key =
- ValidateUtils.checkNotNull(AuthorizedKeyEntry.parseAuthorizedKeyEntry(line),
+ AuthorizedKeyEntry key = ValidateUtils.checkNotNull(AuthorizedKeyEntry.parseAuthorizedKeyEntry(line),
"No valid key entry recovered from line=%s", data);
entry.setKeyEntry(key);
return entry;
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostHashValue.java b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostHashValue.java
index f423259..186b86b 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostHashValue.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostHashValue.java
@@ -82,9 +82,9 @@ public class KnownHostHashValue {
/**
* Checks if the host matches the hash
*
- * @param host The host name/address - ignored if {@code null}/empty
- * @param port The access port - ignored if non-positive or SSH default
- * @return {@code true} if host matches the hash
+ * @param host The host name/address - ignored if {@code null}/empty
+ * @param port The access port - ignored if non-positive or SSH default
+ * @return {@code true} if host matches the hash
* @throws RuntimeException If entry not properly initialized
*/
public boolean isHostMatch(String host, int port) {
@@ -100,8 +100,8 @@ public class KnownHostHashValue {
if (t instanceof RuntimeException) {
throw (RuntimeException) t;
}
- throw new RuntimeSshException("Failed (" + t.getClass().getSimpleName() + ")"
- + " to calculate hash value: " + t.getMessage(), t);
+ throw new RuntimeSshException(
+ "Failed (" + t.getClass().getSimpleName() + ")" + " to calculate hash value: " + t.getMessage(), t);
}
}
@@ -109,19 +109,20 @@ public class KnownHostHashValue {
public String toString() {
if ((getDigester() == null) || NumberUtils.isEmpty(getSaltValue()) || NumberUtils.isEmpty(getDigestValue())) {
return Objects.toString(getDigester(), null)
- + "-" + BufferUtils.toHex(':', getSaltValue())
- + "-" + BufferUtils.toHex(':', getDigestValue());
+ + "-" + BufferUtils.toHex(':', getSaltValue())
+ + "-" + BufferUtils.toHex(':', getDigestValue());
}
try {
return append(new StringBuilder(Byte.MAX_VALUE), this).toString();
- } catch (IOException | RuntimeException e) { // unexpected
+ } catch (IOException | RuntimeException e) { // unexpected
return e.getClass().getSimpleName() + ": " + e.getMessage();
}
}
// see http://nms.lcs.mit.edu/projects/ssh/README.hashed-hosts
- public static byte[] calculateHashValue(String host, int port, Factory<? extends Mac> factory, byte[] salt) throws Exception {
+ public static byte[] calculateHashValue(String host, int port, Factory<? extends Mac> factory, byte[] salt)
+ throws Exception {
return calculateHashValue(host, port, factory.create(), salt);
}
@@ -142,8 +143,10 @@ public class KnownHostHashValue {
try {
return appendHostPattern(new StringBuilder(host.length() + 8 /* port if necessary */), host, port).toString();
} catch (IOException e) {
- throw new RuntimeException("Unexpected (" + e.getClass().getSimpleName() + ") failure"
- + " to generate host pattern of " + host + ":" + port + ": " + e.getMessage(), e);
+ throw new RuntimeException(
+ "Unexpected (" + e.getClass().getSimpleName() + ") failure" + " to generate host pattern of " + host + ":"
+ + port + ": " + e.getMessage(),
+ e);
}
}
@@ -162,7 +165,8 @@ public class KnownHostHashValue {
}
public static <A extends Appendable> A append(A sb, KnownHostHashValue hashValue) throws IOException {
- return (hashValue == null) ? sb : append(sb, hashValue.getDigester(), hashValue.getSaltValue(), hashValue.getDigestValue());
+ return (hashValue == null)
+ ? sb : append(sb, hashValue.getDigester(), hashValue.getSaltValue(), hashValue.getDigestValue());
}
public static <A extends Appendable> A append(A sb, NamedResource factory, byte[] salt, byte[] digest) throws IOException {
@@ -185,12 +189,13 @@ public class KnownHostHashValue {
}
String[] components = GenericUtils.split(pattern, HASHED_HOST_DELIMITER);
- ValidateUtils.checkTrue(components.length == 4 /* 1st one is empty */, "Invalid hash pattern (insufficient data): %s", pattern);
- ValidateUtils.checkTrue(GenericUtils.isEmpty(components[0]), "Invalid hash pattern (unexpected extra data): %s", pattern);
+ ValidateUtils.checkTrue(components.length == 4 /* 1st one is empty */, "Invalid hash pattern (insufficient data): %s",
+ pattern);
+ ValidateUtils.checkTrue(GenericUtils.isEmpty(components[0]), "Invalid hash pattern (unexpected extra data): %s",
+ pattern);
- NamedFactory<Mac> factory =
- ValidateUtils.checkNotNull(KnownHostDigest.fromName(components[1]),
- "Invalid hash pattern (unknown digest): %s", pattern);
+ NamedFactory<Mac> factory = ValidateUtils.checkNotNull(KnownHostDigest.fromName(components[1]),
+ "Invalid hash pattern (unknown digest): %s", pattern);
Base64.Decoder decoder = Base64.getDecoder();
value.setDigester(factory);
value.setSaltValue(decoder.decode(components[2]));
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcher.java b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcher.java
index 5986e25..002b029 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcher.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcher.java
@@ -42,12 +42,12 @@ public class BuiltinClientIdentitiesWatcher extends ClientIdentitiesWatcher {
private final boolean supportedOnly;
public BuiltinClientIdentitiesWatcher(Path keysFolder, boolean supportedOnly,
- ClientIdentityLoader loader, FilePasswordProvider provider, boolean strict) {
+ ClientIdentityLoader loader, FilePasswordProvider provider, boolean strict) {
this(keysFolder, NamedResource.getNameList(BuiltinIdentities.VALUES), supportedOnly, loader, provider, strict);
}
public BuiltinClientIdentitiesWatcher(Path keysFolder, Collection<String> ids, boolean supportedOnly,
- ClientIdentityLoader loader, FilePasswordProvider provider, boolean strict) {
+ ClientIdentityLoader loader, FilePasswordProvider provider, boolean strict) {
this(keysFolder, ids, supportedOnly,
ClientIdentityLoaderHolder.loaderHolderOf(Objects.requireNonNull(loader, "No client identity loader")),
FilePasswordProviderHolder.providerHolderOf(Objects.requireNonNull(provider, "No password provider")),
@@ -55,12 +55,14 @@ public class BuiltinClientIdentitiesWatcher extends ClientIdentitiesWatcher {
}
public BuiltinClientIdentitiesWatcher(Path keysFolder, boolean supportedOnly,
- ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider, boolean strict) {
+ ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider,
+ boolean strict) {
this(keysFolder, NamedResource.getNameList(BuiltinIdentities.VALUES), supportedOnly, loader, provider, strict);
}
public BuiltinClientIdentitiesWatcher(Path keysFolder, Collection<String> ids, boolean supportedOnly,
- ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider, boolean strict) {
+ ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider,
+ boolean strict) {
super(getBuiltinIdentitiesPaths(keysFolder, ids), loader, provider, strict);
this.supportedOnly = supportedOnly;
}
@@ -72,8 +74,8 @@ public class BuiltinClientIdentitiesWatcher extends ClientIdentitiesWatcher {
@Override
public Iterable<KeyPair> loadKeys(SessionContext session) {
return isSupportedOnly()
- ? loadKeys(session, p -> isSupported(session, p))
- : super.loadKeys(session);
+ ? loadKeys(session, p -> isSupported(session, p))
+ : super.loadKeys(session);
}
protected boolean isSupported(SessionContext session, KeyPair kp) {
@@ -83,7 +85,7 @@ public class BuiltinClientIdentitiesWatcher extends ClientIdentitiesWatcher {
}
if (log.isDebugEnabled()) {
log.debug("loadKeys - remove unsupported identity={}, key-type={}, key={}",
- id, KeyUtils.getKeyType(kp), KeyUtils.getFingerPrint(kp.getPublic()));
+ id, KeyUtils.getKeyType(kp), KeyUtils.getFingerPrint(kp.getPublic()));
}
return false;
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java
index dbf9c4a..ccfec83 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java
@@ -43,12 +43,12 @@ public class ClientIdentitiesWatcher extends AbstractKeyPairProvider implements
private final Collection<ClientIdentityProvider> providers;
public ClientIdentitiesWatcher(Collection<? extends Path> paths,
- ClientIdentityLoader loader, FilePasswordProvider provider) {
+ ClientIdentityLoader loader, FilePasswordProvider provider) {
this(paths, loader, provider, true);
}
public ClientIdentitiesWatcher(Collection<? extends Path> paths,
- ClientIdentityLoader loader, FilePasswordProvider provider, boolean strict) {
+ ClientIdentityLoader loader, FilePasswordProvider provider, boolean strict) {
this(paths,
ClientIdentityLoaderHolder.loaderHolderOf(Objects.requireNonNull(loader, "No client identity loader")),
FilePasswordProviderHolder.providerHolderOf(Objects.requireNonNull(provider, "No password provider")),
@@ -56,12 +56,12 @@ public class ClientIdentitiesWatcher extends AbstractKeyPairProvider implements
}
public ClientIdentitiesWatcher(Collection<? extends Path> paths,
- ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider) {
+ ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider) {
this(paths, loader, provider, true);
}
public ClientIdentitiesWatcher(Collection<? extends Path> paths,
- ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider, boolean strict) {
+ ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider, boolean strict) {
this(buildProviders(paths, loader, provider, strict));
}
@@ -90,7 +90,7 @@ public class ClientIdentitiesWatcher extends AbstractKeyPairProvider implements
return kp;
} catch (Throwable e) {
log.warn("loadKeys({}) failed ({}) to load key: {}",
- p, e.getClass().getSimpleName(), e.getMessage());
+ p, e.getClass().getSimpleName(), e.getMessage());
if (log.isDebugEnabled()) {
log.debug("loadKeys(" + p + ") key load failure details", e);
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentity.java b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentity.java
index cc43a06..d6ac30c 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentity.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentity.java
@@ -48,7 +48,7 @@ import org.apache.sshd.common.util.io.IoUtils;
* Provides keys loading capability from the user's keys folder - e.g., {@code id_rsa}
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- * @see org.apache.sshd.common.util.security.SecurityUtils#getKeyPairResourceParser()
+ * @see org.apache.sshd.common.util.security.SecurityUtils#getKeyPairResourceParser()
*/
public final class ClientIdentity {
@@ -56,17 +56,16 @@ public final class ClientIdentity {
public static final String ID_FILE_SUFFIX = "";
- public static final Function<String, String> ID_GENERATOR =
- ClientIdentity::getIdentityFileName;
+ public static final Function<String, String> ID_GENERATOR = ClientIdentity::getIdentityFileName;
private ClientIdentity() {
throw new UnsupportedOperationException("No instance");
}
/**
- * @param name The file name - ignored if {@code null}/empty
- * @return The identity type - {@code null} if cannot determine it - e.g.,
- * does not start with the {@link #ID_FILE_PREFIX}
+ * @param name The file name - ignored if {@code null}/empty
+ * @return The identity type - {@code null} if cannot determine it - e.g., does not start with the
+ * {@link #ID_FILE_PREFIX}
*/
public static String getIdentityType(String name) {
if (GenericUtils.isEmpty(name)
@@ -83,131 +82,121 @@ public final class ClientIdentity {
}
/**
- * @param type The identity type - e.g., {@code rsa} - ignored
- * if {@code null}/empty
- * @return The matching file name for the identity - {@code null}
- * if no name
- * @see #ID_FILE_PREFIX
- * @see #ID_FILE_SUFFIX
- * @see IdentityUtils#getIdentityFileName(String, String, String)
+ * @param type The identity type - e.g., {@code rsa} - ignored if {@code null}/empty
+ * @return The matching file name for the identity - {@code null} if no name
+ * @see #ID_FILE_PREFIX
+ * @see #ID_FILE_SUFFIX
+ * @see IdentityUtils#getIdentityFileName(String, String, String)
*/
public static String getIdentityFileName(String type) {
return IdentityUtils.getIdentityFileName(ID_FILE_PREFIX, type, ID_FILE_SUFFIX);
}
/**
- * @param strict If {@code true} then files that do not have the required
- * access rights are excluded from consideration
- * @param supportedOnly If {@code true} then ignore identities that are not
- * supported internally
- * @param provider A {@link FilePasswordProvider} - may be {@code null}
- * if the loaded keys are <U>guaranteed</U> not to be encrypted. The argument
- * to {@code FilePasswordProvider#getPassword} is the path of the
- * file whose key is to be loaded
- * @param options The {@link LinkOption}s to apply when checking
- * for existence
- * @return A {@link KeyPair} for the identities - {@code null} if no identities
- * available (e.g., after filtering unsupported ones or strict permissions)
+ * @param strict If {@code true} then files that do not have the required access rights are
+ * excluded from consideration
+ * @param supportedOnly If {@code true} then ignore identities that are not supported internally
+ * @param provider A {@link FilePasswordProvider} - may be {@code null} if the loaded keys are
+ * <U>guaranteed</U> not to be encrypted. The argument to
+ * {@code FilePasswordProvider#getPassword} is the path of the file whose key is to
+ * be loaded
+ * @param options The {@link LinkOption}s to apply when checking for existence
+ * @return A {@link KeyPair} for the identities - {@code null} if no identities available
+ * (e.g., after filtering unsupported ones or strict permissions)
* @throws IOException If failed to access the file system
* @throws GeneralSecurityException If failed to load the keys
- * @see PublicKeyEntry#getDefaultKeysFolderPath()
- * @see #loadDefaultIdentities(Path, boolean, FilePasswordProvider, LinkOption...)
+ * @see PublicKeyEntry#getDefaultKeysFolderPath()
+ * @see #loadDefaultIdentities(Path, boolean, FilePasswordProvider, LinkOption...)
*/
public static KeyPairProvider loadDefaultKeyPairProvider(
boolean strict, boolean supportedOnly, FilePasswordProvider provider, LinkOption... options)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
return loadDefaultKeyPairProvider(PublicKeyEntry.getDefaultKeysFolderPath(), strict, supportedOnly, provider, options);
}
/**
- * @param dir The folder to scan for the built-in identities
- * @param strict If {@code true} then files that do not have the required
- * access rights are excluded from consideration
- * @param supportedOnly If {@code true} then ignore identities that are not
- * supported internally
- * @param provider A {@link FilePasswordProvider} - may be {@code null}
- * if the loaded keys are <U>guaranteed</U> not to be encrypted. The argument
- * to {@code FilePasswordProvider#getPassword} is the path of the
- * file whose key is to be loaded
- * @param options The {@link LinkOption}s to apply when checking
- * for existence
- * @return A {@link KeyPair} for the identities - {@code null} if no identities
- * available (e.g., after filtering unsupported ones or strict permissions)
+ * @param dir The folder to scan for the built-in identities
+ * @param strict If {@code true} then files that do not have the required access rights are
+ * excluded from consideration
+ * @param supportedOnly If {@code true} then ignore identities that are not supported internally
+ * @param provider A {@link FilePasswordProvider} - may be {@code null} if the loaded keys are
+ * <U>guaranteed</U> not to be encrypted. The argument to
+ * {@code FilePasswordProvider#getPassword} is the path of the file whose key is to
+ * be loaded
+ * @param options The {@link LinkOption}s to apply when checking for existence
+ * @return A {@link KeyPair} for the identities - {@code null} if no identities available
+ * (e.g., after filtering unsupported ones or strict permissions)
* @throws IOException If failed to access the file system
* @throws GeneralSecurityException If failed to load the keys
- * @see #loadDefaultIdentities(Path, boolean, FilePasswordProvider, LinkOption...)
- * @see IdentityUtils#createKeyPairProvider(Map, boolean)
+ * @see #loadDefaultIdentities(Path, boolean, FilePasswordProvider, LinkOption...)
+ * @see IdentityUtils#createKeyPairProvider(Map, boolean)
*/
public static KeyPairProvider loadDefaultKeyPairProvider(
Path dir, boolean strict, boolean supportedOnly, FilePasswordProvider provider, LinkOption... options)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
Map<String, KeyPair> ids = loadDefaultIdentities(dir, strict, provider, options);
return IdentityUtils.createKeyPairProvider(ids, supportedOnly);
}
/**
- * @param strict If {@code true} then files that do not have the required
- * access rights are excluded from consideration
- * @param provider A {@link FilePasswordProvider} - may be {@code null}
- * if the loaded keys are <U>guaranteed</U> not to be encrypted. The argument
- * to {@code FilePasswordProvider#getPassword} is the path of the
- * file whose key is to be loaded
- * @param options The {@link LinkOption}s to apply when checking
- * for existence
- * @return A {@link Map} of the found files where key=identity type (case
- * <U>insensitive</U>), value=the {@link KeyPair} of the identity
+ * @param strict If {@code true} then files that do not have the required access rights are
+ * excluded from consideration
+ * @param provider A {@link FilePasswordProvider} - may be {@code null} if the loaded keys are
+ * <U>guaranteed</U> not to be encrypted. The argument to
+ * {@code FilePasswordProvider#getPassword} is the path of the file whose key is to
+ * be loaded
+ * @param options The {@link LinkOption}s to apply when checking for existence
+ * @return A {@link Map} of the found files where key=identity type (case
+ * <U>insensitive</U>), value=the {@link KeyPair} of the identity
* @throws IOException If failed to access the file system
* @throws GeneralSecurityException If failed to load the keys
- * @see PublicKeyEntry#getDefaultKeysFolderPath()
- * @see #loadDefaultIdentities(Path, boolean, FilePasswordProvider, LinkOption...)
+ * @see PublicKeyEntry#getDefaultKeysFolderPath()
+ * @see #loadDefaultIdentities(Path, boolean, FilePasswordProvider, LinkOption...)
*/
public static Map<String, KeyPair> loadDefaultIdentities(
boolean strict, FilePasswordProvider provider, LinkOption... options)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
return loadDefaultIdentities(PublicKeyEntry.getDefaultKeysFolderPath(), strict, provider, options);
}
/**
- * @param dir The folder to scan for the built-in identities
- * @param strict If {@code true} then files that do not have the required
- * access rights are excluded from consideration
- * @param provider A {@link FilePasswordProvider} - may be {@code null}
- * if the loaded keys are <U>guaranteed</U> not to be encrypted. The argument
- * to {@code FilePasswordProvider#getPassword} is the path of the
- * file whose key is to be loaded
- * @param options The {@link LinkOption}s to apply when checking
- * for existence
- * @return A {@link Map} of the found files where key=identity type (case
- * <U>insensitive</U>), value=the {@link KeyPair} of the identity
+ * @param dir The folder to scan for the built-in identities
+ * @param strict If {@code true} then files that do not have the required access rights are
+ * excluded from consideration
+ * @param provider A {@link FilePasswordProvider} - may be {@code null} if the loaded keys are
+ * <U>guaranteed</U> not to be encrypted. The argument to
+ * {@code FilePasswordProvider#getPassword} is the path of the file whose key is to
+ * be loaded
+ * @param options The {@link LinkOption}s to apply when checking for existence
+ * @return A {@link Map} of the found files where key=identity type (case
+ * <U>insensitive</U>), value=the {@link KeyPair} of the identity
* @throws IOException If failed to access the file system
* @throws GeneralSecurityException If failed to load the keys
- * @see BuiltinIdentities
+ * @see BuiltinIdentities
*/
public static Map<String, KeyPair> loadDefaultIdentities(
Path dir, boolean strict, FilePasswordProvider provider, LinkOption... options)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
return loadIdentities(null, dir, strict, BuiltinIdentities.NAMES, ID_GENERATOR, provider, options);
}
/**
* Scans a folder and loads all available identity files
*
- * @param session The {@link SessionContext} for invoking this load command - may
- * be {@code null} if not invoked within a session context (e.g., offline tool or session unknown).
- * @param dir The {@link Path} of the folder to scan - ignored if not exists
- * @param strict If {@code true} then files that do not have the required
- * access rights are excluded from consideration
- * @param types The identity types - ignored if {@code null}/empty
- * @param idGenerator A {@link Function} to derive the file name
- * holding the specified type
- * @param provider A {@link FilePasswordProvider} - may be {@code null}
- * if the loaded keys are <U>guaranteed</U> not to be encrypted. The argument
- * to {@code FilePasswordProvider#getPassword} is the path of the
- * file whose key is to be loaded
- * @param options The {@link LinkOption}s to apply when checking
- * for existence
- * @return A {@link Map} of the found files where key=identity type (case
- * <U>insensitive</U>), value=the {@link KeyPair} of the identity
+ * @param session The {@link SessionContext} for invoking this load command - may be {@code null}
+ * if not invoked within a session context (e.g., offline tool or session unknown).
+ * @param dir The {@link Path} of the folder to scan - ignored if not exists
+ * @param strict If {@code true} then files that do not have the required access rights are
+ * excluded from consideration
+ * @param types The identity types - ignored if {@code null}/empty
+ * @param idGenerator A {@link Function} to derive the file name holding the specified type
+ * @param provider A {@link FilePasswordProvider} - may be {@code null} if the loaded keys are
+ * <U>guaranteed</U> not to be encrypted. The argument to
+ * {@code FilePasswordProvider#getPassword} is the path of the file whose key is to
+ * be loaded
+ * @param options The {@link LinkOption}s to apply when checking for existence
+ * @return A {@link Map} of the found files where key=identity type (case
+ * <U>insensitive</U>), value=the {@link KeyPair} of the identity
* @throws IOException If failed to access the file system
* @throws GeneralSecurityException If failed to load the keys
*/
@@ -223,22 +212,21 @@ public final class ClientIdentity {
/**
* Scans a folder for possible identity files
*
- * @param dir The {@link Path} of the folder to scan - ignored if not exists
- * @param strict If {@code true} then files that do not have the required
- * access rights are excluded from consideration
- * @param types The identity types - ignored if {@code null}/empty
- * @param idGenerator A {@link Function} to derive the file name
- * holding the specified type
- * @param options The {@link LinkOption}s to apply when checking
- * for existence
- * @return A {@link Map} of the found files where key=identity type (case
- * <U>insensitive</U>), value=the {@link Path} of the file holding the key
+ * @param dir The {@link Path} of the folder to scan - ignored if not exists
+ * @param strict If {@code true} then files that do not have the required access rights are excluded from
+ * consideration
+ * @param types The identity types - ignored if {@code null}/empty
+ * @param idGenerator A {@link Function} to derive the file name holding the specified type
+ * @param options The {@link LinkOption}s to apply when checking for existence
+ * @return A {@link Map} of the found files where key=identity type (case <U>insensitive</U>), value=the
+ * {@link Path} of the file holding the key
* @throws IOException If failed to access the file system
- * @see KeyUtils#validateStrictKeyFilePermissions(Path, LinkOption...)
+ * @see KeyUtils#validateStrictKeyFilePermissions(Path, LinkOption...)
*/
public static Map<String, Path> scanIdentitiesFolder(
- Path dir, boolean strict, Collection<String> types, Function<? super String, String> idGenerator, LinkOption... options)
- throws IOException {
+ Path dir, boolean strict, Collection<String> types, Function<? super String, String> idGenerator,
+ LinkOption... options)
+ throws IOException {
if (GenericUtils.isEmpty(types)) {
return Collections.emptyMap();
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcher.java b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcher.java
index fbc3eb3..7d5e04e 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcher.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcher.java
@@ -37,8 +37,8 @@ import org.apache.sshd.common.util.io.ModifiableFileWatcher;
import org.apache.sshd.common.util.io.resource.PathResource;
/**
- * A {@link ClientIdentityProvider} that watches a given key file re-loading
- * its contents if it is ever modified, deleted or (re-)created
+ * A {@link ClientIdentityProvider} that watches a given key file re-loading its contents if it is ever modified,
+ * deleted or (re-)created
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
@@ -62,12 +62,13 @@ public class ClientIdentityFileWatcher
}
public ClientIdentityFileWatcher(
- Path path, ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider) {
+ Path path, ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider) {
this(path, loader, provider, true);
}
public ClientIdentityFileWatcher(
- Path path, ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider, boolean strict) {
+ Path path, ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider,
+ boolean strict) {
super(path);
this.loaderHolder = Objects.requireNonNull(loader, "No client identity loader");
this.providerHolder = Objects.requireNonNull(provider, "No password provider");
@@ -95,7 +96,7 @@ public class ClientIdentityFileWatcher
return identitiesHolder.get();
}
- Iterable<KeyPair> kp = identitiesHolder.getAndSet(null); // start fresh
+ Iterable<KeyPair> kp = identitiesHolder.getAndSet(null); // start fresh
Path path = getPath();
if (!exists()) {
return identitiesHolder.get();
@@ -110,8 +111,7 @@ public class ClientIdentityFileWatcher
protected Iterable<KeyPair> reloadClientIdentities(SessionContext session, Path path)
throws IOException, GeneralSecurityException {
if (isStrict()) {
- Map.Entry<String, Object> violation =
- KeyUtils.validateStrictKeyFilePermissions(path, IoUtils.EMPTY_LINK_OPTIONS);
+ Map.Entry<String, Object> violation = KeyUtils.validateStrictKeyFilePermissions(path, IoUtils.EMPTY_LINK_OPTIONS);
if (violation != null) {
if (log.isDebugEnabled()) {
log.debug("reloadClientIdentity({}) ignore due to {}", path, violation.getKey());
@@ -132,7 +132,7 @@ public class ClientIdentityFileWatcher
PublicKey key = (kp == null) ? null : kp.getPublic();
if (key != null) {
log.trace("reloadClientIdentity({}) loaded {}-{}",
- location, KeyUtils.getKeyType(key), KeyUtils.getFingerPrint(key));
+ location, KeyUtils.getKeyType(key), KeyUtils.getFingerPrint(key));
}
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityLoader.java b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityLoader.java
index 5d089a5..9dc2189 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityLoader.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityLoader.java
@@ -44,10 +44,13 @@ import org.apache.sshd.common.util.security.SecurityUtils;
*/
public interface ClientIdentityLoader {
/**
- * <P>A default implementation that assumes a file location that <U>must</U> exist.</P>
+ * <P>
+ * A default implementation that assumes a file location that <U>must</U> exist.
+ * </P>
*
* <P>
- * <B>Note:</B> It calls {@link SecurityUtils#loadKeyPairIdentities(SessionContext, NamedResource, InputStream, FilePasswordProvider)}
+ * <B>Note:</B> It calls
+ * {@link SecurityUtils#loadKeyPairIdentities(SessionContext, NamedResource, InputStream, FilePasswordProvider)}
* </P>
*/
ClientIdentityLoader DEFAULT = new ClientIdentityLoader() {
@@ -60,7 +63,7 @@ public interface ClientIdentityLoader {
@Override
public Iterable<KeyPair> loadClientIdentities(
SessionContext session, NamedResource location, FilePasswordProvider provider)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
Path path = toPath(location);
PathResource resource = new PathResource(path);
try (InputStream inputStream = resource.openInputStream()) {
@@ -76,7 +79,8 @@ public interface ClientIdentityLoader {
private Path toPath(NamedResource location) {
Objects.requireNonNull(location, "No location provided");
- Path path = Paths.get(ValidateUtils.checkNotNullAndNotEmpty(location.getName(), "No location value for %s", location));
+ Path path = Paths
+ .get(ValidateUtils.checkNotNullAndNotEmpty(location.getName(), "No location value for %s", location));
path = path.toAbsolutePath();
path = path.normalize();
return path;
@@ -84,47 +88,45 @@ public interface ClientIdentityLoader {
};
/**
- * @param location The identity key-pair location - the actual meaning (file, URL, etc.)
- * depends on the implementation.
- * @return {@code true} if it represents a valid location - the actual meaning of
- * the validity depends on the implementation
+ * @param location The identity key-pair location - the actual meaning (file, URL, etc.) depends on the
+ * implementation.
+ * @return {@code true} if it represents a valid location - the actual meaning of the validity depends
+ * on the implementation
* @throws IOException If failed to validate the location
*/
boolean isValidLocation(NamedResource location) throws IOException;
/**
- * @param session The {@link SessionContext} for invoking this load command - may
- * be {@code null} if not invoked within a session context (e.g., offline tool).
- * @param location The identity key-pair location - the actual meaning (file, URL, etc.)
- * depends on the implementation.
- * @param provider The {@link FilePasswordProvider} to consult if the location contains
- * an encrypted identity
- * @return The loaded {@link KeyPair} - {@code null} if location is empty
- * and it is OK that it does not exist
- * @throws IOException If failed to access / process the remote location
- * @throws GeneralSecurityException If failed to convert the contents into
- * a valid identity
+ * @param session The {@link SessionContext} for invoking this load command - may be {@code null}
+ * if not invoked within a session context (e.g., offline tool).
+ * @param location The identity key-pair location - the actual meaning (file, URL, etc.) depends on
+ * the implementation.
+ * @param provider The {@link FilePasswordProvider} to consult if the location contains an
+ * encrypted identity
+ * @return The loaded {@link KeyPair} - {@code null} if location is empty and it is OK that
+ * it does not exist
+ * @throws IOException If failed to access / process the remote location
+ * @throws GeneralSecurityException If failed to convert the contents into a valid identity
*/
Iterable<KeyPair> loadClientIdentities(
- SessionContext session, NamedResource location, FilePasswordProvider provider)
+ SessionContext session, NamedResource location, FilePasswordProvider provider)
throws IOException, GeneralSecurityException;
/**
* Uses the provided {@link ClientIdentityLoader} to <U>lazy</U> load the keys locations
*
- * @param loader The loader instance to use
- * @param locations The locations to load - ignored if {@code null}/empty
- * @param passwordProvider The {@link FilePasswordProvider} to use if any
- * encrypted keys found
- * @param ignoreNonExisting Whether to ignore non existing locations as indicated
- * by {@link #isValidLocation(NamedResource)}
- * @return The {@link KeyIdentityProvider} wrapper
+ * @param loader The loader instance to use
+ * @param locations The locations to load - ignored if {@code null}/empty
+ * @param passwordProvider The {@link FilePasswordProvider} to use if any encrypted keys found
+ * @param ignoreNonExisting Whether to ignore non existing locations as indicated by
+ * {@link #isValidLocation(NamedResource)}
+ * @return The {@link KeyIdentityProvider} wrapper
*/
static KeyIdentityProvider asKeyIdentityProvider(
ClientIdentityLoader loader, Collection<? extends NamedResource> locations,
FilePasswordProvider passwordProvider, boolean ignoreNonExisting) {
return GenericUtils.isEmpty(locations)
- ? KeyIdentityProvider.EMPTY_KEYS_PROVIDER
- : new LazyClientKeyIdentityProvider(loader, locations, passwordProvider, ignoreNonExisting);
+ ? KeyIdentityProvider.EMPTY_KEYS_PROVIDER
+ : new LazyClientKeyIdentityProvider(loader, locations, passwordProvider, ignoreNonExisting);
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityLoaderHolder.java b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityLoaderHolder.java
index 922f346..d2c4785 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityLoaderHolder.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityLoaderHolder.java
@@ -25,8 +25,7 @@ package org.apache.sshd.client.config.keys;
@FunctionalInterface
public interface ClientIdentityLoaderHolder {
/**
- * @return The {@link ClientIdentityLoader} to use in order to load client
- * key pair identities - never {@code null}
+ * @return The {@link ClientIdentityLoader} to use in order to load client key pair identities - never {@code null}
*/
ClientIdentityLoader getClientIdentityLoader();
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityProvider.java b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityProvider.java
index 9d0f989..1a8fe61 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityProvider.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityProvider.java
@@ -38,46 +38,44 @@ public interface ClientIdentityProvider {
/**
* Provides a {@link KeyPair} representing the client identity
*
- * @param session The {@link SessionContext} for invoking this load command - may
- * be {@code null} if not invoked within a session context (e.g., offline tool).
- * @return The client identities - may be {@code null}/empty if no currently
- * available identity from this provider. <B>Note:</B> the provider
- * may return a <U>different</U> value every time this method is called
- * - e.g., if it is (re-)loading contents from a file.
- * @throws IOException If failed to load the identity
+ * @param session The {@link SessionContext} for invoking this load command - may be {@code null}
+ * if not invoked within a session context (e.g., offline tool).
+ * @return The client identities - may be {@code null}/empty if no currently available
+ * identity from this provider. <B>Note:</B> the provider may return a
+ * <U>different</U> value every time this method is called - e.g., if it is
+ * (re-)loading contents from a file.
+ * @throws IOException If failed to load the identity
* @throws GeneralSecurityException If failed to parse the identity
*/
Iterable<KeyPair> getClientIdentities(SessionContext session)
- throws IOException, GeneralSecurityException;
+ throws IOException, GeneralSecurityException;
/**
- * Wraps a {@link KeyPair} into a {@link ClientIdentityProvider} that
- * simply returns this value as it {@link #getClientIdentities(SessionContext)}.
+ * Wraps a {@link KeyPair} into a {@link ClientIdentityProvider} that simply returns this value as it
+ * {@link #getClientIdentities(SessionContext)}.
*
- * @param kp The {@link KeyPair} instance (including {@code null})
- * @return The wrapping provider
+ * @param kp The {@link KeyPair} instance (including {@code null})
+ * @return The wrapping provider
*/
static ClientIdentityProvider of(KeyPair kp) {
return session -> Collections.singletonList(kp);
}
/**
- * Wraps several {@link ClientIdentityProvider} into a {@link KeyPair}
- * {@link Iterable} that invokes each provider "lazily" - i.e.,
- * only when {@link Iterator#hasNext()} is invoked. This prevents password
- * protected private keys to be decrypted until they are actually needed.
+ * Wraps several {@link ClientIdentityProvider} into a {@link KeyPair} {@link Iterable} that invokes each provider
+ * "lazily" - i.e., only when {@link Iterator#hasNext()} is invoked. This prevents password protected
+ * private keys to be decrypted until they are actually needed.
*
- * @param providers The providers - ignored if {@code null}
- * @param kpExtractor The (never {@code null}) extractor of the {@link KeyPair}
- * from the {@link ClientIdentityProvider} argument. If returned pair is
- * {@code null} then next provider is queried.
- * @param filter Any further filter to apply on (non-{@code null}) key pairs
- * before returning it as the {@link Iterator#next()} result.
- * @return The wrapper {@link Iterable}. <b>Note:</b> a <u>new</u> {@link Iterator}
- * instance is returned on each {@link Iterable#iterator()} call - i.e., any encrypted
- * private key may require the user to re-enter the relevant password. If the default
- * {@code ClientIdentityFileWatcher} is used, this is not a problem since it caches
- * the decoded result (unless the file has changed).
+ * @param providers The providers - ignored if {@code null}
+ * @param kpExtractor The (never {@code null}) extractor of the {@link KeyPair} from the
+ * {@link ClientIdentityProvider} argument. If returned pair is {@code null} then next provider
+ * is queried.
+ * @param filter Any further filter to apply on (non-{@code null}) key pairs before returning it as the
+ * {@link Iterator#next()} result.
+ * @return The wrapper {@link Iterable}. <b>Note:</b> a <u>new</u> {@link Iterator} instance is returned
+ * on each {@link Iterable#iterator()} call - i.e., any encrypted private key may require the
+ * user to re-enter the relevant password. If the default {@code ClientIdentityFileWatcher} is
+ * used, this is not a problem since it caches the decoded result (unless the file has changed).
*/
static Iterable<KeyPair> lazyKeysLoader(
Iterable<? extends ClientIdentityProvider> providers,
@@ -102,18 +100,17 @@ public interface ClientIdentityProvider {
}
/**
- * Wraps several {@link ClientIdentityProvider} into a {@link KeyPair}
- * {@link Iterator} that invokes each provider "lazily" - i.e.,
- * only when {@link Iterator#hasNext()} is invoked. This prevents password
- * protected private keys to be decrypted until they are actually needed.
+ * Wraps several {@link ClientIdentityProvider} into a {@link KeyPair} {@link Iterator} that invokes each provider
+ * "lazily" - i.e., only when {@link Iterator#hasNext()} is invoked. This prevents password protected
+ * private keys to be decrypted until they are actually needed.
*
- * @param providers The providers - ignored if {@code null}
- * @param kpExtractor The (never {@code null}) extractor of the {@link KeyPair}
- * from the {@link ClientIdentityProvider} argument. If returned pair is
- * {@code null} then next provider is queried.
- * @param filter Any further filter to apply on (non-{@code null}) key pairs
- * before returning it as the {@link Iterator#next()} result.
- * @return The wrapper {@link Iterator}
+ * @param providers The providers - ignored if {@code null}
+ * @param kpExtractor The (never {@code null}) extractor of the {@link KeyPair} from the
+ * {@link ClientIdentityProvider} argument. If returned pair is {@code null} then next provider
+ * is queried.
+ * @param filter Any further filter to apply on (non-{@code null}) key pairs before returning it as the
+ * {@link Iterator#next()} result.
+ * @return The wrapper {@link Iterator}
*/
static Iterator<KeyPair> lazyKeysIterator(
Iterator<? extends ClientIdentityProvider> providers,
@@ -121,7 +118,7 @@ public interface ClientIdentityProvider {
Predicate<? super KeyPair> filter) {
Objects.requireNonNull(kpExtractor, "No key pair extractor provided");
return (providers == null)
- ? Collections.emptyIterator()
- : new LazyClientIdentityIterator(providers, kpExtractor, filter);
+ ? Collections.emptyIterator()
+ : new LazyClientIdentityIterator(providers, kpExtractor, filter);
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/DefaultClientIdentitiesWatcher.java b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/DefaultClientIdentitiesWatcher.java
index cee0af5..67430ed 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/DefaultClientIdentitiesWatcher.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/DefaultClientIdentitiesWatcher.java
@@ -40,7 +40,8 @@ public class DefaultClientIdentitiesWatcher extends BuiltinClientIdentitiesWatch
}
public DefaultClientIdentitiesWatcher(
- boolean supportedOnly, ClientIdentityLoader loader, FilePasswordProvider provider, boolean strict) {
+ boolean supportedOnly, ClientIdentityLoader loader, FilePasswordProvider provider,
+ boolean strict) {
this(supportedOnly,
ClientIdentityLoaderHolder.loaderHolderOf(Objects.requireNonNull(loader, "No client identity loader")),
FilePasswordProviderHolder.providerHolderOf(Objects.requireNonNull(provider, "No password provider")),
@@ -51,12 +52,14 @@ public class DefaultClientIdentitiesWatcher extends BuiltinClientIdentitiesWatch
this(loader, provider, true);
}
- public DefaultClientIdentitiesWatcher(ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider, boolean strict) {
+ public DefaultClientIdentitiesWatcher(ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider,
+ boolean strict) {
this(true, loader, provider, strict);
}
public DefaultClientIdentitiesWatcher(boolean supportedOnly,
- ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider, boolean strict) {
+ ClientIdentityLoaderHolder loader, FilePasswordProviderHolder provider,
+ boolean strict) {
super(PublicKeyEntry.getDefaultKeysFolderPath(), supportedOnly, loader, provider, strict);
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientIdentityIterator.java b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientIdentityIterator.java
index a3e5a2e..aaa19e2 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientIdentityIterator.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientIdentityIterator.java
@@ -29,10 +29,9 @@ import java.util.function.Predicate;
import org.apache.sshd.common.keyprovider.KeyIdentityProvider;
/**
- * Wraps several {@link ClientIdentityProvider} into a {@link KeyPair}
- * {@link Iterator} that invokes each provider "lazily" - i.e.,
- * only when {@link Iterator#hasNext()} is invoked. This prevents password
- * protected private keys to be decrypted until they are actually needed.
+ * Wraps several {@link ClientIdentityProvider} into a {@link KeyPair} {@link Iterator} that invokes each provider
+ * "lazily" - i.e., only when {@link Iterator#hasNext()} is invoked. This prevents password protected private
+ * keys to be decrypted until they are actually needed.
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
@@ -46,17 +45,17 @@ public class LazyClientIdentityIterator implements Iterator<KeyPair> {
private final Predicate<? super KeyPair> filter;
/**
- * @param providers The providers - ignored if {@code null}
- * @param kpExtractor The (never {@code null}) extractor of the {@link KeyPair}
- * from the {@link ClientIdentityProvider} argument. If returned pair is
- * {@code null} then next provider is queried.
- * @param filter Any further filter to apply on (non-{@code null}) key pairs
- * before returning it as the {@link Iterator#next()} result.
+ * @param providers The providers - ignored if {@code null}
+ * @param kpExtractor The (never {@code null}) extractor of the {@link KeyPair} from the
+ * {@link ClientIdentityProvider} argument. If returned pair is {@code null} then next provider
+ * is queried.
+ * @param filter Any further filter to apply on (non-{@code null}) key pairs before returning it as the
+ * {@link Iterator#next()} result.
*/
public LazyClientIdentityIterator(
- Iterator<? extends ClientIdentityProvider> providers,
- Function<? super ClientIdentityProvider, ? extends Iterable<? extends KeyPair>> kpExtractor,
- Predicate<? super KeyPair> filter) {
+ Iterator<? extends ClientIdentityProvider> providers,
+ Function<? super ClientIdentityProvider, ? extends Iterable<? extends KeyPair>> kpExtractor,
+ Predicate<? super KeyPair> filter) {
this.providers = providers;
this.kpExtractor = Objects.requireNonNull(kpExtractor, "No key pair extractor provided");
this.filter = filter;
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientKeyIdentityProvider.java b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientKeyIdentityProvider.java
index cd7a8e0..4d8fc5a 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientKeyIdentityProvider.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientKeyIdentityProvider.java
@@ -41,15 +41,16 @@ import org.apache.sshd.common.util.GenericUtils;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class LazyClientKeyIdentityProvider implements KeyIdentityProvider, ClientIdentityLoaderHolder, FilePasswordProviderHolder {
+public class LazyClientKeyIdentityProvider
+ implements KeyIdentityProvider, ClientIdentityLoaderHolder, FilePasswordProviderHolder {
private final ClientIdentityLoader clientIdentityLoader;
private final Collection<? extends NamedResource> locations;
private final FilePasswordProvider passwordProvider;
private final boolean ignoreNonExisting;
public LazyClientKeyIdentityProvider(
- ClientIdentityLoader loader, Collection<? extends NamedResource> locations,
- FilePasswordProvider passwordProvider, boolean ignoreNonExisting) {
+ ClientIdentityLoader loader, Collection<? extends NamedResource> locations,
+ FilePasswordProvider passwordProvider, boolean ignoreNonExisting) {
this.clientIdentityLoader = Objects.requireNonNull(loader, "No client identity loader provided");
this.locations = locations;
this.passwordProvider = passwordProvider;
@@ -106,8 +107,10 @@ public class LazyClientKeyIdentityProvider implements KeyIdentityProvider, Clien
try {
ids = loadClientIdentities(session, l);
} catch (IOException | GeneralSecurityException e) {
- throw new RuntimeException("Failed (" + e.getClass().getSimpleName() + ")"
- + " to load key from " + l.getName() + ": " + e.getMessage(), e);
+ throw new RuntimeException(
+ "Failed (" + e.getClass().getSimpleName() + ")"
+ + " to load key from " + l.getName() + ": " + e.getMessage(),
+ e);
}
currentIdentities = (ids == null) ? null : ids.iterator();
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/AttributeRepository.java b/sshd-common/src/main/java/org/apache/sshd/common/AttributeRepository.java
index 18caaa4..bd9e561 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/AttributeRepository.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/AttributeRepository.java
@@ -33,13 +33,13 @@ import org.apache.sshd.common.util.GenericUtils;
public interface AttributeRepository {
/**
* <P>
- * Type safe key for storage of user attributes. Typically it is used as a static
- * variable that is shared between the producer and the consumer. To further
- * restrict access the setting or getting it from the store one can add static
- * {@code get/set methods} e.g:
+ * Type safe key for storage of user attributes. Typically it is used as a static variable that is shared between
+ * the producer and the consumer. To further restrict access the setting or getting it from the store one can add
+ * static {@code get/set methods} e.g:
* </P>
*
- * <pre><code>
+ * <pre>
+ * <code>
* public static final AttributeKey<MyValue> MY_KEY = new AttributeKey<MyValue>();
*
* public static MyValue getMyValue(Session s) {
@@ -49,10 +49,11 @@ public interface AttributeRepository {
* public static void setMyValue(Session s, MyValue value) {
* s.setAttribute(MY_KEY, value);
* }
- * </code></pre>
+ * </code>
+ * </pre>
*
- * @param <T> type of value stored in the attribute.
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ * @param <T> type of value stored in the attribute.
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
// CHECKSTYLE:OFF
class AttributeKey<T> {
@@ -70,28 +71,26 @@ public interface AttributeRepository {
/**
* Returns the value of the user-defined attribute.
*
- * @param <T> The generic attribute type
- * @param key The key of the attribute; must not be {@code null}.
- * @return {@code null} if there is no value associated with the specified key
+ * @param <T> The generic attribute type
+ * @param key The key of the attribute; must not be {@code null}.
+ * @return {@code null} if there is no value associated with the specified key
*/
<T> T getAttribute(AttributeKey<T> key);
/**
- * Attempts to resolve the associated value by going up the store's
- * hierarchy (if any)
+ * Attempts to resolve the associated value by going up the store's hierarchy (if any)
*
- * @param <T> The generic attribute type
- * @param key The key of the attribute; must not be {@code null}.
- * @return {@code null} if there is no value associated with the specified key
- * either in this repository or any of its ancestors (if any available)
+ * @param <T> The generic attribute type
+ * @param key The key of the attribute; must not be {@code null}.
+ * @return {@code null} if there is no value associated with the specified key either in this repository or any
+ * of its ancestors (if any available)
*/
default <T> T resolveAttribute(AttributeKey<T> key) {
return getAttribute(key);
}
/**
- * @return A {@link Collection} <u>snapshot</u> of all the currently registered
- * attributes in the repository
+ * @return A {@link Collection} <u>snapshot</u> of all the currently registered attributes in the repository
*/
Collection<AttributeKey<?>> attributeKeys();
@@ -118,8 +117,8 @@ public interface AttributeRepository {
@Override
public Collection<AttributeKey<?>> attributeKeys() {
return GenericUtils.isEmpty(attributes)
- ? Collections.emptySet()
- : new HashSet<>(attributes.keySet());
+ ? Collections.emptySet()
+ : new HashSet<>(attributes.keySet());
}
@Override
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/AttributeStore.java b/sshd-common/src/main/java/org/apache/sshd/common/AttributeStore.java
index 0df4ad5..8639793 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/AttributeStore.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/AttributeStore.java
@@ -29,17 +29,15 @@ import java.util.function.Function;
*/
public interface AttributeStore extends AttributeRepository {
/**
- * If the specified key is not already associated with a value (or is mapped
- * to {@code null}), attempts to compute its value using the given mapping
- * function and enters it into this map unless {@code null}.
+ * If the specified key is not already associated with a value (or is mapped to {@code null}), attempts to compute
+ * its value using the given mapping function and enters it into this map unless {@code null}.
*
- * @param <T> The generic attribute type
- * @param key The key of the attribute; must not be {@code null}.
- * @param resolver The (never {@code null}) mapping function to use if value
- * not already mapped. If returns {@code null} then value is not mapped to
- * the provided key.
- * @return The resolved value - {@code null} if value not mapped and resolver
- * did not return a non-{@code null} value for it
+ * @param <T> The generic attribute type
+ * @param key The key of the attribute; must not be {@code null}.
+ * @param resolver The (never {@code null}) mapping function to use if value not already mapped. If returns
+ * {@code null} then value is not mapped to the provided key.
+ * @return The resolved value - {@code null} if value not mapped and resolver did not return a
+ * non-{@code null} value for it
*/
default <T> T computeAttributeIfAbsent(
AttributeKey<T> key, Function<? super AttributeKey<T>, ? extends T> resolver) {
@@ -62,19 +60,19 @@ public interface AttributeStore extends AttributeRepository {
/**
* Sets a user-defined attribute.
*
- * @param <T> The generic attribute type
- * @param key The key of the attribute; must not be {@code null}.
- * @param value The value of the attribute; must not be {@code null}.
- * @return The old value of the attribute; {@code null} if it is new.
+ * @param <T> The generic attribute type
+ * @param key The key of the attribute; must not be {@code null}.
+ * @param value The value of the attribute; must not be {@code null}.
+ * @return The old value of the attribute; {@code null} if it is new.
*/
<T> T setAttribute(AttributeKey<T> key, T value);
/**
* Removes the user-defined attribute
*
- * @param <T> The generic attribute type
- * @param key The key of the attribute; must not be {@code null}.
- * @return The removed value; {@code null} if no previous value
+ * @param <T> The generic attribute type
+ * @param key The key of the attribute; must not be {@code null}.
+ * @return The removed value; {@code null} if no previous value
*/
<T> T removeAttribute(AttributeKey<T> key);
@@ -83,4 +81,3 @@ public interface AttributeStore extends AttributeRepository {
*/
void clearAttributes();
}
-
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/BuiltinFactory.java b/sshd-common/src/main/java/org/apache/sshd/common/BuiltinFactory.java
index 33b53a9..b10fca1 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/BuiltinFactory.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/BuiltinFactory.java
@@ -27,8 +27,8 @@ import org.apache.sshd.common.util.GenericUtils;
/**
* A named optional factory.
*
- * @param <T> The create object instance type
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ * @param <T> The create object instance type
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public interface BuiltinFactory<T> extends NamedFactory<T>, OptionalFeature {
static <T, E extends BuiltinFactory<T>> List<NamedFactory<T>> setUpFactories(
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/Closeable.java b/sshd-common/src/main/java/org/apache/sshd/common/Closeable.java
index f4f9310..064c1e9 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/Closeable.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/Closeable.java
@@ -27,18 +27,17 @@ import org.apache.sshd.common.future.CloseFuture;
import org.apache.sshd.common.future.SshFutureListener;
/**
- * A {@code Closeable} is a resource that can be closed.
- * The close method is invoked to release resources that the object is
- * holding. The user can pre-register listeners to be notified
- * when resource close is completed (successfully or otherwise)
+ * A {@code Closeable} is a resource that can be closed. The close method is invoked to release resources that the
+ * object is holding. The user can pre-register listeners to be notified when resource close is completed (successfully
+ * or otherwise)
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public interface Closeable extends Channel {
/**
- * Timeout (milliseconds) for waiting on a {@link CloseFuture} to successfully
- * complete its action.
+ * Timeout (milliseconds) for waiting on a {@link CloseFuture} to successfully complete its action.
+ *
* @see #DEFAULT_CLOSE_WAIT_TIMEOUT
*/
String CLOSE_WAIT_TIMEOUT = "sshd-close-wait-time";
@@ -49,21 +48,18 @@ public interface Closeable extends Channel {
long DEFAULT_CLOSE_WAIT_TIMEOUT = TimeUnit.SECONDS.toMillis(15L);
/**
- * Close this resource asynchronously and return a future.
- * Resources support two closing modes: a graceful mode
- * which will cleanly close the resource and an immediate mode
- * which will close the resources abruptly.
+ * Close this resource asynchronously and return a future. Resources support two closing modes: a graceful mode
+ * which will cleanly close the resource and an immediate mode which will close the resources abruptly.
*
- * @param immediately <code>true</code> if the resource should be shut down abruptly,
- * <code>false</code> for a graceful close
- * @return a {@link CloseFuture} representing the close request
+ * @param immediately <code>true</code> if the resource should be shut down abruptly, <code>false</code> for a
+ * graceful close
+ * @return a {@link CloseFuture} representing the close request
*/
CloseFuture close(boolean immediately);
/**
- * Pre-register a listener to be informed when resource is closed. If
- * resource is already closed, the listener will be invoked immediately
- * and not registered for future notification
+ * Pre-register a listener to be informed when resource is closed. If resource is already closed, the listener will
+ * be invoked immediately and not registered for future notification
*
* @param listener The notification {@link SshFutureListener} - never {@code null}
*/
@@ -72,8 +68,8 @@ public interface Closeable extends Channel {
/**
* Remove a pre-registered close event listener
*
- * @param listener The register {@link SshFutureListener} - never {@code null}.
- * Ignored if not registered or resource already closed
+ * @param listener The register {@link SshFutureListener} - never {@code null}. Ignored if not registered or
+ * resource already closed
*/
void removeCloseFutureListener(SshFutureListener<CloseFuture> listener);
@@ -85,9 +81,8 @@ public interface Closeable extends Channel {
boolean isClosed();
/**
- * Returns <code>true</code> if the {@link #close(boolean)} method
- * has been called. Note that this method will return <code>true</code>
- * even if this {@link #isClosed()} returns <code>true</code>.
+ * Returns <code>true</code> if the {@link #close(boolean)} method has been called. Note that this method will
+ * return <code>true</code> even if this {@link #isClosed()} returns <code>true</code>.
*
* @return <code>true</code> if closing
*/
@@ -105,8 +100,8 @@ public interface Closeable extends Channel {
static long getMaxCloseWaitTime(PropertyResolver resolver) {
return (resolver == null)
- ? DEFAULT_CLOSE_WAIT_TIMEOUT
- : resolver.getLongProperty(CLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT);
+ ? DEFAULT_CLOSE_WAIT_TIMEOUT
+ : resolver.getLongProperty(CLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT);
}
static void close(Closeable closeable) throws IOException {
@@ -117,8 +112,8 @@ public interface Closeable extends Channel {
if ((!closeable.isClosed()) && (!closeable.isClosing())) {
CloseFuture future = closeable.close(true);
long maxWait = (closeable instanceof PropertyResolver)
- ? getMaxCloseWaitTime((PropertyResolver) closeable)
- : DEFAULT_CLOSE_WAIT_TIMEOUT;
+ ? getMaxCloseWaitTime((PropertyResolver) closeable)
+ : DEFAULT_CLOSE_WAIT_TIMEOUT;
boolean successful = future.await(maxWait);
if (!successful) {
throw new SocketTimeoutException("Failed to receive closure confirmation within " + maxWait + " millis");
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/Factory.java b/sshd-common/src/main/java/org/apache/sshd/common/Factory.java
index 93b351c..b8ace58 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/Factory.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/Factory.java
@@ -23,8 +23,8 @@ import java.util.function.Supplier;
/**
* Factory is a simple interface that is used to create other objects.
*
- * @param <T> type of object this factory will create
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ * @param <T> type of object this factory will create
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
@FunctionalInterface
public interface Factory<T> extends Supplier<T> {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/NamedFactory.java b/sshd-common/src/main/java/org/apache/sshd/common/NamedFactory.java
index 024c327..566e5f2 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/NamedFactory.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/NamedFactory.java
@@ -24,25 +24,23 @@ import java.util.function.Function;
import java.util.stream.Collectors;
/**
- * A named factory is a factory identified by a name.
- * Such names are used mainly in the algorithm negotiation at the beginning of the SSH connection.
+ * A named factory is a factory identified by a name. Such names are used mainly in the algorithm negotiation at the
+ * beginning of the SSH connection.
*
- * @param <T> The create object instance type
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ * @param <T> The create object instance type
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public interface NamedFactory<T> extends Factory<T>, NamedResource {
/**
- * Create an instance of the specified name by looking up the needed factory
- * in the list.
+ * Create an instance of the specified name by looking up the needed factory in the list.
*
- * @param factories list of available factories
- * @param name the factory name to use
- * @param <T> type of object to create
- * @return a newly created object or {@code null} if the factory is not in the list
+ * @param factories list of available factories
+ * @param name the factory name to use
+ * @param <T> type of object to create
+ * @return a newly created object or {@code null} if the factory is not in the list
*/
static <T> T create(Collection<? extends NamedFactory<? extends T>> factories, String name) {
- NamedFactory<? extends T> f =
- NamedResource.findByName(name, String.CASE_INSENSITIVE_ORDER, factories);
+ NamedFactory<? extends T> f = NamedResource.findByName(name, String.CASE_INSENSITIVE_ORDER, factories);
if (f != null) {
return f.create();
} else {
@@ -53,15 +51,15 @@ public interface NamedFactory<T> extends Factory<T>, NamedResource {
static <S extends OptionalFeature, E extends NamedResource> List<E> setUpTransformedFactories(
boolean ignoreUnsupported, Collection<? extends S> preferred, Function<? super S, ? extends E> xform) {
return preferred.stream()
- .filter(f -> ignoreUnsupported || f.isSupported())
- .map(xform)
- .collect(Collectors.toList());
+ .filter(f -> ignoreUnsupported || f.isSupported())
+ .map(xform)
+ .collect(Collectors.toList());
}
static <E extends NamedResource & OptionalFeature> List<E> setUpBuiltinFactories(
boolean ignoreUnsupported, Collection<? extends E> preferred) {
return preferred.stream()
- .filter(f -> ignoreUnsupported || f.isSupported())
- .collect(Collectors.toList());
+ .filter(f -> ignoreUnsupported || f.isSupported())
+ .collect(Collectors.toList());
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/NamedResource.java b/sshd-common/src/main/java/org/apache/sshd/common/NamedResource.java
index c2299f1..6421539 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/NamedResource.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/NamedResource.java
@@ -38,11 +38,9 @@ public interface NamedResource {
Function<NamedResource, String> NAME_EXTRACTOR = input -> input == null ? null : input.getName();
/**
- * Compares 2 {@link NamedResource}s according to their {@link #getName()}
- * value case <U>insensitive</U>
+ * Compares 2 {@link NamedResource}s according to their {@link #getName()} value case <U>insensitive</U>
*/
- Comparator<NamedResource> BY_NAME_COMPARATOR =
- Comparator.comparing(NAME_EXTRACTOR, String.CASE_INSENSITIVE_ORDER);
+ Comparator<NamedResource> BY_NAME_COMPARATOR = Comparator.comparing(NAME_EXTRACTOR, String.CASE_INSENSITIVE_ORDER);
/**
* @return The resource name
@@ -50,17 +48,17 @@ public interface NamedResource {
String getName();
/**
- * @param resources The named resources
- * @return A {@link List} of all the factories names - in same order
- * as they appear in the input collection
+ * @param resources The named resources
+ * @return A {@link List} of all the factories names - in same order as they appear in the input
+ * collection
*/
static List<String> getNameList(Collection<? extends NamedResource> resources) {
return GenericUtils.map(resources, NamedResource::getName);
}
/**
- * @param resources list of available resources
- * @return A comma separated list of factory names
+ * @param resources list of available resources
+ * @return A comma separated list of factory names
*/
static String getNames(Collection<? extends NamedResource> resources) {
Collection<String> nameList = getNameList(resources);
@@ -70,12 +68,12 @@ public interface NamedResource {
/**
* Remove the resource identified by the name from the list.
*
- * @param <R> The generic resource type
- * @param name Name of the resource - ignored if {@code null}/empty
- * @param c The {@link Comparator} to decide whether the {@link NamedResource#getName()}
- * matches the <tt>name</tt> parameter
- * @param resources The {@link NamedResource} to check - ignored if {@code null}/empty
- * @return the removed resource from the list or {@code null} if not in the list
+ * @param <R> The generic resource type
+ * @param name Name of the resource - ignored if {@code null}/empty
+ * @param c The {@link Comparator} to decide whether the {@link NamedResource#getName()} matches the
+ * <tt>name</tt> parameter
+ * @param resources The {@link NamedResource} to check - ignored if {@code null}/empty
+ * @return the removed resource from the list or {@code null} if not in the list
*/
static <R extends NamedResource> R removeByName(
String name, Comparator<? super String> c, Collection<? extends R> resources) {
@@ -87,29 +85,29 @@ public interface NamedResource {
}
/**
- * @param <R> The generic resource type
- * @param name Name of the resource - ignored if {@code null}/empty
- * @param c The {@link Comparator} to decide whether the {@link NamedResource#getName()}
- * matches the <tt>name</tt> parameter
- * @param resources The {@link NamedResource} to check - ignored if {@code null}/empty
- * @return The <U>first</U> resource whose name matches the parameter (by invoking
- * {@link Comparator#compare(Object, Object)} - {@code null} if no match found
+ * @param <R> The generic resource type
+ * @param name Name of the resource - ignored if {@code null}/empty
+ * @param c The {@link Comparator} to decide whether the {@link NamedResource#getName()} matches the
+ * <tt>name</tt> parameter
+ * @param resources The {@link NamedResource} to check - ignored if {@code null}/empty
+ * @return The <U>first</U> resource whose name matches the parameter (by invoking
+ * {@link Comparator#compare(Object, Object)} - {@code null} if no match found
*/
static <R extends NamedResource> R findByName(
String name, Comparator<? super String> c, Collection<? extends R> resources) {
return GenericUtils.isEmpty(name)
- ? null
- : GenericUtils.stream(resources)
- .filter(r -> c.compare(name, r.getName()) == 0)
- .findFirst()
- .orElse(null);
+ ? null
+ : GenericUtils.stream(resources)
+ .filter(r -> c.compare(name, r.getName()) == 0)
+ .findFirst()
+ .orElse(null);
}
/**
* Wraps a name value inside a {@link NamedResource}
*
- * @param name The name value to wrap
- * @return The wrapper instance
+ * @param name The name value to wrap
+ * @return The wrapper instance
*/
static NamedResource ofName(String name) {
return new NamedResource() {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolver.java b/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolver.java
index 09363c5..64ddffc 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolver.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolver.java
@@ -24,14 +24,12 @@ import java.util.Collections;
import java.util.Map;
/**
- * Indicates an entity that can be configured using properties. The properties
- * are simple name-value pairs where the actual value type depends on the
- * property. Some automatic conversions may be available - e.g., from a string
- * to a numeric or {@code boolean} value, or from {@code int} to {@code long},
- * etc.. <B>Note:</B> implementations may decide to use case <U>insensitive</U>
- * property names, therefore it is <U><B>highly discouraged</B></U> to use names
- * that differ from each other only in case sensitivity. Also, implementations
- * may choose to trim whitespaces, thus such are also highly discouraged.
+ * Indicates an entity that can be configured using properties. The properties are simple name-value pairs where the
+ * actual value type depends on the property. Some automatic conversions may be available - e.g., from a string to a
+ * numeric or {@code boolean} value, or from {@code int} to {@code long}, etc.. <B>Note:</B> implementations may decide
+ * to use case <U>insensitive</U> property names, therefore it is <U><B>highly discouraged</B></U> to use names that
+ * differ from each other only in case sensitivity. Also, implementations may choose to trim whitespaces, thus such are
+ * also highly discouraged.
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
@@ -57,33 +55,29 @@ public interface PropertyResolver {
};
/**
- * @return The parent resolver that can be used to query for missing
- * properties - {@code null} if no parent
+ * @return The parent resolver that can be used to query for missing properties - {@code null} if no parent
*/
PropertyResolver getParentPropertyResolver();
/**
* <P>
- * A map of properties that can be used to configure the SSH server or
- * client. This map will never be changed by either the server or client and
- * is not supposed to be changed at runtime (changes are not bound to have
- * any effect on a running client or server), though it may affect the
- * creation of sessions later as these values are usually not cached.
+ * A map of properties that can be used to configure the SSH server or client. This map will never be changed by
+ * either the server or client and is not supposed to be changed at runtime (changes are not bound to have any
+ * effect on a running client or server), though it may affect the creation of sessions later as these values are
+ * usually not cached.
* </P>
*
* <P>
- * <B>Note:</B> the <U>type</U> of the mapped property should match the
- * expected configuration value type - {@code Long, Integer, Boolean,
- * String}, etc.... If it doesn't, the {@code toString()} result of the
- * mapped value is used to convert it to the required type. E.g., if the
- * mapped value is the <U>string</U> "1234" and the expected value
- * is a {@code long} then it will be parsed into one. Also, if the mapped
- * value is an {@code Integer} but a {@code long} is expected, then it will
- * be converted into one.
+ * <B>Note:</B> the <U>type</U> of the mapped property should match the expected configuration value type -
+ * {@code Long, Integer, Boolean,
+ * String}, etc.... If it doesn't, the {@code toString()} result of the mapped value is used to convert it to the
+ * required type. E.g., if the mapped value is the <U>string</U> "1234" and the expected value is a
+ * {@code long} then it will be parsed into one. Also, if the mapped value is an {@code Integer} but a {@code long}
+ * is expected, then it will be converted into one.
* </P>
*
- * @return a valid <code>Map</code> containing configuration values, never {@code null}.
- * <b>Note:</b> may be immutable.
+ * @return a valid <code>Map</code> containing configuration values, never {@code null}. <b>Note:</b> may be
+ * immutable.
*/
Map<String, Object> getProperties();
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolverUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolverUtils.java
index 280c447..2d3ecea 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolverUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolverUtils.java
@@ -41,39 +41,37 @@ public final class PropertyResolverUtils {
/**
* Case <U>insensitive</U> {@link NavigableSet} of values considered {@code true} by {@link #parseBoolean(String)}
*/
- public static final NavigableSet<String> TRUE_VALUES =
- Collections.unmodifiableNavigableSet(
+ public static final NavigableSet<String> TRUE_VALUES = Collections.unmodifiableNavigableSet(
GenericUtils.asSortedSet(
- String.CASE_INSENSITIVE_ORDER, "true", "t", "yes", "y", "on"));
+ String.CASE_INSENSITIVE_ORDER, "true", "t", "yes", "y", "on"));
/**
* Case <U>insensitive</U> {@link NavigableSet} of values considered {@code false} by {@link #parseBoolean(String)}
*/
- public static final NavigableSet<String> FALSE_VALUES =
- Collections.unmodifiableNavigableSet(
+ public static final NavigableSet<String> FALSE_VALUES = Collections.unmodifiableNavigableSet(
GenericUtils.asSortedSet(
- String.CASE_INSENSITIVE_ORDER, "false", "f", "no", "n", "off"));
+ String.CASE_INSENSITIVE_ORDER, "false", "f", "no", "n", "off"));
private PropertyResolverUtils() {
throw new UnsupportedOperationException("No instance allowed");
}
/**
- * @param v Value to examine
- * @return {@code true} if equals to {@value #NONE_VALUE} - case <U>insensitive</U>
+ * @param v Value to examine
+ * @return {@code true} if equals to {@value #NONE_VALUE} - case <U>insensitive</U>
*/
public static boolean isNoneValue(String v) {
return NONE_VALUE.equalsIgnoreCase(v);
}
/**
- * @param resolver The {@link PropertyResolver} instance - ignored if {@code null}
- * @param name The property name
- * @param defaultValue The default value to return if the specified property
- * does not exist in the properties map
- * @return The resolved property
+ * @param resolver The {@link PropertyResolver} instance - ignored if {@code null}
+ * @param name The property name
+ * @param defaultValue The default value to return if the specified property does not exist in the
+ * properties map
+ * @return The resolved property
* @throws NumberFormatException if malformed value
- * @see #toLong(Object, long)
+ * @see #toLong(Object, long)
*/
public static long getLongProperty(PropertyResolver resolver, String name, long defaultValue) {
return toLong(resolvePropertyValue(resolver, name), defaultValue);
@@ -86,41 +84,35 @@ public final class PropertyResolverUtils {
/**
* Converts a generic object value to a {@code long} if possible:
* <UL>
- * <LI>
- * If value is {@code null} the default is returned
- * </LI>
+ * <LI>If value is {@code null} the default is returned</LI>
*
- * <LI>
- * If value is a {@link Number} then its {@link Number#longValue()} is returned
- * </LI>
+ * <LI>If value is a {@link Number} then its {@link Number#longValue()} is returned</LI>
*
- * <LI>
- * Otherwise, the value's {@code toString()} is parsed as a {@code long}
- * </LI>
+ * <LI>Otherwise, the value's {@code toString()} is parsed as a {@code long}</LI>
* </UL>
*
- * @param value The resolved value - may be {@code null}
- * @param defaultValue The default to use if {@code null} resolved value
- * @return The resolved value
+ * @param value The resolved value - may be {@code null}
+ * @param defaultValue The default to use if {@code null} resolved value
+ * @return The resolved value
* @throws NumberFormatException if malformed value
- * @see Long#parseLong(String)
+ * @see Long#parseLong(String)
*/
public static long toLong(Object value, long defaultValue) {
if (value == null) {
return defaultValue;
} else if (value instanceof Number) {
return ((Number) value).longValue();
- } else { // we parse the string in case it is not a valid long value
+ } else { // we parse the string in case it is not a valid long value
return Long.parseLong(value.toString());
}
}
/**
- * @param resolver The {@link PropertyResolver} instance - ignored if {@code null}
- * @param name The property name
- * @return The {@link Long} value or {@code null} if property not found
+ * @param resolver The {@link PropertyResolver} instance - ignored if {@code null}
+ * @param name The property name
+ * @return The {@link Long} value or {@code null} if property not found
* @throws NumberFormatException if malformed value
- * @see #toLong(Object)
+ * @see #toLong(Object)
*/
public static Long getLong(PropertyResolver resolver, String name) {
return toLong(resolvePropertyValue(resolver, name));
@@ -133,29 +125,20 @@ public final class PropertyResolverUtils {
/**
* Converts a generic object into a {@link Long}:
* <UL>
- * <LI>
- * If the value is {@code null} then returns {@code null}.
- * </LI>
+ * <LI>If the value is {@code null} then returns {@code null}.</LI>
*
- * <LI>
- * If the value is already a {@link Long} then it is returned as such.
- * </LI>
-
- * <LI>
- * If value is a {@link Number} then its {@link Number#longValue()} is
- * wrapped as a {@link Long}
- * </LI>
+ * <LI>If the value is already a {@link Long} then it is returned as such.</LI>
+ *
+ * <LI>If value is a {@link Number} then its {@link Number#longValue()} is wrapped as a {@link Long}</LI>
*
- * <LI>
- * Otherwise, the value's {@code toString()} is parsed as a {@link Long}
- * </LI>
+ * <LI>Otherwise, the value's {@code toString()} is parsed as a {@link Long}</LI>
* </UL>
*
- * @param value The resolved value - may be {@code null}
- * @return The {@link Long} value or {@code null} if property not found
+ * @param value The resolved value - may be {@code null}
+ * @return The {@link Long} value or {@code null} if property not found
* @throws NumberFormatException if malformed value
- * @see Long#valueOf(long)
- * @see Long#valueOf(String)
+ * @see Long#valueOf(long)
+ * @see Long#valueOf(String)
*/
public static Long toLong(Object value) {
if (value == null) {
@@ -164,7 +147,7 @@ public final class PropertyResolverUtils {
return (Long) value;
} else if (value instanceof Number) {
return ((Number) value).longValue();
- } else { // we parse the string in case it is not a valid long value
+ } else { // we parse the string in case it is not a valid long value
return Long.valueOf(value.toString());
}
}
@@ -172,32 +155,30 @@ public final class PropertyResolverUtils {
/**
* Converts an enumerated configuration value:
* <UL>
- * <P><LI>
- * If value is {@code null} then return {@code null}
- * </LI></P>
+ * <P>
+ * <LI>If value is {@code null} then return {@code null}</LI>
+ * </P>
*
- * <P><LI>
- * If value already of the expected type then simply
- * cast and return it.
- * </LI></P>
+ * <P>
+ * <LI>If value already of the expected type then simply cast and return it.</LI>
+ * </P>
*
- * <P><LI>
- * If value is a {@link CharSequence} then convert it
- * to a string and look for a matching enumerated value
- * name - case <U>insensitive</U>.
- * </LI></P>>
+ * <P>
+ * <LI>If value is a {@link CharSequence} then convert it to a string and look for a matching enumerated value name
+ * - case <U>insensitive</U>.</LI>
+ * </P>
+ * >
* </UL>
*
- * @param <E> Type of enumerated value
- * @param enumType The enumerated class type
- * @param value The configured value - ignored if {@code null}
- * @param failIfNoMatch Whether to fail if no matching name found
- * @param available The available values to compare the name
- * @return The matching enumerated value - {@code null} if no match found
- * @throws IllegalArgumentException If value is neither {@code null},
- * nor the enumerated type nor a {@link CharSequence}
- * @throws NoSuchElementException If no matching string name found and
- * <tt>failIfNoMatch</tt> is {@code true}
+ * @param <E> Type of enumerated value
+ * @param enumType The enumerated class type
+ * @param value The configured value - ignored if {@code null}
+ * @param failIfNoMatch Whether to fail if no matching name found
+ * @param available The available values to compare the name
+ * @return The matching enumerated value - {@code null} if no match found
+ * @throws IllegalArgumentException If value is neither {@code null}, nor the enumerated type nor a
+ * {@link CharSequence}
+ * @throws NoSuchElementException If no matching string name found and <tt>failIfNoMatch</tt> is {@code true}
*/
public static <E extends Enum<E>> E toEnum(
Class<E> enumType, Object value, boolean failIfNoMatch, Collection<E> available) {
@@ -222,7 +203,7 @@ public final class PropertyResolverUtils {
return null;
} else {
throw new IllegalArgumentException(
- "Bad value type for enum conversion: " + value.getClass().getSimpleName());
+ "Bad value type for enum conversion: " + value.getClass().getSimpleName());
}
}
@@ -247,7 +228,7 @@ public final class PropertyResolverUtils {
return defaultValue;
} else if (value instanceof Number) {
return ((Number) value).intValue();
- } else { // we parse the string in case this is NOT an integer
+ } else { // we parse the string in case this is NOT an integer
return Integer.parseInt(value.toString());
}
}
@@ -267,7 +248,7 @@ public final class PropertyResolverUtils {
return (Integer) value;
} else if (value instanceof Number) {
return ((Number) value).intValue();
- } else { // we parse the string in case this is NOT a valid integer string
+ } else { // we parse the string in case this is NOT a valid integer string
return Integer.valueOf(value.toString());
}
}
@@ -289,11 +270,11 @@ public final class PropertyResolverUtils {
}
/**
- * @param value The value to convert
- * @param defaultValue The default value to return if value is {@code null} or
- * and empty string, then returns the default value.
- * @return The resolved value
- * @see #toBoolean(Object)
+ * @param value The value to convert
+ * @param defaultValue The default value to return if value is {@code null} or and empty string, then returns the
+ * default value.
+ * @return The resolved value
+ * @see #toBoolean(Object)
*/
public static boolean toBoolean(Object value, boolean defaultValue) {
Boolean bool = toBoolean(value);
@@ -315,28 +296,32 @@ public final class PropertyResolverUtils {
}
/**
- * <P>Attempts to convert the object into a {@link Boolean} value as follows:</P></BR>
+ * <P>
+ * Attempts to convert the object into a {@link Boolean} value as follows:
+ * </P>
+ * </BR>
* <UL>
- * <P><LI>
- * If {@code null} or an empty string then return {@code null}.
- * </LI></P>
+ * <P>
+ * <LI>If {@code null} or an empty string then return {@code null}.</LI>
+ * </P>
*
- * <P><LI>
- * If already a {@link Boolean} then return as-is
- * </LI></P>
+ * <P>
+ * <LI>If already a {@link Boolean} then return as-is</LI>
+ * </P>
*
- * <P><LI>
- * If a {@link CharSequence} then invoke {@link #parseBoolean(String)}
- * </LI></P>
+ * <P>
+ * <LI>If a {@link CharSequence} then invoke {@link #parseBoolean(String)}</LI>
+ * </P>
*
- * <P><LI>
- * Otherwise, throws an {@link UnsupportedOperationException}
- * </LI></P>
+ * <P>
+ * <LI>Otherwise, throws an {@link UnsupportedOperationException}</LI>
+ * </P>
* </UL>
- * @param value The value to be converted
- * @return The result - {@code null} if {@code null} or an empty string
+ *
+ * @param value The value to be converted
+ * @return The result - {@code null} if {@code null} or an empty string
* @throws UnsupportedOperationException If value cannot be converted to a boolean - e.g., a number.
- * @see #parseBoolean(String)
+ * @see #parseBoolean(String)
*/
public static Boolean toBoolean(Object value) {
if (value == null) {
@@ -347,18 +332,18 @@ public final class PropertyResolverUtils {
return parseBoolean(value.toString());
} else {
throw new UnsupportedOperationException(
- "Cannot convert " + value.getClass().getSimpleName() + "[" + value + "] to boolean");
+ "Cannot convert " + value.getClass().getSimpleName() + "[" + value + "] to boolean");
}
}
/**
- * Converts a string to a {@link Boolean} value by looking for it in either the {@link #TRUE_VALUES}
- * or {@link #FALSE_VALUES}
+ * Converts a string to a {@link Boolean} value by looking for it in either the {@link #TRUE_VALUES} or
+ * {@link #FALSE_VALUES}
*
- * @param value The value to parse
- * @return The result - {@code null} if value is {@code null}/empty
- * @throws IllegalArgumentException If non-empty string that does not match (case <U>insensitive</U>)
- * either of the known values for boolean.
+ * @param value The value to parse
+ * @return The result - {@code null} if value is {@code null}/empty
+ * @throws IllegalArgumentException If non-empty string that does not match (case <U>insensitive</U>) either of the
+ * known values for boolean.
*/
public static Boolean parseBoolean(String value) {
if (GenericUtils.isEmpty(value)) {
@@ -381,10 +366,10 @@ public final class PropertyResolverUtils {
}
/**
- * @param resolver The {@link PropertyResolver} to use - ignored if {@code null}
- * @param name The property name
- * @param defaultValue The default value to return if property not set or empty
- * @return The set value (if not {@code null}/empty) or default one
+ * @param resolver The {@link PropertyResolver} to use - ignored if {@code null}
+ * @param name The property name
+ * @param defaultValue The default value to return if property not set or empty
+ * @return The set value (if not {@code null}/empty) or default one
*/
public static String getStringProperty(
PropertyResolver resolver, String name, String defaultValue) {
@@ -452,11 +437,10 @@ public final class PropertyResolverUtils {
}
/**
- * @param resolver The {@link PropertyResolver} instance
- * @param name The property name
- * @param value The new value - if {@code null} or an empty {@link CharSequence}
- * the property is <U>removed</U>
- * @return The previous value - {@code null} if none
+ * @param resolver The {@link PropertyResolver} instance
+ * @param name The property name
+ * @param value The new value - if {@code null} or an empty {@link CharSequence} the property is <U>removed</U>
+ * @return The previous value - {@code null} if none
*/
public static Object updateProperty(PropertyResolver resolver, String name, Object value) {
return updateProperty(resolver.getProperties(), name, value);
@@ -472,14 +456,13 @@ public final class PropertyResolverUtils {
}
/**
- * Unwinds the resolvers hierarchy until found one with a non-{@code null} value
- * for the requested property or reached top. If still no value found and the key
- * starts with "org.apache.sshd" then the system properties are also
- * consulted
+ * Unwinds the resolvers hierarchy until found one with a non-{@code null} value for the requested property or
+ * reached top. If still no value found and the key starts with "org.apache.sshd" then the system
+ * properties are also consulted
*
- * @param resolver The {@link PropertyResolver} to start from - ignored if {@code null}
- * @param name The requested property name
- * @return The found value or {@code null}
+ * @param resolver The {@link PropertyResolver} to start from - ignored if {@code null}
+ * @param name The requested property name
+ * @return The found value or {@code null}
*/
public static Object resolvePropertyValue(PropertyResolver resolver, String name) {
String key = ValidateUtils.checkNotNullAndNotEmpty(name, "No property name");
@@ -495,12 +478,12 @@ public final class PropertyResolverUtils {
}
/**
- * Unwinds the resolvers hierarchy until found one with a non-{@code null} value
- * for the requested property or reached top.
+ * Unwinds the resolvers hierarchy until found one with a non-{@code null} value for the requested property or
+ * reached top.
*
- * @param resolver The {@link PropertyResolver} to start from - ignored if {@code null}
- * @param name The requested property name
- * @return The found properties {@link Map} or {@code null}
+ * @param resolver The {@link PropertyResolver} to start from - ignored if {@code null}
+ * @param name The requested property name
+ * @return The found properties {@link Map} or {@code null}
*/
public static Map<String, Object> resolvePropertiesSource(PropertyResolver resolver, String name) {
String key = ValidateUtils.checkNotNullAndNotEmpty(name, "No property name");
@@ -534,12 +517,10 @@ public final class PropertyResolverUtils {
}
/**
- * Wraps a {@link Map} into a {@link PropertyResolver} so it can be used
- * with these utilities
+ * Wraps a {@link Map} into a {@link PropertyResolver} so it can be used with these utilities
*
- * @param props The properties map - may be {@code null}/empty if no properties
- * are updated
- * @return The resolver wrapper
+ * @param props The properties map - may be {@code null}/empty if no properties are updated
+ * @return The resolver wrapper
*/
public static PropertyResolver toPropertyResolver(Map<String, ?> props) {
return toPropertyResolver(props, null);
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/SshConstants.java b/sshd-common/src/main/java/org/apache/sshd/common/SshConstants.java
index 06f7b05..900a865 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/SshConstants.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/SshConstants.java
@@ -121,15 +121,14 @@ public final class SshConstants {
public static final int SSH_OPEN_RESOURCE_SHORTAGE = 4;
// Some more constants
- public static final int SSH_EXTENDED_DATA_STDERR = 1; // see RFC4254 section 5.2
+ public static final int SSH_EXTENDED_DATA_STDERR = 1; // see RFC4254 section 5.2
// 32-bit length + 8-bit pad length
public static final int SSH_PACKET_HEADER_LEN = Integer.BYTES + Byte.BYTES;
/*
* See https://tools.ietf.org/html/rfc4253#section-6.1:
*
- * All implementations MUST be able to process packets with an
- * uncompressed payload length of 32768 bytes or less and a total packet
- * size of 35000 bytes or less
+ * All implementations MUST be able to process packets with an uncompressed payload length of 32768 bytes or less
+ * and a total packet size of 35000 bytes or less
*/
public static final int SSH_REQUIRED_PAYLOAD_PACKET_LENGTH_SUPPORT = 32768;
public static final int SSH_REQUIRED_TOTAL_PACKET_LENGTH_SUPPORT = 35000;
@@ -139,10 +138,9 @@ public final class SshConstants {
}
private static final class LazyAmbiguousOpcodesHolder {
- private static final Set<Integer> AMBIGUOUS_OPCODES =
- Collections.unmodifiableSet(
+ private static final Set<Integer> AMBIGUOUS_OPCODES = Collections.unmodifiableSet(
new HashSet<>(
- LoggingUtils.getAmbiguousMenmonics(SshConstants.class, "SSH_MSG_").values()));
+ LoggingUtils.getAmbiguousMenmonics(SshConstants.class, "SSH_MSG_").values()));
private LazyAmbiguousOpcodesHolder() {
throw new UnsupportedOperationException("No instance allowed");
@@ -150,9 +148,9 @@ public final class SshConstants {
}
/**
- * @param cmd The command value
- * @return {@code true} if this value is used by several <U>different</U> messages
- * @see #getAmbiguousOpcodes()
+ * @param cmd The command value
+ * @return {@code true} if this value is used by several <U>different</U> messages
+ * @see #getAmbiguousOpcodes()
*/
public static boolean isAmbiguousOpcode(int cmd) {
Collection<Integer> ambiguousOpcodes = getAmbiguousOpcodes();
@@ -168,19 +166,18 @@ public final class SshConstants {
}
private static final class LazyMessagesMapHolder {
- private static final Map<Integer, String> MESSAGES_MAP =
- LoggingUtils.generateMnemonicMap(SshConstants.class, f -> {
- String name = f.getName();
- if (!name.startsWith("SSH_MSG_")) {
- return false;
- }
-
- try {
- return !isAmbiguousOpcode(f.getByte(null));
- } catch (Exception e) {
- return false;
- }
- });
+ private static final Map<Integer, String> MESSAGES_MAP = LoggingUtils.generateMnemonicMap(SshConstants.class, f -> {
+ String name = f.getName();
+ if (!name.startsWith("SSH_MSG_")) {
+ return false;
+ }
+
+ try {
+ return !isAmbiguousOpcode(f.getByte(null));
+ } catch (Exception e) {
+ return false;
+ }
+ });
private LazyMessagesMapHolder() {
throw new UnsupportedOperationException("No instance allowed");
@@ -190,9 +187,9 @@ public final class SshConstants {
/**
* Converts a command value to a user-friendly name
*
- * @param cmd The command value
- * @return The user-friendly name - if not one of the defined {@code SSH_MSG_XXX}
- * values then returns the string representation of the command's value
+ * @param cmd The command value
+ * @return The user-friendly name - if not one of the defined {@code SSH_MSG_XXX} values then returns the string
+ * representation of the command's value
*/
public static String getCommandMessageName(int cmd) {
@SuppressWarnings("synthetic-access")
@@ -205,8 +202,8 @@ public final class SshConstants {
}
private static final class LazyReasonsMapHolder {
- private static final Map<Integer, String> REASONS_MAP =
- LoggingUtils.generateMnemonicMap(SshConstants.class, "SSH2_DISCONNECT_");
+ private static final Map<Integer, String> REASONS_MAP
+ = LoggingUtils.generateMnemonicMap(SshConstants.class, "SSH2_DISCONNECT_");
private LazyReasonsMapHolder() {
throw new UnsupportedOperationException("No instance allowed");
@@ -216,9 +213,9 @@ public final class SshConstants {
/**
* Converts a disconnect reason value to a user-friendly name
*
- * @param reason The disconnect reason value
- * @return The user-friendly name - if not one of the defined {@code SSH2_DISCONNECT_}
- * values then returns the string representation of the reason's value
+ * @param reason The disconnect reason value
+ * @return The user-friendly name - if not one of the defined {@code SSH2_DISCONNECT_} values then returns
+ * the string representation of the reason's value
*/
public static String getDisconnectReasonName(int reason) {
@SuppressWarnings("synthetic-access")
@@ -231,8 +228,8 @@ public final class SshConstants {
}
private static final class LazyOpenCodesMapHolder {
- private static final Map<Integer, String> OPEN_CODES_MAP =
- LoggingUtils.generateMnemonicMap(SshConstants.class, "SSH_OPEN_");
+ private static final Map<Integer, String> OPEN_CODES_MAP
+ = LoggingUtils.generateMnemonicMap(SshConstants.class, "SSH_OPEN_");
private LazyOpenCodesMapHolder() {
throw new UnsupportedOperationException("No instance allowed");
@@ -242,9 +239,9 @@ public final class SshConstants {
/**
* Converts an open error value to a user-friendly name
*
- * @param code The open error value
- * @return The user-friendly name - if not one of the defined {@code SSH_OPEN_}
- * values then returns the string representation of the reason's value
+ * @param code The open error value
+ * @return The user-friendly name - if not one of the defined {@code SSH_OPEN_} values then returns the string
+ * representation of the reason's value
*/
public static String getOpenErrorCodeName(int code) {
@SuppressWarnings("synthetic-access")
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/SyspropsMapWrapper.java b/sshd-common/src/main/java/org/apache/sshd/common/SyspropsMapWrapper.java
index 09ef03a..0cf3d54 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/SyspropsMapWrapper.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/SyspropsMapWrapper.java
@@ -32,10 +32,9 @@ import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.MapEntryUtils;
/**
- * A wrapper that exposes a read-only {@link Map} access to the system
- * properties. Any attempt to modify it will throw {@link UnsupportedOperationException}.
- * The mapper uses the {@link #SYSPROPS_MAPPED_PREFIX} to filter and access'
- * only these properties, ignoring all others
+ * A wrapper that exposes a read-only {@link Map} access to the system properties. Any attempt to modify it will throw
+ * {@link UnsupportedOperationException}. The mapper uses the {@link #SYSPROPS_MAPPED_PREFIX} to filter and access' only
+ * these properties, ignoring all others
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
@@ -46,11 +45,9 @@ public final class SyspropsMapWrapper implements Map<String, Object> {
public static final String SYSPROPS_MAPPED_PREFIX = "org.apache.sshd.config";
/**
- * Exposes the "raw" system properties as a {@link PropertyResolver}
- * without any further filtering
+ * Exposes the "raw" system properties as a {@link PropertyResolver} without any further filtering
*/
- public static final PropertyResolver RAW_PROPS_RESOLVER =
- PropertyResolverUtils.toPropertyResolver(System.getProperties());
+ public static final PropertyResolver RAW_PROPS_RESOLVER = PropertyResolverUtils.toPropertyResolver(System.getProperties());
/**
* The one and only wrapper instance
@@ -143,12 +140,12 @@ public final class SyspropsMapWrapper implements Map<String, Object> {
@Override
public Set<String> keySet() {
return System.getProperties()
- .stringPropertyNames()
- .stream()
- // filter out any non-SSHD properties
- .filter(SyspropsMapWrapper::isMappedSyspropKey)
- .map(SyspropsMapWrapper::getUnmappedSyspropKey)
- .collect(Collectors.toSet());
+ .stringPropertyNames()
+ .stream()
+ // filter out any non-SSHD properties
+ .filter(SyspropsMapWrapper::isMappedSyspropKey)
+ .map(SyspropsMapWrapper::getUnmappedSyspropKey)
+ .collect(Collectors.toSet());
}
@Override
@@ -176,11 +173,11 @@ public final class SyspropsMapWrapper implements Map<String, Object> {
Properties props = System.getProperties();
// return a copy in order to avoid concurrent modifications
return props
- .stringPropertyNames()
- .stream()
- .filter(SyspropsMapWrapper::isMappedSyspropKey)
- .map(props::get)
- .collect(Collectors.toList());
+ .stringPropertyNames()
+ .stream()
+ .filter(SyspropsMapWrapper::isMappedSyspropKey)
+ .map(props::get)
+ .collect(Collectors.toList());
}
@Override
@@ -189,20 +186,20 @@ public final class SyspropsMapWrapper implements Map<String, Object> {
}
/**
- * @param key Key to be tested
- * @return {@code true} if key starts with {@link #SYSPROPS_MAPPED_PREFIX}
- * and continues with a dot followed by some characters
+ * @param key Key to be tested
+ * @return {@code true} if key starts with {@link #SYSPROPS_MAPPED_PREFIX} and continues with a dot followed by
+ * some characters
*/
public static boolean isMappedSyspropKey(String key) {
return (GenericUtils.length(key) > (SYSPROPS_MAPPED_PREFIX.length() + 1))
- && key.startsWith(SYSPROPS_MAPPED_PREFIX)
- && (key.charAt(SYSPROPS_MAPPED_PREFIX.length()) == '.');
+ && key.startsWith(SYSPROPS_MAPPED_PREFIX)
+ && (key.charAt(SYSPROPS_MAPPED_PREFIX.length()) == '.');
}
/**
- * @param key Key to be transformed
- * @return The "pure" key name if a mapped one, same as input otherwise
- * @see #isMappedSyspropKey(String)
+ * @param key Key to be transformed
+ * @return The "pure" key name if a mapped one, same as input otherwise
+ * @see #isMappedSyspropKey(String)
*/
public static String getUnmappedSyspropKey(Object key) {
String s = Objects.toString(key);
@@ -210,9 +207,9 @@ public final class SyspropsMapWrapper implements Map<String, Object> {
}
/**
- * @param key The original key
- * @return A key prefixed by {@link #SYSPROPS_MAPPED_PREFIX}
- * @see #isMappedSyspropKey(String)
+ * @param key The original key
+ * @return A key prefixed by {@link #SYSPROPS_MAPPED_PREFIX}
+ * @see #isMappedSyspropKey(String)
*/
public static String getMappedSyspropKey(Object key) {
return SYSPROPS_MAPPED_PREFIX + "." + key;
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/auth/BasicCredentialsImpl.java b/sshd-common/src/main/java/org/apache/sshd/common/auth/BasicCredentialsImpl.java
index 4e444f0..8a1f61a 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/auth/BasicCredentialsImpl.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/auth/BasicCredentialsImpl.java
@@ -85,7 +85,7 @@ public class BasicCredentialsImpl implements MutableBasicCredentials, Cloneable
BasicCredentialsImpl other = (BasicCredentialsImpl) obj;
return Objects.equals(getUsername(), other.getUsername())
- && Objects.equals(getPassword(), other.getPassword());
+ && Objects.equals(getPassword(), other.getPassword());
}
// NOTE: do not implement 'toString' on purpose to avoid inadvertent logging of contents
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/auth/UserAuthFactoriesManager.java b/sshd-common/src/main/java/org/apache/sshd/common/auth/UserAuthFactoriesManager.java
index c64c1d8..5d09e97 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/auth/UserAuthFactoriesManager.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/auth/UserAuthFactoriesManager.java
@@ -29,12 +29,13 @@ import org.apache.sshd.common.session.SessionContext;
import org.apache.sshd.common.util.GenericUtils;
/**
- * @param <S> Type of session being managed
- * @param <M> Type of {@code UserAuth} being used
- * @param <F> Type of user authentication mechanism factory
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ * @param <S> Type of session being managed
+ * @param <M> Type of {@code UserAuth} being used
+ * @param <F> Type of user authentication mechanism factory
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public interface UserAuthFactoriesManager<S extends SessionContext,
+public interface UserAuthFactoriesManager<
+ S extends SessionContext,
M extends UserAuthInstance<S>, F extends UserAuthMethodFactory<S, M>> {
/**
* Retrieve the list of named factories for <code>UserAuth</code> objects.
@@ -59,9 +60,9 @@ public interface UserAuthFactoriesManager<S extends SessionContext,
default void setUserAuthFactoriesNames(String... names) {
setUserAuthFactoriesNames(
- GenericUtils.isEmpty((Object[]) names)
- ? Collections.emptyList()
- : Arrays.asList(names));
+ GenericUtils.isEmpty((Object[]) names)
+ ? Collections.emptyList()
+ : Arrays.asList(names));
}
void setUserAuthFactoriesNames(Collection<String> names);
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/auth/UserAuthInstance.java b/sshd-common/src/main/java/org/apache/sshd/common/auth/UserAuthInstance.java
index 7e326ee..3756ec8 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/auth/UserAuthInstance.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/auth/UserAuthInstance.java
@@ -25,14 +25,13 @@ import org.apache.sshd.common.session.SessionContext;
/**
* Represents an authentication-in-progress tracker for a specific session
*
- * @param <S> The type of session being tracked by the instance
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ * @param <S> The type of session being tracked by the instance
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public interface UserAuthInstance<S extends SessionContext> extends NamedResource {
/**
- * @return The current session for which the authentication is being
- * tracked. <B>Note:</B> may be {@code null} if the instance has not
- * been initialized yet
+ * @return The current session for which the authentication is being tracked. <B>Note:</B> may be {@code null} if
+ * the instance has not been initialized yet
*/
S getSession();
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/auth/UserAuthMethodFactory.java b/sshd-common/src/main/java/org/apache/sshd/common/auth/UserAuthMethodFactory.java
index 9955e01..c41f515 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/auth/UserAuthMethodFactory.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/auth/UserAuthMethodFactory.java
@@ -29,10 +29,9 @@ import org.apache.sshd.common.session.SessionContext;
/**
* Represents a user authentication method
*
- * @param <S> The type of {@link SessionContext} being provided
- * to the instance creator
- * @param <M> The authentication method factory type
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ * @param <S> The type of {@link SessionContext} being provided to the instance creator
+ * @param <M> The authentication method factory type
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public interface UserAuthMethodFactory<S extends SessionContext, M extends UserAuthInstance<S>> extends NamedResource {
/**
@@ -56,43 +55,41 @@ public interface UserAuthMethodFactory<S extends SessionContext, M extends UserA
String HOST_BASED = "hostbased";
/**
- * If set to {@code true} then {@link #isSecureAuthenticationTransport(SessionContext)}
- * returns {@code true} even if transport is insecure.
+ * If set to {@code true} then {@link #isSecureAuthenticationTransport(SessionContext)} returns {@code true} even if
+ * transport is insecure.
*/
String ALLOW_INSECURE_AUTH = "allow-insecure-auth";
boolean DEFAULT_ALLOW_INSECURE_AUTH = false;
/**
- * If set to {@code true} then {@link #isDataIntegrityAuthenticationTransport(SessionContext)}
- * returns {@code true} even if transport has no MAC(s) to verify message integrity
+ * If set to {@code true} then {@link #isDataIntegrityAuthenticationTransport(SessionContext)} returns {@code true}
+ * even if transport has no MAC(s) to verify message integrity
*/
String ALLOW_NON_INTEGRITY_AUTH = "allow-non-integrity-auth";
boolean DEFAULT_ALLOW_NON_INTEGRITY_AUTH = false;
/**
- * @param session The session for which authentication is required
- * @return The authenticator instance
+ * @param session The session for which authentication is required
+ * @return The authenticator instance
* @throws IOException If failed to create the instance
*/
M createUserAuth(S session) throws IOException;
/**
- * @param <S> The type of {@link SessionContext} being provided
- * to the instance creator
- * @param <M> The authentication method factory type
- * @param session The session through which the request is being made
- * @param factories The available factories
- * @param name The requested factory name
- * @return The created authenticator instance - {@code null} if no matching factory
+ * @param <S> The type of {@link SessionContext} being provided to the instance creator
+ * @param <M> The authentication method factory type
+ * @param session The session through which the request is being made
+ * @param factories The available factories
+ * @param name The requested factory name
+ * @return The created authenticator instance - {@code null} if no matching factory
* @throws IOException If failed to create the instance
*/
static <S extends SessionContext, M extends UserAuthInstance<S>> M createUserAuth(
S session, Collection<? extends UserAuthMethodFactory<S, M>> factories, String name)
- throws IOException {
- UserAuthMethodFactory<S, M> f =
- NamedResource.findByName(name, String.CASE_INSENSITIVE_ORDER, factories);
+ throws IOException {
+ UserAuthMethodFactory<S, M> f = NamedResource.findByName(name, String.CASE_INSENSITIVE_ORDER, factories);
if (f != null) {
return f.createUserAuth(session);
} else {
@@ -102,6 +99,7 @@ public interface UserAuthMethodFactory<S extends SessionContext, M extends UserA
/**
* According to <A HREF="https://tools.ietf.org/html/rfc4252#section-8">RFC 4252 - section 8</A>:
+ *
* <PRE>
* Both the server and the client should check whether the underlying
* transport layer provides confidentiality (i.e., if encryption is
@@ -110,11 +108,11 @@ public interface UserAuthMethodFactory<S extends SessionContext, M extends UserA
* confidentiality or no MAC, password change SHOULD be disabled.
* </PRE>
*
- * @param session The {@link SessionContext} being used for authentication
- * @return {@code true} if the context is not {@code null} and the ciphers
- * have been established to anything other than "none".
- * @see #ALLOW_INSECURE_AUTH
- * @see SessionContext#isSecureSessionTransport(SessionContext)
+ * @param session The {@link SessionContext} being used for authentication
+ * @return {@code true} if the context is not {@code null} and the ciphers have been established to anything
+ * other than "none".
+ * @see #ALLOW_INSECURE_AUTH
+ * @see SessionContext#isSecureSessionTransport(SessionContext)
*/
static boolean isSecureAuthenticationTransport(SessionContext session) {
if (session == null) {
@@ -122,7 +120,7 @@ public interface UserAuthMethodFactory<S extends SessionContext, M extends UserA
}
boolean allowInsecure = PropertyResolverUtils.getBooleanProperty(
- session, ALLOW_INSECURE_AUTH, DEFAULT_ALLOW_INSECURE_AUTH);
+ session, ALLOW_INSECURE_AUTH, DEFAULT_ALLOW_INSECURE_AUTH);
if (allowInsecure) {
return true;
}
@@ -131,11 +129,11 @@ public interface UserAuthMethodFactory<S extends SessionContext, M extends UserA
}
/**
- * @param session The {@link SessionContext} being used for authentication
- * @return {@code true} if the context is not {@code null} and the MAC(s)
- * used to verify packet integrity have been established.
- * @see #ALLOW_NON_INTEGRITY_AUTH
- * @see SessionContext#isDataIntegrityTransport(SessionContext)
+ * @param session The {@link SessionContext} being used for authentication
+ * @return {@code true} if the context is not {@code null} and the MAC(s) used to verify packet integrity
+ * have been established.
+ * @see #ALLOW_NON_INTEGRITY_AUTH
+ * @see SessionContext#isDataIntegrityTransport(SessionContext)
*/
static boolean isDataIntegrityAuthenticationTransport(SessionContext session) {
if (session == null) {
@@ -143,7 +141,7 @@ public interface UserAuthMethodFactory<S extends SessionContext, M extends UserA
}
boolean allowNonValidated = PropertyResolverUtils.getBooleanProperty(
- session, ALLOW_NON_INTEGRITY_AUTH, DEFAULT_ALLOW_NON_INTEGRITY_AUTH);
+ session, ALLOW_NON_INTEGRITY_AUTH, DEFAULT_ALLOW_NON_INTEGRITY_AUTH);
if (allowNonValidated) {
return true;
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/auth/UsernameHolder.java b/sshd-common/src/main/java/org/apache/sshd/common/auth/UsernameHolder.java
index 7ee76ad..019f05b 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/auth/UsernameHolder.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/auth/UsernameHolder.java
@@ -25,8 +25,7 @@ package org.apache.sshd.common.auth;
@FunctionalInterface
public interface UsernameHolder {
/**
- * @return The attached username - may be {@code null}/empty if holder
- * not yet initialized
+ * @return The attached username - may be {@code null}/empty if holder not yet initialized
*/
String getUsername();
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyChannelConfiguration.java b/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyChannelConfiguration.java
index 141012c..6369766 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyChannelConfiguration.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyChannelConfiguration.java
@@ -100,12 +100,12 @@ public class PtyChannelConfiguration implements PtyChannelConfigurationMutator {
@Override
public String toString() {
return getClass().getSimpleName()
- + "[type=" + getPtyType()
- + ", lines=" + getPtyLines()
- + ", columns=" + getPtyColumns()
- + ", height=" + getPtyHeight()
- + ", width=" + getPtyWidth()
- + ", modes=" + getPtyModes()
- + "]";
+ + "[type=" + getPtyType()
+ + ", lines=" + getPtyLines()
+ + ", columns=" + getPtyColumns()
+ + ", height=" + getPtyHeight()
+ + ", width=" + getPtyWidth()
+ + ", modes=" + getPtyModes()
+ + "]";
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyChannelConfigurationHolder.java b/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyChannelConfigurationHolder.java
index 6ba629b..7199057 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyChannelConfigurationHolder.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyChannelConfigurationHolder.java
@@ -35,8 +35,7 @@ public interface PtyChannelConfigurationHolder {
String DUMMY_PTY_TYPE = "dummy";
String WINDOWS_PTY_TYPE = "windows";
- Map<PtyMode, Integer> DEFAULT_PTY_MODES =
- EnumMapBuilder.<PtyMode, Integer>builder(PtyMode.class)
+ Map<PtyMode, Integer> DEFAULT_PTY_MODES = EnumMapBuilder.<PtyMode, Integer> builder(PtyMode.class)
.put(PtyMode.ISIG, 1)
.put(PtyMode.ICANON, 1)
.put(PtyMode.ECHO, 1)
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyChannelConfigurationMutator.java b/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyChannelConfigurationMutator.java
index bd3cfc9..1d721b4 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyChannelConfigurationMutator.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyChannelConfigurationMutator.java
@@ -57,10 +57,10 @@ public interface PtyChannelConfigurationMutator extends PtyChannelConfigurationH
/**
* Uses O/S detection to initialize some default PTY related values
*
- * @param <M> Generic {@link PtyChannelConfigurationMutator} instance
- * @param mutator The mutator to update - ignored if {@code null}
- * @return The updated mutator
- * @throws IOException If failed to access some O/S related configuration
+ * @param <M> Generic {@link PtyChannelConfigurationMutator} instance
+ * @param mutator The mutator to update - ignored if {@code null}
+ * @return The updated mutator
+ * @throws IOException If failed to access some O/S related configuration
* @throws InterruptedException If interrupted during access of O/S related configuration
*/
static <M extends PtyChannelConfigurationMutator> M setupSensitiveDefaultPtyConfiguration(M mutator)
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyMode.java b/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyMode.java
index 4c5126b..b79c11d 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyMode.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/channel/PtyMode.java
@@ -32,8 +32,8 @@ import java.util.function.ToIntFunction;
import org.apache.sshd.common.util.GenericUtils;
/**
- * A enum describing the tty modes according to
- * <a href="https://tools.ietf.org/html/rfc4254#section-8">RFC 4254 - section 8</a>.
+ * A enum describing the tty modes according to <a href="https://tools.ietf.org/html/rfc4254#section-8">RFC 4254 -
+ * section 8</a>.
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
@@ -42,8 +42,8 @@ public enum PtyMode {
/////////////////////////////// Chars ////////////////////////////////////
/**
- * Interrupt character; 255 if none. Similarly for the other characters.
- * Not all of these characters are supported on all systems.
+ * Interrupt character; 255 if none. Similarly for the other characters. Not all of these characters are supported
+ * on all systems.
*/
VINTR(1),
/**
@@ -118,8 +118,7 @@ public enum PtyMode {
///////////////////////////////// I-flags ////////////////////////////////
/**
- * The ignore parity flag. The parameter SHOULD be 0 if this flag
- * is FALSE, and 1 if it is TRUE.
+ * The ignore parity flag. The parameter SHOULD be 0 if this flag is FALSE, and 1 if it is TRUE.
*/
IGNPAR(30),
/**
@@ -182,8 +181,7 @@ public enum PtyMode {
*/
ICANON(51),
/**
- * Enable input and output of uppercase characters by preceding their
- * lowercase equivalents with "\".
+ * Enable input and output of uppercase characters by preceding their lowercase equivalents with "\".
*/
XCASE(52),
/**
@@ -293,31 +291,30 @@ public enum PtyMode {
/**
* An un-modifiable {@link Set} of all defined {@link PtyMode}s
*/
- public static final Set<PtyMode> MODES =
- Collections.unmodifiableSet(EnumSet.allOf(PtyMode.class));
+ public static final Set<PtyMode> MODES = Collections.unmodifiableSet(EnumSet.allOf(PtyMode.class));
- public static final NavigableMap<Integer, PtyMode> COMMANDS =
- Collections.unmodifiableNavigableMap(
+ public static final NavigableMap<Integer, PtyMode> COMMANDS = Collections.unmodifiableNavigableMap(
GenericUtils.toSortedMap(MODES, PtyMode::toInt, Function.identity(), Comparator.naturalOrder()));
/**
- * A {@code null}-safe {@link ToIntFunction} that returns the {@link PtyMode#toInt()} value and (-1) for {@code null}
+ * A {@code null}-safe {@link ToIntFunction} that returns the {@link PtyMode#toInt()} value and (-1) for
+ * {@code null}
*/
public static final ToIntFunction<PtyMode> OPCODE_EXTRACTOR = v -> (v == null) ? -1 : v.toInt();
/**
- * A {@code null}-safe {@link Comparator} of {@link PtyMode} values
- * according to their {@link PtyMode#toInt()} value
+ * A {@code null}-safe {@link Comparator} of {@link PtyMode} values according to their {@link PtyMode#toInt()} value
+ *
* @see #OPCODE_EXTRACTOR
*/
public static final Comparator<PtyMode> BY_OPCODE = new Comparator<PtyMode>() {
- @Override
- public int compare(PtyMode o1, PtyMode o2) {
- int v1 = OPCODE_EXTRACTOR.applyAsInt(o1);
- int v2 = OPCODE_EXTRACTOR.applyAsInt(o2);
- return Integer.compare(v1, v2);
- }
- };
+ @Override
+ public int compare(PtyMode o1, PtyMode o2) {
+ int v1 = OPCODE_EXTRACTOR.applyAsInt(o1);
+ int v2 = OPCODE_EXTRACTOR.applyAsInt(o2);
+ return Integer.compare(v1, v2);
+ }
+ };
private final int v;
@@ -330,9 +327,9 @@ public enum PtyMode {
}
/**
- * @param b The numeric value of the option
- * @return The matching {@link PtyMode} or {@code null} if no match found
- * @see #toInt()
+ * @param b The numeric value of the option
+ * @return The matching {@link PtyMode} or {@code null} if no match found
+ * @see #toInt()
*/
public static PtyMode fromInt(int b) {
return COMMANDS.get(0x00FF & b);
@@ -353,16 +350,16 @@ public enum PtyMode {
}
/**
- * @param options The options to enable - ignored if {@code null}/empty
- * @return A {@link Map} where all the specified {@link PtyMode}s have {@link #TRUE_SETTING}
+ * @param options The options to enable - ignored if {@code null}/empty
+ * @return A {@link Map} where all the specified {@link PtyMode}s have {@link #TRUE_SETTING}
*/
public static Map<PtyMode, Integer> createEnabledOptions(PtyMode... options) {
return createEnabledOptions(GenericUtils.of(options));
}
/**
- * @param options The options to enable - ignored if {@code null}/empty
- * @return A {@link Map} where all the specified {@link PtyMode}s have {@link #TRUE_SETTING}
+ * @param options The options to enable - ignored if {@code null}/empty
+ * @return A {@link Map} where all the specified {@link PtyMode}s have {@link #TRUE_SETTING}
*/
public static Map<PtyMode, Integer> createEnabledOptions(Collection<PtyMode> options) {
if (GenericUtils.isEmpty(options)) {
@@ -382,11 +379,10 @@ public enum PtyMode {
}
/**
- * @param modes The PTY settings - ignored if {@code null}/empty
- * @param options The options that should be enabled
- * @return A {@link Set} of all the {@link PtyMode}s that appeared
- * in the settings and were enabled
- * @see #getBooleanSettingValue(Map, PtyMode)
+ * @param modes The PTY settings - ignored if {@code null}/empty
+ * @param options The options that should be enabled
+ * @return A {@link Set} of all the {@link PtyMode}s that appeared in the settings and were enabled
+ * @see #getBooleanSettingValue(Map, PtyMode)
*/
public static Set<PtyMode> resolveEnabledOptions(Map<PtyMode, ?> modes, Collection<PtyMode> options) {
if (GenericUtils.isEmpty(modes) || GenericUtils.isEmpty(options)) {
@@ -404,17 +400,17 @@ public enum PtyMode {
}
/**
- * @param modes The current modes {@link Map}-ing
- * @param m The required {@link PtyMode}
- * @return {@code true} if <U>all</U> of these conditions hold:</BR>
- * <UL>
- * <LI>Modes map is not {@code null}/empty</LI>
- * <LI>Required mode setting is not {@code null}</LI>
- * <LI>The setting has a mapped value</LI>
- * <LI>The mapped value is a {@link Number}</LI>
- * <LI>The {@link Number#intValue()} is non-zero</LI>
- * </UL>
- * @see #getBooleanSettingValue(Object)
+ * @param modes The current modes {@link Map}-ing
+ * @param m The required {@link PtyMode}
+ * @return {@code true} if <U>all</U> of these conditions hold:</BR>
+ * <UL>
+ * <LI>Modes map is not {@code null}/empty</LI>
+ * <LI>Required mode setting is not {@code null}</LI>
+ * <LI>The setting has a mapped value</LI>
+ * <LI>The mapped value is a {@link Number}</LI>
+ * <LI>The {@link Number#intValue()} is non-zero</LI>
+ * </UL>
+ * @see #getBooleanSettingValue(Object)
*/
public static boolean getBooleanSettingValue(Map<PtyMode, ?> modes, PtyMode m) {
if ((m == null) || GenericUtils.isEmpty(modes)) {
@@ -425,32 +421,23 @@ public enum PtyMode {
}
/**
- * @param modes The {@link Map} of {@link PtyMode}s resolved by the "pty-req" message.
- * @param enablers A {@link Collection} of enabler settings to be consulted
- * @param defaultValue The default value to be used if no definite setting could be deduced
- * @return {@code true} if the CR mode is enabled:</BR>
- * <UL>
- * <LI>
- * If<tt>modes</tt> or <tt>enablers</tt> are {@code null}/empty
- * then <tt>defaultValue</tt> is used
- * </LI>
+ * @param modes The {@link Map} of {@link PtyMode}s resolved by the "pty-req" message.
+ * @param enablers A {@link Collection} of enabler settings to be consulted
+ * @param defaultValue The default value to be used if no definite setting could be deduced
+ * @return {@code true} if the CR mode is enabled:</BR>
+ * <UL>
+ * <LI>If<tt>modes</tt> or <tt>enablers</tt> are {@code null}/empty then <tt>defaultValue</tt>
+ * is used</LI>
*
- * <LI>
- * If <U>any</U> of the <tt>enablers</tt> modes are enabled
- * then the CR mode is enabled.
- * </LI>
+ * <LI>If <U>any</U> of the <tt>enablers</tt> modes are enabled then the CR mode is enabled.
+ * </LI>
*
- * <LI>
- * If <U>none</U> of the <tt>enablers</tt> modes were specified
- * then use <tt>defaultValue</tt>
- * </LI>
+ * <LI>If <U>none</U> of the <tt>enablers</tt> modes were specified then use
+ * <tt>defaultValue</tt></LI>
*
- * <LI>
- * Otherwise (i.e., at least one or more of the <tt>enablers</tt>
- * modes were specified, but <U>all</U> of them said {@code no})
- * then {@code false}.
- * </LI>
- * </UL>
+ * <LI>Otherwise (i.e., at least one or more of the <tt>enablers</tt> modes were specified, but
+ * <U>all</U> of them said {@code no}) then {@code false}.</LI>
+ * </UL>
*/
public static boolean getBooleanSettingValue(
Map<PtyMode, ?> modes, Collection<PtyMode> enablers, boolean defaultValue) {
@@ -477,35 +464,35 @@ public enum PtyMode {
if (settingsCount > 0) {
return false;
} else {
- return defaultValue; // none of the settings has been found - assume default
+ return defaultValue; // none of the settings has been found - assume default
}
}
/**
- * @param v The value to be tested
- * @return {@code true} if <U>all</U> of these conditions hold:</BR>
- * <UL>
- * <LI>The mapped value is a {@link Number}</LI>
- * <LI>The {@link Number#intValue()} is non-zero</LI>
- * </UL>
- * @see #getBooleanSettingValue(int)
+ * @param v The value to be tested
+ * @return {@code true} if <U>all</U> of these conditions hold:</BR>
+ * <UL>
+ * <LI>The mapped value is a {@link Number}</LI>
+ * <LI>The {@link Number#intValue()} is non-zero</LI>
+ * </UL>
+ * @see #getBooleanSettingValue(int)
*/
public static boolean getBooleanSettingValue(Object v) {
return (v instanceof Number) && getBooleanSettingValue(((Number) v).intValue());
}
/**
- * @param v The setting value
- * @return {@code true} if value is non-zero
+ * @param v The setting value
+ * @return {@code true} if value is non-zero
*/
public static boolean getBooleanSettingValue(int v) {
return v != 0;
}
/**
- * @param m The {@link PtyMode}
- * @return {@code true} if not {@code null} and one of the settings that
- * refers to a character value - name usually starts with {@code Vxxx}
+ * @param m The {@link PtyMode}
+ * @return {@code true} if not {@code null} and one of the settings that refers to a character value - name
+ * usually starts with {@code Vxxx}
*/
public static boolean isCharSetting(PtyMode m) {
if (m == null) {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/channel/SttySupport.java b/sshd-common/src/main/java/org/apache/sshd/common/channel/SttySupport.java
index d996dee..8ba2984 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/channel/SttySupport.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/channel/SttySupport.java
@@ -36,13 +36,13 @@ import java.util.concurrent.atomic.AtomicReference;
*/
public final class SttySupport {
public static final int DEFAULT_TERMINAL_WIDTH = 80;
- public static final int DEFAULT_TERMINAL_HEIGHT = 24;
+ public static final int DEFAULT_TERMINAL_HEIGHT = 24;
public static final String SSHD_STTY_COMMAND_PROP = "sshd.sttyCommand";
public static final String DEFAULT_SSHD_STTY_COMMAND = "stty";
- private static final AtomicReference<String> STTY_COMMAND_HOLDER =
- new AtomicReference<>(System.getProperty(SSHD_STTY_COMMAND_PROP, DEFAULT_SSHD_STTY_COMMAND));
+ private static final AtomicReference<String> STTY_COMMAND_HOLDER
+ = new AtomicReference<>(System.getProperty(SSHD_STTY_COMMAND_PROP, DEFAULT_SSHD_STTY_COMMAND));
private static final AtomicReference<String> TTY_PROPS_HOLDER = new AtomicReference<>(null);
private static final AtomicLong TTY_PROPS_LAST_FETCHED_HOLDER = new AtomicLong(0L);
@@ -137,13 +137,13 @@ public final class SttySupport {
}
/**
- * <P>Returns the value of "stty size" width param.</P>
+ * <P>
+ * Returns the value of "stty size" width param.
+ * </P>
*
* <P>
- * <strong>Note</strong>: this method caches the value from the
- * first time it is called in order to increase speed, which means
- * that changing to size of the terminal will not be reflected
- * in the console.
+ * <strong>Note</strong>: this method caches the value from the first time it is called in order to increase speed,
+ * which means that changing to size of the terminal will not be reflected in the console.
* </P>
*
* @return The terminal width
@@ -157,18 +157,18 @@ public final class SttySupport {
return val;
} catch (Exception e) {
- return DEFAULT_TERMINAL_WIDTH; // debug breakpoint
+ return DEFAULT_TERMINAL_WIDTH; // debug breakpoint
}
}
/**
- * <P>Returns the value of "stty size" height param.</P>
+ * <P>
+ * Returns the value of "stty size" height param.
+ * </P>
*
* <P>
- * <strong>Note</strong>: this method caches the value from the
- * first time it is called in order to increase speed, which means
- * that changing to size of the terminal will not be reflected
- * in the console.
+ * <strong>Note</strong>: this method caches the value from the first time it is called in order to increase speed,
+ * which means that changing to size of the terminal will not be reflected in the console.
* </P>
*
* @return The terminal height
@@ -182,7 +182,7 @@ public final class SttySupport {
return val;
} catch (Exception e) {
- return DEFAULT_TERMINAL_HEIGHT; // debug breakpoint
+ return DEFAULT_TERMINAL_HEIGHT; // debug breakpoint
}
}
@@ -221,28 +221,26 @@ public final class SttySupport {
}
/**
- * Execute the stty command with the specified arguments
- * against the current active terminal.
+ * Execute the stty command with the specified arguments against the current active terminal.
*
- * @param args The command arguments
- * @return The execution result
- * @throws IOException If failed to execute the command
+ * @param args The command arguments
+ * @return The execution result
+ * @throws IOException If failed to execute the command
* @throws InterruptedException If interrupted while awaiting command execution
- * @see #exec(String)
+ * @see #exec(String)
*/
public static String stty(String args) throws IOException, InterruptedException {
return exec("stty " + args + " < /dev/tty").trim();
}
/**
- * Execute the specified command and return the output
- * (both stdout and stderr).
+ * Execute the specified command and return the output (both stdout and stderr).
*
- * @param cmd The command to execute
- * @return The execution result
- * @throws IOException If failed to execute the command
+ * @param cmd The command to execute
+ * @return The execution result
+ * @throws IOException If failed to execute the command
* @throws InterruptedException If interrupted while awaiting command execution
- * @see #exec(String[])
+ * @see #exec(String[])
*/
public static String exec(final String cmd)
throws IOException, InterruptedException {
@@ -250,12 +248,11 @@ public final class SttySupport {
}
/**
- * Execute the specified command and return the output
- * (both stdout and stderr).
+ * Execute the specified command and return the output (both stdout and stderr).
*
- * @param cmd The command components
- * @return The execution result
- * @throws IOException If failed to execute the command
+ * @param cmd The command components
+ * @return The execution result
+ * @throws IOException If failed to execute the command
* @throws InterruptedException If interrupted while awaiting command execution
*/
private static String exec(String... cmd)
@@ -286,16 +283,15 @@ public final class SttySupport {
/**
* @return The command to use to set the terminal options.
- * @see #setSttyCommand(String)
+ * @see #setSttyCommand(String)
*/
public static String getSttyCommand() {
return STTY_COMMAND_HOLDER.get();
}
/**
- * @param cmd The command to use to set the terminal options. Defaults
- * to {@link #DEFAULT_SSHD_STTY_COMMAND}, or the value of the
- * {@link #SSHD_STTY_COMMAND_PROP} system property if not set via this method
+ * @param cmd The command to use to set the terminal options. Defaults to {@link #DEFAULT_SSHD_STTY_COMMAND}, or the
+ * value of the {@link #SSHD_STTY_COMMAND_PROP} system property if not set via this method
*/
public static void setSttyCommand(String cmd) {
STTY_COMMAND_HOLDER.set(cmd);
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/cipher/BaseCipher.java b/sshd-common/src/main/java/org/apache/sshd/common/cipher/BaseCipher.java
index 1e35b50..7a855d1 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/cipher/BaseCipher.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/cipher/BaseCipher.java
@@ -41,8 +41,8 @@ public class BaseCipher implements Cipher {
private String s;
public BaseCipher(
- int ivsize, int kdfSize, String algorithm,
- int keySize, String transformation, int blkSize) {
+ int ivsize, int kdfSize, String algorithm,
+ int keySize, String transformation, int blkSize) {
this.ivsize = ivsize;
this.kdfSize = kdfSize;
this.algorithm = ValidateUtils.checkNotNullAndNotEmpty(algorithm, "No algorithm");
@@ -95,11 +95,11 @@ public class BaseCipher implements Cipher {
protected javax.crypto.Cipher createCipherInstance(Mode mode, byte[] key, byte[] iv) throws Exception {
javax.crypto.Cipher instance = SecurityUtils.getCipher(getTransformation());
instance.init(
- Mode.Encrypt.equals(mode)
- ? javax.crypto.Cipher.ENCRYPT_MODE
- : javax.crypto.Cipher.DECRYPT_MODE,
- new SecretKeySpec(key, getAlgorithm()),
- new IvParameterSpec(iv));
+ Mode.Encrypt.equals(mode)
+ ? javax.crypto.Cipher.ENCRYPT_MODE
+ : javax.crypto.Cipher.DECRYPT_MODE,
+ new SecretKeySpec(key, getAlgorithm()),
+ new IvParameterSpec(iv));
return instance;
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/cipher/BaseRC4Cipher.java b/sshd-common/src/main/java/org/apache/sshd/common/cipher/BaseRC4Cipher.java
index 0c91cf6..10ebb0f 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/cipher/BaseRC4Cipher.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/cipher/BaseRC4Cipher.java
@@ -34,17 +34,17 @@ public class BaseRC4Cipher extends BaseCipher {
@Override
protected byte[] initializeIVData(Mode mode, byte[] iv, int reqLen) {
- return iv; // not used in any way
+ return iv; // not used in any way
}
@Override
protected javax.crypto.Cipher createCipherInstance(Mode mode, byte[] key, byte[] iv) throws Exception {
javax.crypto.Cipher instance = SecurityUtils.getCipher(getTransformation());
instance.init(
- Mode.Encrypt.equals(mode)
- ? javax.crypto.Cipher.ENCRYPT_MODE
- : javax.crypto.Cipher.DECRYPT_MODE,
- new SecretKeySpec(key, getAlgorithm()));
+ Mode.Encrypt.equals(mode)
+ ? javax.crypto.Cipher.ENCRYPT_MODE
+ : javax.crypto.Cipher.DECRYPT_MODE,
+ new SecretKeySpec(key, getAlgorithm()));
byte[] foo = new byte[1];
for (int i = 0; i < SKIP_SIZE; i++) {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/cipher/BuiltinCiphers.java b/sshd-common/src/main/java/org/apache/sshd/common/cipher/BuiltinCiphers.java
index 91a908f..0f8a136 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/cipher/BuiltinCiphers.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/cipher/BuiltinCiphers.java
@@ -73,11 +73,9 @@ public enum BuiltinCiphers implements CipherFactory {
blowfishcbc(Constants.BLOWFISH_CBC, 8, 16, "Blowfish", 128, "Blowfish/CBC/NoPadding", 8),
tripledescbc(Constants.TRIPLE_DES_CBC, 8, 24, "DESede", 192, "DESede/CBC/NoPadding", 8);
- public static final Set<BuiltinCiphers> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(BuiltinCiphers.class));
+ public static final Set<BuiltinCiphers> VALUES = Collections.unmodifiableSet(EnumSet.allOf(BuiltinCiphers.class));
- private static final Map<String, CipherFactory> EXTENSIONS =
- new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ private static final Map<String, CipherFactory> EXTENSIONS = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
private final String factoryName;
private final int ivsize;
@@ -89,8 +87,8 @@ public enum BuiltinCiphers implements CipherFactory {
private final boolean supported;
BuiltinCiphers(
- String factoryName, int ivsize, int kdfSize,
- String algorithm, int keySize, String transformation, int blkSize) {
+ String factoryName, int ivsize, int kdfSize,
+ String algorithm, int keySize, String transformation, int blkSize) {
this.factoryName = factoryName;
this.ivsize = ivsize;
this.kdfSize = kdfSize;
@@ -99,9 +97,8 @@ public enum BuiltinCiphers implements CipherFactory {
this.transformation = transformation;
this.blkSize = blkSize;
/*
- * This can be done once since in order to change the support the JVM
- * needs to be stopped, some unlimited-strength files need be installed
- * and then the JVM re-started. Therefore, the answer is not going to
+ * This can be done once since in order to change the support the JVM needs to be stopped, some
+ * unlimited-strength files need be installed and then the JVM re-started. Therefore, the answer is not going to
* change while the JVM is running
*/
this.supported = Constants.NONE.equals(factoryName) || Cipher.checkSupported(this.transformation, this.keysize);
@@ -118,9 +115,8 @@ public enum BuiltinCiphers implements CipherFactory {
}
/**
- * @return {@code true} if the current JVM configuration supports this
- * cipher - e.g., AES-256 requires the <A HREF="http://www.oracle.com/technetwork/java/javase/downloads/">
- * Java Cryptography Extension (JCE)</A>
+ * @return {@code true} if the current JVM configuration supports this cipher - e.g., AES-256 requires the
+ * <A HREF="http://www.oracle.com/technetwork/java/javase/downloads/"> Java Cryptography Extension (JCE)</A>
*/
@Override
public boolean isSupported() {
@@ -160,18 +156,16 @@ public enum BuiltinCiphers implements CipherFactory {
@Override
public Cipher create() {
return new BaseCipher(
- getIVSize(), getKdfSize(), getAlgorithm(),
- getKeySize(), getTransformation(), getCipherBlockSize());
+ getIVSize(), getKdfSize(), getAlgorithm(),
+ getKeySize(), getTransformation(), getCipherBlockSize());
}
/**
- * Registered a {@link NamedFactory} to be available besides the built-in
- * ones when parsing configuration
+ * Registered a {@link NamedFactory} to be available besides the built-in ones when parsing configuration
*
- * @param extension The factory to register
- * @throws IllegalArgumentException if factory instance is {@code null},
- * or overrides a built-in one or overrides another registered factory
- * with the same name (case <U>insensitive</U>).
+ * @param extension The factory to register
+ * @throws IllegalArgumentException if factory instance is {@code null}, or overrides a built-in one or overrides
+ * another registered factory with the same name (case <U>insensitive</U>).
*/
public static void registerExtension(CipherFactory extension) {
String name = Objects.requireNonNull(extension, "No extension provided").getName();
@@ -184,8 +178,8 @@ public enum BuiltinCiphers implements CipherFactory {
}
/**
- * @return A {@link SortedSet} of the currently registered extensions, sorted
- * according to the factory name (case <U>insensitive</U>)
+ * @return A {@link SortedSet} of the currently registered extensions, sorted according to the factory name (case
+ * <U>insensitive</U>)
*/
public static NavigableSet<CipherFactory> getRegisteredExtensions() {
synchronized (EXTENSIONS) {
@@ -196,8 +190,8 @@ public enum BuiltinCiphers implements CipherFactory {
/**
* Unregisters specified extension
*
- * @param name The factory name - ignored if {@code null}/empty
- * @return The registered extension - {@code null} if not found
+ * @param name The factory name - ignored if {@code null}/empty
+ * @return The registered extension - {@code null} if not found
*/
public static NamedFactory<Cipher> unregisterExtension(String name) {
if (GenericUtils.isEmpty(name)) {
@@ -210,9 +204,9 @@ public enum BuiltinCiphers implements CipherFactory {
}
/**
- * @param s The {@link Enum}'s name - ignored if {@code null}/empty
- * @return The matching {@link BuiltinCiphers} whose {@link Enum#name()} matches
- * (case <U>insensitive</U>) the provided argument - {@code null} if no match
+ * @param s The {@link Enum}'s name - ignored if {@code null}/empty
+ * @return The matching {@link BuiltinCiphers} whose {@link Enum#name()} matches (case <U>insensitive</U>) the
+ * provided argument - {@code null} if no match
*/
public static BuiltinCiphers fromString(String s) {
if (GenericUtils.isEmpty(s)) {
@@ -229,10 +223,10 @@ public enum BuiltinCiphers implements CipherFactory {
}
/**
- * @param factory The {@link NamedFactory} for the cipher - ignored if {@code null}
- * @return The matching {@link BuiltinCiphers} whose factory name matches
- * (case <U>insensitive</U>) the cipher factory name
- * @see #fromFactoryName(String)
+ * @param factory The {@link NamedFactory} for the cipher - ignored if {@code null}
+ * @return The matching {@link BuiltinCiphers} whose factory name matches (case <U>insensitive</U>) the
+ * cipher factory name
+ * @see #fromFactoryName(String)
*/
public static BuiltinCiphers fromFactory(NamedFactory<Cipher> factory) {
if (factory == null) {
@@ -243,19 +237,18 @@ public enum BuiltinCiphers implements CipherFactory {
}
/**
- * @param name The factory name - ignored if {@code null}/empty
- * @return The matching {@link BuiltinCiphers} whose factory name matches
- * (case <U>insensitive</U>) the provided name - {@code null} if no match
+ * @param name The factory name - ignored if {@code null}/empty
+ * @return The matching {@link BuiltinCiphers} whose factory name matches (case <U>insensitive</U>) the
+ * provided name - {@code null} if no match
*/
public static BuiltinCiphers fromFactoryName(String name) {
return NamedResource.findByName(name, String.CASE_INSENSITIVE_ORDER, VALUES);
}
/**
- * @param ciphers A comma-separated list of ciphers' names - ignored if {@code null}/empty
- * @return A {@link ParseResult} containing the successfully parsed
- * factories and the unknown ones. <B>Note:</B> it is up to caller to
- * ensure that the lists do not contain duplicates
+ * @param ciphers A comma-separated list of ciphers' names - ignored if {@code null}/empty
+ * @return A {@link ParseResult} containing the successfully parsed factories and the unknown ones.
+ * <B>Note:</B> it is up to caller to ensure that the lists do not contain duplicates
*/
public static ParseResult parseCiphersList(String ciphers) {
return parseCiphersList(GenericUtils.split(ciphers, ','));
@@ -289,9 +282,8 @@ public enum BuiltinCiphers implements CipherFactory {
}
/**
- * @param name The factory name
- * @return The factory or {@code null} if it is neither a built-in one
- * or a registered extension
+ * @param name The factory name
+ * @return The factory or {@code null} if it is neither a built-in one or a registered extension
*/
public static CipherFactory resolveFactory(String name) {
if (GenericUtils.isEmpty(name)) {
@@ -323,8 +315,7 @@ public enum BuiltinCiphers implements CipherFactory {
public static final class Constants {
public static final String NONE = "none";
- public static final Pattern NONE_CIPHER_PATTERN =
- Pattern.compile("(^|.*,)" + NONE + "($|,.*)");
+ public static final Pattern NONE_CIPHER_PATTERN = Pattern.compile("(^|.*,)" + NONE + "($|,.*)");
public static final String AES128_CBC = "aes128-cbc";
public static final String AES128_CTR = "aes128-ctr";
@@ -342,8 +333,8 @@ public enum BuiltinCiphers implements CipherFactory {
}
/**
- * @param s A comma-separated list of ciphers - ignored if {@code null}/empty
- * @return {@code true} if the {@link #NONE} cipher name appears in it
+ * @param s A comma-separated list of ciphers - ignored if {@code null}/empty
+ * @return {@code true} if the {@link #NONE} cipher name appears in it
*/
public static boolean isNoneCipherIncluded(String s) {
if (GenericUtils.isEmpty(s)) {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/cipher/Cipher.java b/sshd-common/src/main/java/org/apache/sshd/common/cipher/Cipher.java
index 868e983..019f26e 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/cipher/Cipher.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/cipher/Cipher.java
@@ -22,24 +22,23 @@ import org.apache.sshd.common.util.NumberUtils;
import org.apache.sshd.common.util.ValidateUtils;
/**
- * Wrapper for a cryptographic cipher, used either for encryption
- * or decryption.
+ * Wrapper for a cryptographic cipher, used either for encryption or decryption.
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public interface Cipher extends CipherInformation {
enum Mode {
- Encrypt, Decrypt
+ Encrypt,
+ Decrypt
}
/**
- * Initialize the cipher for encryption or decryption with
- * the given key and initialization vector
+ * Initialize the cipher for encryption or decryption with the given key and initialization vector
*
- * @param mode Encrypt/Decrypt initialization
- * @param key Key bytes
- * @param iv Initialization vector bytes
+ * @param mode Encrypt/Decrypt initialization
+ * @param key Key bytes
+ * @param iv Initialization vector bytes
* @throws Exception If failed to initialize
*/
void init(Mode mode, byte[] key, byte[] iv) throws Exception;
@@ -47,9 +46,9 @@ public interface Cipher extends CipherInformation {
/**
* Performs in-place encryption or decryption on the given data.
*
- * @param input The input/output bytes
+ * @param input The input/output bytes
* @throws Exception If failed to execute
- * @see #update(byte[], int, int)
+ * @see #update(byte[], int, int)
*/
default void update(byte[] input) throws Exception {
update(input, 0, NumberUtils.length(input));
@@ -58,20 +57,18 @@ public interface Cipher extends CipherInformation {
/**
* Performs in-place encryption or decryption on the given data.
*
- * @param input The input/output bytes
- * @param inputOffset The offset of the data in the data buffer
- * @param inputLen The number of bytes to update - starting at the given offset
- * @throws Exception If failed to execute
+ * @param input The input/output bytes
+ * @param inputOffset The offset of the data in the data buffer
+ * @param inputLen The number of bytes to update - starting at the given offset
+ * @throws Exception If failed to execute
*/
void update(byte[] input, int inputOffset, int inputLen) throws Exception;
/**
- * @param xform The full cipher transformation - e.g., AES/CBC/NoPadding -
- * never {@code null}/empty
- * @param keyLength The required key length in bits - always positive
- * @return {@code true} if the cipher transformation <U>and</U> required
- * key length are supported
- * @see javax.crypto.Cipher#getMaxAllowedKeyLength(String)
+ * @param xform The full cipher transformation - e.g., AES/CBC/NoPadding - never {@code null}/empty
+ * @param keyLength The required key length in bits - always positive
+ * @return {@code true} if the cipher transformation <U>and</U> required key length are supported
+ * @see javax.crypto.Cipher#getMaxAllowedKeyLength(String)
*/
static boolean checkSupported(String xform, int keyLength) {
ValidateUtils.checkNotNullAndNotEmpty(xform, "No transformation");
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/cipher/CipherInformation.java b/sshd-common/src/main/java/org/apache/sshd/common/cipher/CipherInformation.java
index 98b79ec..743b3b2 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/cipher/CipherInformation.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/cipher/CipherInformation.java
@@ -39,10 +39,9 @@ public interface CipherInformation extends AlgorithmNameProvider, KeySizeIndicat
int getIVSize();
/**
- * @return Size of block data used by the cipher (in bytes). For stream
- * ciphers this value is (currently) used to indicate some average work
- * buffer size to be used for the automatic re-keying mechanism described
- * in <a href="https://tools.ietf.org/html/rfc4253#section-9">RFC 4253 - Section 9</a>
+ * @return Size of block data used by the cipher (in bytes). For stream ciphers this value is (currently) used to
+ * indicate some average work buffer size to be used for the automatic re-keying mechanism described in
+ * <a href="https://tools.ietf.org/html/rfc4253#section-9">RFC 4253 - Section 9</a>
*/
int getCipherBlockSize();
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/cipher/CipherNone.java b/sshd-common/src/main/java/org/apache/sshd/common/cipher/CipherNone.java
index 6d28149..90ddb73 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/cipher/CipherNone.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/cipher/CipherNone.java
@@ -19,10 +19,8 @@
package org.apache.sshd.common.cipher;
/**
- * Represents a no-op cipher.
- * This cipher can not really be used during authentication and should only
- * be used after, so that authentication remains secured, but not the remaining
- * of the exchanges.
+ * Represents a no-op cipher. This cipher can not really be used during authentication and should only be used after, so
+ * that authentication remains secured, but not the remaining of the exchanges.
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
@@ -48,17 +46,17 @@ public class CipherNone implements Cipher {
@Override
public int getIVSize() {
- return 8; // dummy - not zero in order to avoid some code that uses it as divisor
+ return 8; // dummy - not zero in order to avoid some code that uses it as divisor
}
@Override
public int getKdfSize() {
- return 16; // dummy - not zero in order to avoid some code that uses it as divisor
+ return 16; // dummy - not zero in order to avoid some code that uses it as divisor
}
@Override
public int getCipherBlockSize() {
- return 8; // dummy - not zero in order to avoid some code that uses it as divisor
+ return 8; // dummy - not zero in order to avoid some code that uses it as divisor
}
@Override
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java b/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java
index b0b2812..f8bee20 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java
@@ -58,70 +58,94 @@ import org.apache.sshd.common.util.security.SecurityUtils;
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResource, OptionalFeature {
- nistp256(Constants.NISTP256, new int[]{1, 2, 840, 10045, 3, 1, 7},
- new ECParameterSpec(
- new EllipticCurve(
- new ECFieldFp(new BigInteger("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", 16)),
- new BigInteger("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC", 16),
- new BigInteger("5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", 16)),
- new ECPoint(
- new BigInteger("6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296", 16),
- new BigInteger("4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5", 16)),
- new BigInteger("FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551", 16),
- 1),
- 32,
- BuiltinDigests.sha256),
- nistp384(Constants.NISTP384, new int[]{1, 3, 132, 0, 34},
- new ECParameterSpec(
- new EllipticCurve(
- new ECFieldFp(new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF", 16)),
- new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC", 16),
- new BigInteger("B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF", 16)),
- new ECPoint(
- new BigInteger("AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7", 16),
- new BigInteger("3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F", 16)),
- new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973", 16),
- 1),
- 48,
- BuiltinDigests.sha384),
- nistp521(Constants.NISTP521, new int[]{1, 3, 132, 0, 35},
- new ECParameterSpec(
- new EllipticCurve(
- new ECFieldFp(new BigInteger("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
- + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 16)),
- new BigInteger("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
- + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC", 16),
- new BigInteger("0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951"
- + "EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00", 16)),
- new ECPoint(
- new BigInteger("00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77"
- + "EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66", 16),
- new BigInteger("011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE7299"
- + "5EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650", 16)),
- new BigInteger("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B"
- + "7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409", 16),
- 1),
- 66,
- BuiltinDigests.sha512);
+ nistp256(Constants.NISTP256, new int[] { 1, 2, 840, 10045, 3, 1, 7 },
+ new ECParameterSpec(
+ new EllipticCurve(
+ new ECFieldFp(
+ new BigInteger("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", 16)),
+ new BigInteger("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC", 16),
+ new BigInteger("5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", 16)),
+ new ECPoint(
+ new BigInteger("6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296", 16),
+ new BigInteger("4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5", 16)),
+ new BigInteger("FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551", 16),
+ 1),
+ 32,
+ BuiltinDigests.sha256),
+ nistp384(Constants.NISTP384, new int[] { 1, 3, 132, 0, 34 },
+ new ECParameterSpec(
+ new EllipticCurve(
+ new ECFieldFp(
+ new BigInteger(
+ "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF",
+ 16)),
+ new BigInteger(
+ "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC",
+ 16),
+ new BigInteger(
+ "B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF",
+ 16)),
+ new ECPoint(
+ new BigInteger(
+ "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7",
+ 16),
+ new BigInteger(
+ "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F",
+ 16)),
+ new BigInteger(
+ "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973",
+ 16),
+ 1),
+ 48,
+ BuiltinDigests.sha384),
+ nistp521(Constants.NISTP521, new int[] { 1, 3, 132, 0, 35 },
+ new ECParameterSpec(
+ new EllipticCurve(
+ new ECFieldFp(
+ new BigInteger(
+ "01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
+ + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
+ 16)),
+ new BigInteger(
+ "01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
+ + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC",
+ 16),
+ new BigInteger(
+ "0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951"
+ + "EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00",
+ 16)),
+ new ECPoint(
+ new BigInteger(
+ "00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77"
+ + "EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66",
+ 16),
+ new BigInteger(
+ "011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE7299"
+ + "5EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650",
+ 16)),
+ new BigInteger(
+ "01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B"
+ + "7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409",
+ 16),
+ 1),
+ 66,
+ BuiltinDigests.sha512);
/**
* A {@link Set} of all the known curves
*/
- public static final Set<ECCurves> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(ECCurves.class));
+ public static final Set<ECCurves> VALUES = Collections.unmodifiableSet(EnumSet.allOf(ECCurves.class));
/**
* A {@link Set} of all the known curves names
*/
- public static final NavigableSet<String> NAMES =
- Collections.unmodifiableNavigableSet(
+ public static final NavigableSet<String> NAMES = Collections.unmodifiableNavigableSet(
GenericUtils.mapSort(VALUES, ECCurves::getName, String.CASE_INSENSITIVE_ORDER));
/**
* A {@link Set} of all the known curves key types
*/
- public static final NavigableSet<String> KEY_TYPES =
- Collections.unmodifiableNavigableSet(
+ public static final NavigableSet<String> KEY_TYPES = Collections.unmodifiableNavigableSet(
GenericUtils.mapSort(VALUES, ECCurves::getKeyType, String.CASE_INSENSITIVE_ORDER));
public static final Comparator<ECCurves> BY_KEY_SIZE = (o1, o2) -> {
@@ -130,8 +154,7 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
return Integer.compare(k1, k2);
};
- public static final List<ECCurves> SORTED_KEY_SIZE =
- Collections.unmodifiableList(VALUES.stream()
+ public static final List<ECCurves> SORTED_KEY_SIZE = Collections.unmodifiableList(VALUES.stream()
.sorted(BY_KEY_SIZE)
.collect(Collectors.toList()));
@@ -155,7 +178,7 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
this.digestFactory = Objects.requireNonNull(digestFactory, "No digestFactory");
}
- @Override // The curve's standard name
+ @Override // The curve's standard name
public final String getName() {
return name;
}
@@ -202,9 +225,8 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
}
/**
- * @param type The key type value - ignored if {@code null}/empty
- * @return The matching {@link ECCurves} constant - {@code null} if
- * no match found case <U>insensitive</U>
+ * @param type The key type value - ignored if {@code null}/empty
+ * @return The matching {@link ECCurves} constant - {@code null} if no match found case <U>insensitive</U>
*/
public static ECCurves fromKeyType(String type) {
if (GenericUtils.isEmpty(type)) {
@@ -221,28 +243,26 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
}
/**
- * @param name The curve name (case <U>insensitive</U> - ignored if {@code null}/empty
- * @return The matching {@link ECCurves} instance - {@code null} if no
- * match found
+ * @param name The curve name (case <U>insensitive</U> - ignored if {@code null}/empty
+ * @return The matching {@link ECCurves} instance - {@code null} if no match found
*/
public static ECCurves fromCurveName(String name) {
return NamedResource.findByName(name, String.CASE_INSENSITIVE_ORDER, VALUES);
}
/**
- * @param key The {@link ECKey} - ignored if {@code null}
- * @return The matching {@link ECCurves} instance - {@code null} if no
- * match found
+ * @param key The {@link ECKey} - ignored if {@code null}
+ * @return The matching {@link ECCurves} instance - {@code null} if no match found
*/
public static ECCurves fromECKey(ECKey key) {
return fromCurveParameters((key == null) ? null : key.getParams());
}
/**
- * @param params The curve's {@link ECParameterSpec} - ignored if {@code null}
- * @return The matching {@link ECCurves} value - {@code null} if no match found
- * @see #getCurveSize(ECParameterSpec)
- * @see #fromCurveSize(int)
+ * @param params The curve's {@link ECParameterSpec} - ignored if {@code null}
+ * @return The matching {@link ECCurves} value - {@code null} if no match found
+ * @see #getCurveSize(ECParameterSpec)
+ * @see #fromCurveSize(int)
*/
public static ECCurves fromCurveParameters(ECParameterSpec params) {
if (params == null) {
@@ -253,9 +273,8 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
}
/**
- * @param keySize The key size (in bits)
- * @return The matching {@link ECCurves} value - {@code null} if no
- * match found
+ * @param keySize The key size (in bits)
+ * @return The matching {@link ECCurves} value - {@code null} if no match found
*/
public static ECCurves fromCurveSize(int keySize) {
if (keySize <= 0) {
@@ -315,8 +334,8 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
}
/**
- * @param params The curve's {@link ECParameterSpec}
- * @return The curve's key size in bits
+ * @param params The curve's {@link ECParameterSpec}
+ * @return The curve's key size in bits
* @throws IllegalArgumentException if invalid parameters provided
*/
public static int getCurveSize(ECParameterSpec params) {
@@ -362,13 +381,12 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
}
/**
- * Converts the given octet string (defined by ASN.1 specifications) to a {@link BigInteger}
- * As octet strings always represent positive integers, a zero-byte is prepended to
- * the given array if necessary (if is MSB equal to 1), then this is converted to BigInteger
- * The conversion is defined in the Section 2.3.8
+ * Converts the given octet string (defined by ASN.1 specifications) to a {@link BigInteger} As octet strings always
+ * represent positive integers, a zero-byte is prepended to the given array if necessary (if is MSB equal to 1),
+ * then this is converted to BigInteger The conversion is defined in the Section 2.3.8
*
- * @param octets - octet string bytes to be converted
- * @return The {@link BigInteger} representation of the octet string
+ * @param octets - octet string bytes to be converted
+ * @return The {@link BigInteger} representation of the octet string
*/
public static BigInteger octetStringToInteger(byte... octets) {
if (octets == null) {
@@ -393,7 +411,8 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
byte indicator = octets[startIndex];
ECCurves.ECPointCompression compression = ECCurves.ECPointCompression.fromIndicatorValue(indicator);
if (compression == null) {
- throw new UnsupportedOperationException("Unknown compression indicator value: 0x" + Integer.toHexString(indicator & 0xFF));
+ throw new UnsupportedOperationException(
+ "Unknown compression indicator value: 0x" + Integer.toHexString(indicator & 0xFF));
}
// The coordinates actually start after the compression indicator
@@ -411,7 +430,7 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
}
}
- return -1; // all zeroes
+ return -1; // all zeroes
}
public static final class Constants {
@@ -433,11 +452,12 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
* The various {@link ECPoint} representation compression indicators
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- * @see <A HREF="https://tools.ietf.org/html/rfc5480#section-2.2">RFC-5480 - section 2.2</A>
+ * @see <A HREF="https://tools.ietf.org/html/rfc5480#section-2.2">RFC-5480 - section 2.2</A>
*/
public enum ECPointCompression {
// see http://tools.ietf.org/html/draft-jivsov-ecc-compact-00
- // see http://crypto.stackexchange.com/questions/8914/ecdsa-compressed-public-key-point-back-to-uncompressed-public-key-point
+ // see
+ // http://crypto.stackexchange.com/questions/8914/ecdsa-compressed-public-key-point-back-to-uncompressed-public-key-point
VARIANT2((byte) 0x02) {
@Override
public ECPoint octetStringToEcPoint(byte[] octets, int startIndex, int len) {
@@ -446,7 +466,8 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
BigInteger x = octetStringToInteger(xp);
// TODO derive even Y...
- throw new UnsupportedOperationException("octetStringToEcPoint(" + name() + ")(X=" + x + ") compression support N/A");
+ throw new UnsupportedOperationException(
+ "octetStringToEcPoint(" + name() + ")(X=" + x + ") compression support N/A");
}
},
VARIANT3((byte) 0x03) {
@@ -457,17 +478,19 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
BigInteger x = octetStringToInteger(xp);
// TODO derive odd Y...
- throw new UnsupportedOperationException("octetStringToEcPoint(" + name() + ")(X=" + x + ") compression support N/A");
+ throw new UnsupportedOperationException(
+ "octetStringToEcPoint(" + name() + ")(X=" + x + ") compression support N/A");
}
},
UNCOMPRESSED((byte) 0x04) {
@Override
public ECPoint octetStringToEcPoint(byte[] octets, int startIndex, int len) {
- int numElements = len / 2; /* x, y */
- if (len != (numElements * 2)) { // make sure length is not odd
- throw new IllegalArgumentException("octetStringToEcPoint(" + name() + ") "
- + " invalid remainder octets representation: "
- + " expected=" + (2 * numElements) + ", actual=" + len);
+ int numElements = len / 2; /* x, y */
+ if (len != (numElements * 2)) { // make sure length is not odd
+ throw new IllegalArgumentException(
+ "octetStringToEcPoint(" + name() + ") "
+ + " invalid remainder octets representation: "
+ + " expected=" + (2 * numElements) + ", actual=" + len);
}
byte[] xp = new byte[numElements];
@@ -484,7 +507,8 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
public void writeECPoint(OutputStream s, String curveName, ECPoint p) throws IOException {
ECCurves curve = fromCurveName(curveName);
if (curve == null) {
- throw new StreamCorruptedException("writeECPoint(" + name() + ")[" + curveName + "] cannot determine octets count");
+ throw new StreamCorruptedException(
+ "writeECPoint(" + name() + ")[" + curveName + "] cannot determine octets count");
}
int numElements = curve.getNumPointOctets();
@@ -495,8 +519,8 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
}
};
- public static final Set<ECPointCompression> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(ECPointCompression.class));
+ public static final Set<ECPointCompression> VALUES
+ = Collections.unmodifiableSet(EnumSet.allOf(ECPointCompression.class));
private final byte indicatorValue;
@@ -515,9 +539,10 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
writeECPoint(baos, curveName, p);
return baos.toByteArray();
} catch (IOException e) {
- throw new RuntimeException("ecPointToOctetString(" + curveName + ")"
- + " failed (" + e.getClass().getSimpleName() + ")"
- + " to write data: " + e.getMessage(),
+ throw new RuntimeException(
+ "ecPointToOctetString(" + curveName + ")"
+ + " failed (" + e.getClass().getSimpleName() + ")"
+ + " to write data: " + e.getMessage(),
e);
}
}
@@ -535,16 +560,17 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
int startIndex = 0;
int vLen = vp.length;
if (vLen > numElements) {
- if (vp[0] == 0) { // skip artificial positive sign
+ if (vp[0] == 0) { // skip artificial positive sign
startIndex++;
vLen--;
}
}
if (vLen > numElements) {
- throw new StreamCorruptedException("writeCoordinate(" + name() + ")[" + n + "]"
- + " value length (" + vLen + ") exceeds max. (" + numElements + ")"
- + " for " + v);
+ throw new StreamCorruptedException(
+ "writeCoordinate(" + name() + ")[" + n + "]"
+ + " value length (" + vLen + ") exceeds max. (" + numElements + ")"
+ + " for " + v);
}
if (vLen < numElements) {
@@ -560,7 +586,7 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
public static ECPointCompression fromIndicatorValue(int value) {
if ((value < 0) || (value > 0xFF)) {
- return null; // must be a byte value
+ return null; // must be a byte value
}
for (ECPointCompression c : VALUES) {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/cipher/package.html b/sshd-common/src/main/java/org/apache/sshd/common/cipher/package.html
index 197a89d..3847e57 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/cipher/package.html
+++ b/sshd-common/src/main/java/org/apache/sshd/common/cipher/package.html
@@ -15,12 +15,12 @@
limitations under the License.
-->
<html>
-<head>
-</head>
-<body>
-
-<a href="{@docRoot}/org/apache/sshd/common/cipher/Cipher.html"><code>Cipher</code></a>
-implementations.
-
-</body>
-</html>
+ <head>
+ </head>
+ <body>
+ <a href="{@docRoot}/org/apache/sshd/common/cipher/Cipher.html">
+ <code>Cipher</code>
+ </a>
+ implementations.
+ </body>
+</html>
\ No newline at end of file
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/compression/BuiltinCompressions.java b/sshd-common/src/main/java/org/apache/sshd/common/compression/BuiltinCompressions.java
index 7360b13..cc02e09 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/compression/BuiltinCompressions.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/compression/BuiltinCompressions.java
@@ -70,11 +70,9 @@ public enum BuiltinCompressions implements CompressionFactory {
}
};
- public static final Set<BuiltinCompressions> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(BuiltinCompressions.class));
+ public static final Set<BuiltinCompressions> VALUES = Collections.unmodifiableSet(EnumSet.allOf(BuiltinCompressions.class));
- private static final Map<String, CompressionFactory> EXTENSIONS =
- new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ private static final Map<String, CompressionFactory> EXTENSIONS = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
private final String name;
@@ -108,13 +106,12 @@ public enum BuiltinCompressions implements CompressionFactory {
}
/**
- * Registered a {@link org.apache.sshd.common.NamedFactory} to be available besides the built-in
- * ones when parsing configuration
+ * Registered a {@link org.apache.sshd.common.NamedFactory} to be available besides the built-in ones when parsing
+ * configuration
*
- * @param extension The factory to register
- * @throws IllegalArgumentException if factory instance is {@code null},
- * or overrides a built-in one or overrides another registered factory
- * with the same name (case <U>insensitive</U>).
+ * @param extension The factory to register
+ * @throws IllegalArgumentException if factory instance is {@code null}, or overrides a built-in one or overrides
+ * another registered factory with the same name (case <U>insensitive</U>).
*/
public static void registerExtension(CompressionFactory extension) {
String name = Objects.requireNonNull(extension, "No extension provided").getName();
@@ -127,8 +124,8 @@ public enum BuiltinCompressions implements CompressionFactory {
}
/**
- * @return A {@link SortedSet} of the currently registered extensions, sorted
- * according to the factory name (case <U>insensitive</U>)
+ * @return A {@link SortedSet} of the currently registered extensions, sorted according to the factory name (case
+ * <U>insensitive</U>)
*/
public static NavigableSet<CompressionFactory> getRegisteredExtensions() {
synchronized (EXTENSIONS) {
@@ -139,8 +136,8 @@ public enum BuiltinCompressions implements CompressionFactory {
/**
* Unregisters specified extension
*
- * @param name The factory name - ignored if {@code null}/empty
- * @return The registered extension - {@code null} if not found
+ * @param name The factory name - ignored if {@code null}/empty
+ * @return The registered extension - {@code null} if not found
*/
public static CompressionFactory unregisterExtension(String name) {
if (GenericUtils.isEmpty(name)) {
@@ -157,18 +154,17 @@ public enum BuiltinCompressions implements CompressionFactory {
}
/**
- * @param compressions A comma-separated list of Compressions' names - ignored
- * if {@code null}/empty
- * @return A {@link ParseResult} containing the successfully parsed
- * factories and the unknown ones. <B>Note:</B> it is up to caller to
- * ensure that the lists do not contain duplicates
+ * @param compressions A comma-separated list of Compressions' names - ignored if {@code null}/empty
+ * @return A {@link ParseResult} containing the successfully parsed factories and the unknown ones.
+ * <B>Note:</B> it is up to caller to ensure that the lists do not contain duplicates
*/
public static ParseResult parseCompressionsList(String compressions) {
return parseCompressionsList(GenericUtils.split(compressions, ','));
}
public static ParseResult parseCompressionsList(String... compressions) {
- return parseCompressionsList(GenericUtils.isEmpty((Object[]) compressions) ? Collections.emptyList() : Arrays.asList(compressions));
+ return parseCompressionsList(
+ GenericUtils.isEmpty((Object[]) compressions) ? Collections.emptyList() : Arrays.asList(compressions));
}
public static ParseResult parseCompressionsList(Collection<String> compressions) {
@@ -195,9 +191,8 @@ public enum BuiltinCompressions implements CompressionFactory {
}
/**
- * @param name The factory name
- * @return The factory or {@code null} if it is neither a built-in one
- * or a registered extension
+ * @param name The factory name
+ * @return The factory or {@code null} if it is neither a built-in one or a registered extension
*/
public static CompressionFactory resolveFactory(String name) {
if (GenericUtils.isEmpty(name)) {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/compression/Compression.java b/sshd-common/src/main/java/org/apache/sshd/common/compression/Compression.java
index 91ac27e..23a94af 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/compression/Compression.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/compression/Compression.java
@@ -23,16 +23,14 @@ import java.io.IOException;
import org.apache.sshd.common.util.buffer.Buffer;
/**
- * Interface used to compress the stream of data between the
- * SSH server and clients.
+ * Interface used to compress the stream of data between the SSH server and clients.
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public interface Compression extends CompressionInformation {
/**
- * Enum identifying if this object will be used to compress
- * or uncompress data.
+ * Enum identifying if this object will be used to compress or uncompress data.
*/
enum Type {
Inflater,
@@ -40,12 +38,9 @@ public interface Compression extends CompressionInformation {
}
/**
- * Initialize this object to either compress or uncompress data.
- * This method must be called prior to any calls to either
- * <code>compress</code> or <code>uncompress</code>.
- * Once the object has been initialized, only one of
- * <code>compress</code> or <code>uncompress</code> methods can be
- * called.
+ * Initialize this object to either compress or uncompress data. This method must be called prior to any calls to
+ * either <code>compress</code> or <code>uncompress</code>. Once the object has been initialized, only one of
+ * <code>compress</code> or <code>uncompress</code> methods can be called.
*
* @param type compression type
* @param level compression level
@@ -55,7 +50,7 @@ public interface Compression extends CompressionInformation {
/**
* Compress the given buffer in place.
*
- * @param buffer the buffer containing the data to compress
+ * @param buffer the buffer containing the data to compress
* @throws IOException if an error occurs
*/
void compress(Buffer buffer) throws IOException;
@@ -63,8 +58,8 @@ public interface Compression extends CompressionInformation {
/**
* Uncompress the data in a buffer into another buffer.
*
- * @param from the buffer containing the data to uncompress
- * @param to the buffer receiving the uncompressed data
+ * @param from the buffer containing the data to uncompress
+ * @param to the buffer receiving the uncompressed data
* @throws IOException if an error occurs
*/
void uncompress(Buffer from, Buffer to) throws IOException;
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/compression/CompressionDelayedZlib.java b/sshd-common/src/main/java/org/apache/sshd/common/compression/CompressionDelayedZlib.java
index 99dec8b..51d0d8e 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/compression/CompressionDelayedZlib.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/compression/CompressionDelayedZlib.java
@@ -22,7 +22,7 @@ package org.apache.sshd.common.compression;
* ZLib delayed compression.
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- * @see Compression#isDelayed()
+ * @see Compression#isDelayed()
*/
public class CompressionDelayedZlib extends CompressionZlib {
/**
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/compression/CompressionInformation.java b/sshd-common/src/main/java/org/apache/sshd/common/compression/CompressionInformation.java
index 428689f..53f7e4c 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/compression/CompressionInformation.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/compression/CompressionInformation.java
@@ -26,17 +26,16 @@ import org.apache.sshd.common.NamedResource;
*/
public interface CompressionInformation extends NamedResource {
/**
- * Delayed compression is an Open-SSH specific feature which
- * informs both the client and server to not compress data before
- * the session has been authenticated.
+ * Delayed compression is an Open-SSH specific feature which informs both the client and server to not compress data
+ * before the session has been authenticated.
*
* @return if the compression is delayed after authentication or not
*/
boolean isDelayed();
/**
- * @return {@code true} if there is any compression executed by
- * this "compressor" - special case for 'none'
+ * @return {@code true} if there is any compression executed by this "compressor" - special case for
+ * 'none'
*/
boolean isCompressionExecuted();
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/compression/CompressionZlib.java b/sshd-common/src/main/java/org/apache/sshd/common/compression/CompressionZlib.java
index e365b91..2f5eb22 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/compression/CompressionZlib.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/compression/CompressionZlib.java
@@ -65,8 +65,8 @@ public class CompressionZlib extends BaseCompression {
compresser.setInput(buffer.array(), buffer.rpos(), buffer.available());
buffer.wpos(buffer.rpos());
for (int len = compresser.deflate(tmpbuf, 0, tmpbuf.length, Deflater.SYNC_FLUSH);
- len > 0;
- len = compresser.deflate(tmpbuf, 0, tmpbuf.length, Deflater.SYNC_FLUSH)) {
+ len > 0;
+ len = compresser.deflate(tmpbuf, 0, tmpbuf.length, Deflater.SYNC_FLUSH)) {
buffer.putRawBytes(tmpbuf, 0, len);
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/compression/package.html b/sshd-common/src/main/java/org/apache/sshd/common/compression/package.html
index 9bd4652..febf428 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/compression/package.html
+++ b/sshd-common/src/main/java/org/apache/sshd/common/compression/package.html
@@ -15,11 +15,12 @@
limitations under the License.
-->
<html>
-<head>
-</head>
-<body>
-
-<a href="{@docRoot}/org/apache/sshd/common/compression/Compression.html"><code>Compression</code></a> implementations.
-
-</body>
-</html>
+ <head>
+ </head>
+ <body>
+ <a href="{@docRoot}/org/apache/sshd/common/compression/Compression.html">
+ <code>Compression</code>
+ </a>
+ implementations.
+ </body>
+</html>
\ No newline at end of file
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/CompressionConfigValue.java b/sshd-common/src/main/java/org/apache/sshd/common/config/CompressionConfigValue.java
index 5df4d1b..712b974 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/CompressionConfigValue.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/CompressionConfigValue.java
@@ -29,8 +29,8 @@ import org.apache.sshd.common.compression.CompressionFactory;
import org.apache.sshd.common.util.GenericUtils;
/**
- * Provides a "bridge" between the configuration values and the
- * actual {@link org.apache.sshd.common.NamedFactory} for the {@link Compression}.
+ * Provides a "bridge" between the configuration values and the actual
+ * {@link org.apache.sshd.common.NamedFactory} for the {@link Compression}.
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
@@ -39,8 +39,8 @@ public enum CompressionConfigValue implements CompressionFactory {
NO(BuiltinCompressions.none),
DELAYED(BuiltinCompressions.delayedZlib);
- public static final Set<CompressionConfigValue> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(CompressionConfigValue.class));
+ public static final Set<CompressionConfigValue> VALUES
+ = Collections.unmodifiableSet(EnumSet.allOf(CompressionConfigValue.class));
private final CompressionFactory factory;
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/ConfigFileReaderSupport.java b/sshd-common/src/main/java/org/apache/sshd/common/config/ConfigFileReaderSupport.java
index ec6c114..cd794c5 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/ConfigFileReaderSupport.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/ConfigFileReaderSupport.java
@@ -46,7 +46,7 @@ import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- * @see <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh_config&sektion=5">ssh_config(5)</a>
+ * @see <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh_config&sektion=5">ssh_config(5)</a>
*/
public final class ConfigFileReaderSupport {
@@ -70,14 +70,12 @@ public final class ConfigFileReaderSupport {
public static final boolean DEFAULT_KBD_INTERACTIVE_AUTH_VALUE = parseBooleanValue(DEFAULT_KBD_INTERACTIVE_AUTH);
public static final String PREFERRED_AUTHS_CONFIG_PROP = "PreferredAuthentications";
- public static final List<String> DEFAULT_PREFERRED_AUTHS =
- Collections.unmodifiableList(
+ public static final List<String> DEFAULT_PREFERRED_AUTHS = Collections.unmodifiableList(
Arrays.asList(
- UserAuthMethodFactory.PUBLIC_KEY,
- UserAuthMethodFactory.KB_INTERACTIVE,
- UserAuthMethodFactory.PASSWORD));
- public static final String DEFAULT_PREFERRED_AUTHS_VALUE =
- GenericUtils.join(DEFAULT_PREFERRED_AUTHS, ',');
+ UserAuthMethodFactory.PUBLIC_KEY,
+ UserAuthMethodFactory.KB_INTERACTIVE,
+ UserAuthMethodFactory.PASSWORD));
+ public static final String DEFAULT_PREFERRED_AUTHS_VALUE = GenericUtils.join(DEFAULT_PREFERRED_AUTHS, ',');
public static final String LISTEN_ADDRESS_CONFIG_PROP = "ListenAddress";
public static final String DEFAULT_BIND_ADDRESS = SshdSocketAddress.IPV4_ANYADDR;
@@ -98,30 +96,27 @@ public final class ConfigFileReaderSupport {
public static final long DEFAULT_REKEY_TIME_LIMIT = TimeUnit.HOURS.toMillis(1L);
// see http://manpages.ubuntu.com/manpages/precise/en/man5/sshd_config.5.html
public static final String CIPHERS_CONFIG_PROP = "Ciphers";
- public static final String DEFAULT_CIPHERS =
- "aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc"
- + ",blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour";
+ public static final String DEFAULT_CIPHERS = "aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc"
+ + ",blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour";
// see http://manpages.ubuntu.com/manpages/precise/en/man5/sshd_config.5.html
public static final String MACS_CONFIG_PROP = "MACs";
- public static final String DEFAULT_MACS =
- "hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96"
- + ",hmac-md5-96,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96";
+ public static final String DEFAULT_MACS = "hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96"
+ + ",hmac-md5-96,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96";
// see http://manpages.ubuntu.com/manpages/precise/en/man5/sshd_config.5.html
public static final String KEX_ALGORITHMS_CONFIG_PROP = "KexAlgorithms";
- public static final String DEFAULT_KEX_ALGORITHMS =
- "ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521"
- + "," + "diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1"
- // RFC-8268 groups
- + "," + "diffie-hellman-group18-sha512,diffie-hellman-group17-sha512"
- + "," + "diffie-hellman-group16-sha512,diffie-hellman-group15-sha512"
- + "," + "diffie-hellman-group14-sha256"
- // Legacy groups
- + "," + "diffie-hellman-group14-sha1,diffie-hellman-group1-sha1";
+ public static final String DEFAULT_KEX_ALGORITHMS = "ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521"
+ + ","
+ + "diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1"
+ // RFC-8268 groups
+ + "," + "diffie-hellman-group18-sha512,diffie-hellman-group17-sha512"
+ + "," + "diffie-hellman-group16-sha512,diffie-hellman-group15-sha512"
+ + "," + "diffie-hellman-group14-sha256"
+ // Legacy groups
+ + "," + "diffie-hellman-group14-sha1,diffie-hellman-group1-sha1";
// see http://linux.die.net/man/5/ssh_config
public static final String HOST_KEY_ALGORITHMS_CONFIG_PROP = "HostKeyAlgorithms";
// see https://tools.ietf.org/html/rfc5656
- public static final String DEFAULT_HOST_KEY_ALGORITHMS =
- KeyPairProvider.SSH_RSA + "," + KeyPairProvider.SSH_DSS;
+ public static final String DEFAULT_HOST_KEY_ALGORITHMS = KeyPairProvider.SSH_RSA + "," + KeyPairProvider.SSH_DSS;
// see http://manpages.ubuntu.com/manpages/precise/en/man5/sshd_config.5.html
public static final String LOG_LEVEL_CONFIG_PROP = "LogLevel";
public static final LogLevelValue DEFAULT_LOG_LEVEL = LogLevelValue.INFO;
@@ -160,13 +155,12 @@ public final class ConfigFileReaderSupport {
}
/**
- * Reads the configuration file contents into a {@link Properties} instance.
- * <B>Note:</B> multiple keys value are concatenated using a comma - it is up to
- * the caller to know which keys are expected to have multiple values and handle
- * the split accordingly
+ * Reads the configuration file contents into a {@link Properties} instance. <B>Note:</B> multiple keys value are
+ * concatenated using a comma - it is up to the caller to know which keys are expected to have multiple values and
+ * handle the split accordingly
*
- * @param rdr The {@link BufferedReader} for reading the file
- * @return The read properties
+ * @param rdr The {@link BufferedReader} for reading the file
+ * @return The read properties
* @throws IOException If failed to read or malformed content
*/
public static Properties readConfigFile(BufferedReader rdr) throws IOException {
@@ -189,8 +183,8 @@ public final class ConfigFileReaderSupport {
}
/*
- * Some options use '=', others use ' ' - try both
- * NOTE: we do not validate the format for each option separately
+ * Some options use '=', others use ' ' - try both NOTE: we do not validate the format for each option
+ * separately
*/
pos = line.indexOf(' ');
if (pos < 0) {
@@ -216,11 +210,10 @@ public final class ConfigFileReaderSupport {
}
/**
- * @param v Checks if the value is "yes", "y",
- * "on", "t" or "true".
- * @return The result - <B>Note:</B> {@code null}/empty values are
- * interpreted as {@code false}
- * @see PropertyResolverUtils#TRUE_VALUES
+ * @param v Checks if the value is "yes", "y", "on", "t" or
+ * "true".
+ * @return The result - <B>Note:</B> {@code null}/empty values are interpreted as {@code false}
+ * @see PropertyResolverUtils#TRUE_VALUES
*/
public static boolean parseBooleanValue(String v) {
if (GenericUtils.isEmpty(v)) {
@@ -231,11 +224,10 @@ public final class ConfigFileReaderSupport {
}
/**
- * Returns a "yes" or "no" value based on the input
- * parameter
+ * Returns a "yes" or "no" value based on the input parameter
*
- * @param flag The required state
- * @return "yes" if {@code true}, "no" otherwise
+ * @param flag The required state
+ * @return "yes" if {@code true}, "no" otherwise
*/
public static String yesNoValueOf(boolean flag) {
return flag ? "yes" : "no";
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/FactoriesListParseResult.java b/sshd-common/src/main/java/org/apache/sshd/common/config/FactoriesListParseResult.java
index ea529c1..6d425c0 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/FactoriesListParseResult.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/FactoriesListParseResult.java
@@ -25,9 +25,9 @@ import org.apache.sshd.common.Factory;
import org.apache.sshd.common.NamedResource;
/**
- * @param <T> Result type
- * @param <F> Factory type
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ * @param <T> Result type
+ * @param <F> Factory type
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public abstract class FactoriesListParseResult<T, F extends NamedResource> extends ListParseResult<F> {
protected FactoriesListParseResult(List<F> parsed, List<String> unsupported) {
@@ -35,18 +35,17 @@ public abstract class FactoriesListParseResult<T, F extends NamedResource> exten
}
/**
- * @return The {@link List} of successfully parsed {@link Factory} instances
- * in the <U>same order</U> as they were encountered during parsing
+ * @return The {@link List} of successfully parsed {@link Factory} instances in the <U>same order</U> as they were
+ * encountered during parsing
*/
public final List<F> getParsedFactories() {
return getParsedValues();
}
/**
- * @return A {@link List} of unknown/unsupported configuration values for
- * the factories
+ * @return A {@link List} of unknown/unsupported configuration values for the factories
*/
public List<String> getUnsupportedFactories() {
return getUnsupportedValues();
}
-}
\ No newline at end of file
+}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/ListParseResult.java b/sshd-common/src/main/java/org/apache/sshd/common/config/ListParseResult.java
index 97590cb..f160234 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/ListParseResult.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/ListParseResult.java
@@ -24,14 +24,13 @@ import java.util.List;
import org.apache.sshd.common.util.GenericUtils;
/**
- * Used to hold the result of parsing a list of value. Such result contains known
- * and unknown values - which are accessible via the respective {@link #getParsedValues()}
- * and {@link #getUnsupportedValues()} methods. <B>Note:</B> the returned {@link List}s may
- * be un-modifiable, so it is recommended to avoid attempting changing the, returned
+ * Used to hold the result of parsing a list of value. Such result contains known and unknown values - which are
+ * accessible via the respective {@link #getParsedValues()} and {@link #getUnsupportedValues()} methods. <B>Note:</B>
+ * the returned {@link List}s may be un-modifiable, so it is recommended to avoid attempting changing the, returned
* list(s)
*
- * @param <E> Type of list item
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ * @param <E> Type of list item
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public abstract class ListParseResult<E> {
private final List<E> parsed;
@@ -43,16 +42,15 @@ public abstract class ListParseResult<E> {
}
/**
- * @return The {@link List} of successfully parsed value instances
- * in the <U>same order</U> as they were encountered during parsing
+ * @return The {@link List} of successfully parsed value instances in the <U>same order</U> as they were encountered
+ * during parsing
*/
public final List<E> getParsedValues() {
return parsed;
}
/**
- * @return A {@link List} of unknown/unsupported configuration values for
- * the factories
+ * @return A {@link List} of unknown/unsupported configuration values for the factories
*/
public List<String> getUnsupportedValues() {
return unsupported;
@@ -61,6 +59,6 @@ public abstract class ListParseResult<E> {
@Override
public String toString() {
return "parsed=" + GenericUtils.join(getParsedValues(), ',')
- + ";unsupported=" + GenericUtils.join(getUnsupportedValues(), ',');
+ + ";unsupported=" + GenericUtils.join(getUnsupportedValues(), ',');
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/LogLevelValue.java b/sshd-common/src/main/java/org/apache/sshd/common/config/LogLevelValue.java
index d3b8a6a..ba5d958 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/LogLevelValue.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/LogLevelValue.java
@@ -28,13 +28,12 @@ import org.apache.sshd.common.util.GenericUtils;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- * @see <A HREF="http://manpages.ubuntu.com/manpages/precise/en/man5/sshd_config.5.html"><I>LogLevel</I> configuration value</A>
+ * @see <A HREF="http://manpages.ubuntu.com/manpages/precise/en/man5/sshd_config.5.html"><I>LogLevel</I>
+ * configuration value</A>
*/
public enum LogLevelValue {
/*
- * NOTE(s):
- * 1. DEBUG and DEBUG1 are EQUIVALENT
- * 2. Order is important (!!!)
+ * NOTE(s): 1. DEBUG and DEBUG1 are EQUIVALENT 2. Order is important (!!!)
*/
QUIET(Level.OFF),
FATAL(Level.SEVERE),
@@ -46,8 +45,7 @@ public enum LogLevelValue {
DEBUG2(Level.FINER),
DEBUG3(Level.FINEST);
- public static final Set<LogLevelValue> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(LogLevelValue.class));
+ public static final Set<LogLevelValue> VALUES = Collections.unmodifiableSet(EnumSet.allOf(LogLevelValue.class));
private final Level level;
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/NamedFactoriesListParseResult.java b/sshd-common/src/main/java/org/apache/sshd/common/config/NamedFactoriesListParseResult.java
index 0ca8072..3935b25 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/NamedFactoriesListParseResult.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/NamedFactoriesListParseResult.java
@@ -28,9 +28,9 @@ import org.apache.sshd.common.util.GenericUtils;
/**
* Holds the result of parsing a list of {@link NamedFactory}ies
*
- * @param <T> Result type
- * @param <F> Factory type
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ * @param <T> Result type
+ * @param <F> Factory type
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public abstract class NamedFactoriesListParseResult<T, F extends NamedResource>
extends FactoriesListParseResult<T, F> {
@@ -42,6 +42,6 @@ public abstract class NamedFactoriesListParseResult<T, F extends NamedResource>
@Override
public String toString() {
return "parsed=" + NamedResource.getNames(getParsedFactories())
- + ";unknown=" + GenericUtils.join(getUnsupportedFactories(), ',');
+ + ";unknown=" + GenericUtils.join(getUnsupportedFactories(), ',');
}
-}
\ No newline at end of file
+}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/NamedResourceListParseResult.java b/sshd-common/src/main/java/org/apache/sshd/common/config/NamedResourceListParseResult.java
index feb45f4..c90079b 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/NamedResourceListParseResult.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/NamedResourceListParseResult.java
@@ -25,8 +25,8 @@ import org.apache.sshd.common.NamedResource;
import org.apache.sshd.common.util.GenericUtils;
/**
- * @param <R> Type of result {@link NamedResource}
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ * @param <R> Type of result {@link NamedResource}
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public abstract class NamedResourceListParseResult<R extends NamedResource> extends ListParseResult<R> {
protected NamedResourceListParseResult(List<R> parsed, List<String> unsupported) {
@@ -34,16 +34,15 @@ public abstract class NamedResourceListParseResult<R extends NamedResource> exte
}
/**
- * @return The {@link List} of successfully parsed {@link NamedResource} instances
- * in the <U>same order</U> as they were encountered during parsing
+ * @return The {@link List} of successfully parsed {@link NamedResource} instances in the <U>same order</U> as they
+ * were encountered during parsing
*/
public final List<R> getParsedResources() {
return getParsedValues();
}
/**
- * @return A {@link List} of unknown/unsupported configuration values for
- * the resources
+ * @return A {@link List} of unknown/unsupported configuration values for the resources
*/
public List<String> getUnsupportedResources() {
return getUnsupportedValues();
@@ -52,6 +51,6 @@ public abstract class NamedResourceListParseResult<R extends NamedResource> exte
@Override
public String toString() {
return "parsed=" + NamedResource.getNames(getParsedResources())
- + ";unknown=" + GenericUtils.join(getUnsupportedResources(), ',');
+ + ";unknown=" + GenericUtils.join(getUnsupportedResources(), ',');
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/SyslogFacilityValue.java b/sshd-common/src/main/java/org/apache/sshd/common/config/SyslogFacilityValue.java
index 9a42e80..bada926 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/SyslogFacilityValue.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/SyslogFacilityValue.java
@@ -27,7 +27,8 @@ import org.apache.sshd.common.util.GenericUtils;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- * @see <A HREF="https://www.freebsd.org/cgi/man.cgi?query=sshd_config&sektion=5"><I>SyslogFacility</I> configuration value</A>
+ * @see <A HREF="https://www.freebsd.org/cgi/man.cgi?query=sshd_config&sektion=5"><I>SyslogFacility</I> configuration
+ * value</A>
*/
public enum SyslogFacilityValue {
DAEMON,
@@ -42,8 +43,7 @@ public enum SyslogFacilityValue {
LOCAL6,
LOCAL7;
- public static final Set<SyslogFacilityValue> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(SyslogFacilityValue.class));
+ public static final Set<SyslogFacilityValue> VALUES = Collections.unmodifiableSet(EnumSet.allOf(SyslogFacilityValue.class));
public static SyslogFacilityValue fromName(String n) {
if (GenericUtils.isEmpty(n)) {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java b/sshd-common/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java
index 8fed7ad..9652a90 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java
@@ -30,7 +30,7 @@ import org.apache.sshd.common.util.GenericUtils;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- * @see <A HREF="http://unixhelp.ed.ac.uk/CGI/man-cgi?sshd_config+5">Time formats for SSH configuration values</A>
+ * @see <A HREF="http://unixhelp.ed.ac.uk/CGI/man-cgi?sshd_config+5">Time formats for SSH configuration values</A>
*/
public enum TimeValueConfig {
SECONDS('s', 'S', TimeUnit.SECONDS.toMillis(1L)),
@@ -39,8 +39,7 @@ public enum TimeValueConfig {
DAYS('d', 'D', TimeUnit.DAYS.toMillis(1L)),
WEEKS('w', 'W', TimeUnit.DAYS.toMillis(7L));
- public static final Set<TimeValueConfig> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(TimeValueConfig.class));
+ public static final Set<TimeValueConfig> VALUES = Collections.unmodifiableSet(EnumSet.allOf(TimeValueConfig.class));
private final char loChar;
private final char hiChar;
@@ -79,10 +78,10 @@ public enum TimeValueConfig {
}
/**
- * @param s A time specification
- * @return The specified duration in milliseconds
- * @see #parse(String)
- * @see #durationOf(Map)
+ * @param s A time specification
+ * @return The specified duration in milliseconds
+ * @see #parse(String)
+ * @see #durationOf(Map)
*/
public static long durationOf(String s) {
Map<TimeValueConfig, Long> spec = parse(s);
@@ -90,9 +89,9 @@ public enum TimeValueConfig {
}
/**
- * @param s An input time specification containing possibly mixed numbers
- * and units - e.g., {@code 3h10m} to indicate 3 hours and 10 minutes
- * @return A {@link Map} specifying for each time unit its count
+ * @param s An input time specification containing possibly mixed numbers and units - e.g.,
+ * {@code 3h10m} to indicate 3 hours and 10 minutes
+ * @return A {@link Map} specifying for each time unit its count
* @throws NumberFormatException If bad numbers found - e.g., negative counts
* @throws IllegalArgumentException If bad format - e.g., unknown unit
*/
@@ -126,7 +125,8 @@ public enum TimeValueConfig {
Long prev = spec.put(c, count);
if (prev != null) {
- throw new IllegalArgumentException("parse(" + s + ") " + c.name() + " value re-specified: current=" + count + ", previous=" + prev);
+ throw new IllegalArgumentException(
+ "parse(" + s + ") " + c.name() + " value re-specified: current=" + count + ", previous=" + prev);
}
lastPos = curPos + 1;
@@ -144,7 +144,9 @@ public enum TimeValueConfig {
Long prev = spec.put(SECONDS, count);
if (prev != null) {
- throw new IllegalArgumentException("parse(" + s + ") last component (" + SECONDS.name() + ") value re-specified: current=" + count + ", previous=" + prev);
+ throw new IllegalArgumentException(
+ "parse(" + s + ") last component (" + SECONDS.name() + ") value re-specified: current=" + count
+ + ", previous=" + prev);
}
}
@@ -152,8 +154,8 @@ public enum TimeValueConfig {
}
/**
- * @param spec The {@link Map} specifying the count for each {@link TimeValueConfig}
- * @return The total duration in milliseconds
+ * @param spec The {@link Map} specifying the count for each {@link TimeValueConfig}
+ * @return The total duration in milliseconds
* @throws IllegalArgumentException If negative count for a time unit
*/
public static long durationOf(Map<TimeValueConfig, ? extends Number> spec) throws IllegalArgumentException {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/VersionProperties.java b/sshd-common/src/main/java/org/apache/sshd/common/config/VersionProperties.java
index 723a538..916057f 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/VersionProperties.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/VersionProperties.java
@@ -41,8 +41,7 @@ public final class VersionProperties {
public static final String REPORTED_VERSION = "sshd-version";
private static final class LazyVersionPropertiesHolder {
- private static final NavigableMap<String, String> PROPERTIES =
- Collections.unmodifiableNavigableMap(
+ private static final NavigableMap<String, String> PROPERTIES = Collections.unmodifiableNavigableMap(
loadVersionProperties(LazyVersionPropertiesHolder.class));
private LazyVersionPropertiesHolder() {
@@ -68,7 +67,7 @@ public final class VersionProperties {
} catch (Exception e) {
Logger log = LoggerFactory.getLogger(anchor);
log.warn("Failed ({}) to load version properties from {}: {}",
- e.getClass().getSimpleName(), cl, e.getMessage());
+ e.getClass().getSimpleName(), cl, e.getMessage());
if (log.isDebugEnabled()) {
log.debug("Version property failure details for loader=" + cl, e);
}
@@ -80,7 +79,7 @@ public final class VersionProperties {
String propValue = props.getProperty(key);
String value = GenericUtils.trimToEmpty(propValue);
if (GenericUtils.isEmpty(value)) {
- continue; // we have no need for empty values
+ continue; // we have no need for empty values
}
String prev = result.put(key, value);
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/AuthorizedKeyEntry.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/AuthorizedKeyEntry.java
index 304f10d..b584b40 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/AuthorizedKeyEntry.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/AuthorizedKeyEntry.java
@@ -48,13 +48,13 @@ import org.apache.sshd.common.util.io.NoCloseInputStream;
import org.apache.sshd.common.util.io.NoCloseReader;
/**
- * Represents an entry in the user's {@code authorized_keys} file according
- * to the <A HREF="http://en.wikibooks.org/wiki/OpenSSH/Client_Configuration_Files#.7E.2F.ssh.2Fauthorized_keys">OpenSSH format</A>.
- * <B>Note:</B> {@code equals/hashCode} check only the key type and data - the
- * comment and/or login options are not considered part of equality
+ * Represents an entry in the user's {@code authorized_keys} file according to the
+ * <A HREF="http://en.wikibooks.org/wiki/OpenSSH/Client_Configuration_Files#.7E.2F.ssh.2Fauthorized_keys">OpenSSH
+ * format</A>. <B>Note:</B> {@code equals/hashCode} check only the key type and data - the comment and/or login options
+ * are not considered part of equality
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- * @see <A HREF="http://man.openbsd.org/sshd.8#AUTHORIZED_KEYS_FILE_FORMAT">sshd(8) - AUTHORIZED_KEYS_FILE_FORMAT</A>
+ * @see <A HREF="http://man.openbsd.org/sshd.8#AUTHORIZED_KEYS_FILE_FORMAT">sshd(8) - AUTHORIZED_KEYS_FILE_FORMAT</A>
*/
public class AuthorizedKeyEntry extends PublicKeyEntry {
public static final char BOOLEAN_OPTION_NEGATION_INDICATOR = '!';
@@ -90,28 +90,28 @@ public class AuthorizedKeyEntry extends PublicKeyEntry {
}
/**
- * @param session The {@link SessionContext} for invoking this load command - may
- * be {@code null} if not invoked within a session context (e.g., offline tool or session unknown).
- * @param fallbackResolver The {@link PublicKeyEntryResolver} to consult if
- * none of the built-in ones can be used. If {@code null} and no built-in
- * resolver can be used then an {@link InvalidKeySpecException} is thrown.
- * @return The resolved {@link PublicKey} - or {@code null} if could not be
- * resolved. <B>Note:</B> may be called only after key type and data bytes
- * have been set or exception(s) may be thrown
+ * @param session The {@link SessionContext} for invoking this load command - may be {@code null}
+ * if not invoked within a session context (e.g., offline tool or session unknown).
+ * @param fallbackResolver The {@link PublicKeyEntryResolver} to consult if none of the built-in ones can
+ * be used. If {@code null} and no built-in resolver can be used then an
+ * {@link InvalidKeySpecException} is thrown.
+ * @return The resolved {@link PublicKey} - or {@code null} if could not be resolved.
+ * <B>Note:</B> may be called only after key type and data bytes have been set or
+ * exception(s) may be thrown
* @throws IOException If failed to decode the key
* @throws GeneralSecurityException If failed to generate the key
- * @see PublicKeyEntry#resolvePublicKey(SessionContext, Map, PublicKeyEntryResolver)
+ * @see PublicKeyEntry#resolvePublicKey(SessionContext, Map, PublicKeyEntryResolver)
*/
public PublicKey resolvePublicKey(
SessionContext session, PublicKeyEntryResolver fallbackResolver)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
return resolvePublicKey(session, getLoginOptions(), fallbackResolver);
}
@Override
public PublicKey appendPublicKey(
SessionContext session, Appendable sb, PublicKeyEntryResolver fallbackResolver)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
Map<String, String> options = getLoginOptions();
if (!GenericUtils.isEmpty(options)) {
int index = 0;
@@ -145,12 +145,12 @@ public class AuthorizedKeyEntry extends PublicKeyEntry {
return key;
}
- @Override // to avoid Findbugs[EQ_DOESNT_OVERRIDE_EQUALS]
+ @Override // to avoid Findbugs[EQ_DOESNT_OVERRIDE_EQUALS]
public int hashCode() {
return super.hashCode();
}
- @Override // to avoid Findbugs[EQ_DOESNT_OVERRIDE_EQUALS]
+ @Override // to avoid Findbugs[EQ_DOESNT_OVERRIDE_EQUALS]
public boolean equals(Object obj) {
return super.equals(obj);
}
@@ -161,17 +161,17 @@ public class AuthorizedKeyEntry extends PublicKeyEntry {
String kc = getComment();
Map<?, ?> ko = getLoginOptions();
return (GenericUtils.isEmpty(ko) ? "" : ko.toString() + " ")
- + entry
- + (GenericUtils.isEmpty(kc) ? "" : " " + kc);
+ + entry
+ + (GenericUtils.isEmpty(kc) ? "" : " " + kc);
}
/**
* Reads read the contents of an {@code authorized_keys} file
*
- * @param url The {@link URL} to read from
- * @return A {@link List} of all the {@link AuthorizedKeyEntry}-ies found there
+ * @param url The {@link URL} to read from
+ * @return A {@link List} of all the {@link AuthorizedKeyEntry}-ies found there
* @throws IOException If failed to read or parse the entries
- * @see #readAuthorizedKeys(InputStream, boolean)
+ * @see #readAuthorizedKeys(InputStream, boolean)
*/
public static List<AuthorizedKeyEntry> readAuthorizedKeys(URL url) throws IOException {
try (InputStream in = url.openStream()) {
@@ -182,13 +182,12 @@ public class AuthorizedKeyEntry extends PublicKeyEntry {
/**
* Reads read the contents of an {@code authorized_keys} file
*
- * @param path {@link Path} to read from
- * @param options The {@link OpenOption}s to use - if unspecified then appropriate
- * defaults assumed
- * @return A {@link List} of all the {@link AuthorizedKeyEntry}-ies found there
+ * @param path {@link Path} to read from
+ * @param options The {@link OpenOption}s to use - if unspecified then appropriate defaults assumed
+ * @return A {@link List} of all the {@link AuthorizedKeyEntry}-ies found there
* @throws IOException If failed to read or parse the entries
- * @see #readAuthorizedKeys(InputStream, boolean)
- * @see Files#newInputStream(Path, OpenOption...)
+ * @see #readAuthorizedKeys(InputStream, boolean)
+ * @see Files#newInputStream(Path, OpenOption...)
*/
public static List<AuthorizedKeyEntry> readAuthorizedKeys(Path path, OpenOption... options) throws IOException {
try (InputStream in = Files.newInputStream(path, options)) {
@@ -199,11 +198,11 @@ public class AuthorizedKeyEntry extends PublicKeyEntry {
/**
* Reads read the contents of an {@code authorized_keys} file
*
- * @param in The {@link InputStream} to use to read the contents of an {@code authorized_keys} file
- * @param okToClose {@code true} if method may close the input regardless success or failure
- * @return A {@link List} of all the {@link AuthorizedKeyEntry}-ies found there
+ * @param in The {@link InputStream} to use to read the contents of an {@code authorized_keys} file
+ * @param okToClose {@code true} if method may close the input regardless success or failure
+ * @return A {@link List} of all the {@link AuthorizedKeyEntry}-ies found there
* @throws IOException If failed to read or parse the entries
- * @see #readAuthorizedKeys(Reader, boolean)
+ * @see #readAuthorizedKeys(Reader, boolean)
*/
public static List<AuthorizedKeyEntry> readAuthorizedKeys(InputStream in, boolean okToClose) throws IOException {
try (Reader rdr = new InputStreamReader(
@@ -215,11 +214,11 @@ public class AuthorizedKeyEntry extends PublicKeyEntry {
/**
* Reads read the contents of an {@code authorized_keys} file
*
- * @param rdr The {@link Reader} to use to read the contents of an {@code authorized_keys} file
- * @param okToClose {@code true} if method may close the input regardless success or failure
- * @return A {@link List} of all the {@link AuthorizedKeyEntry}-ies found there
+ * @param rdr The {@link Reader} to use to read the contents of an {@code authorized_keys} file
+ * @param okToClose {@code true} if method may close the input regardless success or failure
+ * @return A {@link List} of all the {@link AuthorizedKeyEntry}-ies found there
* @throws IOException If failed to read or parse the entries
- * @see #readAuthorizedKeys(BufferedReader)
+ * @see #readAuthorizedKeys(BufferedReader)
*/
public static List<AuthorizedKeyEntry> readAuthorizedKeys(Reader rdr, boolean okToClose) throws IOException {
try (BufferedReader buf = new BufferedReader(NoCloseReader.resolveReader(rdr, okToClose))) {
@@ -228,10 +227,10 @@ public class AuthorizedKeyEntry extends PublicKeyEntry {
}
/**
- * @param rdr The {@link BufferedReader} to use to read the contents of an {@code authorized_keys} file
- * @return A {@link List} of all the {@link AuthorizedKeyEntry}-ies found there
+ * @param rdr The {@link BufferedReader} to use to read the contents of an {@code authorized_keys} file
+ * @return A {@link List} of all the {@link AuthorizedKeyEntry}-ies found there
* @throws IOException If failed to read or parse the entries
- * @see #parseAuthorizedKeyEntry(String)
+ * @see #parseAuthorizedKeyEntry(String)
*/
public static List<AuthorizedKeyEntry> readAuthorizedKeys(BufferedReader rdr) throws IOException {
List<AuthorizedKeyEntry> entries = null;
@@ -240,11 +239,12 @@ public class AuthorizedKeyEntry extends PublicKeyEntry {
try {
entry = parseAuthorizedKeyEntry(line);
if (entry == null) {
- continue; // null, empty or comment line
+ continue; // null, empty or comment line
}
} catch (RuntimeException | Error e) {
- throw new StreamCorruptedException("Failed (" + e.getClass().getSimpleName() + ")"
- + " to parse key entry=" + line + ": " + e.getMessage());
+ throw new StreamCorruptedException(
+ "Failed (" + e.getClass().getSimpleName() + ")"
+ + " to parse key entry=" + line + ": " + e.getMessage());
}
if (entries == null) {
@@ -262,27 +262,27 @@ public class AuthorizedKeyEntry extends PublicKeyEntry {
}
/**
- * @param value Original line from an {@code authorized_keys} file
- * @return {@link AuthorizedKeyEntry} or {@code null} if the line is
- * {@code null}/empty or a comment line
+ * @param value Original line from an {@code authorized_keys} file
+ * @return {@link AuthorizedKeyEntry} or {@code null} if the line is {@code null}/empty or
+ * a comment line
* @throws IllegalArgumentException If failed to parse/decode the line
- * @see #parseAuthorizedKeyEntry(String, PublicKeyEntryDataResolver)
+ * @see #parseAuthorizedKeyEntry(String, PublicKeyEntryDataResolver)
*/
public static AuthorizedKeyEntry parseAuthorizedKeyEntry(String value) throws IllegalArgumentException {
return parseAuthorizedKeyEntry(value, null);
}
/**
- * @param value Original line from an {@code authorized_keys} file
- * @param resolver The {@link PublicKeyEntryDataResolver} to use - if {@code null}
- * one will be automatically resolved from the key type
- * @return {@link AuthorizedKeyEntry} or {@code null} if the line is
- * {@code null}/empty or a comment line
+ * @param value Original line from an {@code authorized_keys} file
+ * @param resolver The {@link PublicKeyEntryDataResolver} to use - if {@code null} one will be
+ * automatically resolved from the key type
+ * @return {@link AuthorizedKeyEntry} or {@code null} if the line is {@code null}/empty or
+ * a comment line
* @throws IllegalArgumentException If failed to parse/decode the line
*/
public static AuthorizedKeyEntry parseAuthorizedKeyEntry(
String value, PublicKeyEntryDataResolver resolver)
- throws IllegalArgumentException {
+ throws IllegalArgumentException {
String line = GenericUtils.replaceWhitespaceAndTrim(value);
if (GenericUtils.isEmpty(line) || (line.charAt(0) == COMMENT_CHAR) /* comment ? */) {
return null;
@@ -322,13 +322,14 @@ public class AuthorizedKeyEntry extends PublicKeyEntry {
}
/**
- * Parses a single line from an {@code authorized_keys} file that is <U>known</U>
- * to contain login options and separates it to the options and the rest of the line.
+ * Parses a single line from an {@code authorized_keys} file that is <U>known</U> to contain login options and
+ * separates it to the options and the rest of the line.
*
- * @param entryLine The line to be parsed
- * @return A {@link SimpleImmutableEntry} representing the parsed data where key=login options part
- * and value=rest of the data - {@code null} if no data in line or line starts with comment character
- * @see <A HREF="http://man.openbsd.org/sshd.8#AUTHORIZED_KEYS_FILE_FORMAT">sshd(8) - AUTHORIZED_KEYS_FILE_FORMAT</A>
+ * @param entryLine The line to be parsed
+ * @return A {@link SimpleImmutableEntry} representing the parsed data where key=login options part and
+ * value=rest of the data - {@code null} if no data in line or line starts with comment character
+ * @see <A HREF="http://man.openbsd.org/sshd.8#AUTHORIZED_KEYS_FILE_FORMAT">sshd(8) -
+ * AUTHORIZED_KEYS_FILE_FORMAT</A>
*/
public static SimpleImmutableEntry<String, String> resolveEntryComponents(String entryLine) {
String line = GenericUtils.replaceWhitespaceAndTrim(entryLine);
@@ -365,23 +366,23 @@ public class AuthorizedKeyEntry extends PublicKeyEntry {
* </P>
*
* <UL>
- * <P><LI>
- * Options that have a value are automatically stripped of any surrounding double quotes./
- * </LI></P>
+ * <P>
+ * <LI>Options that have a value are automatically stripped of any surrounding double quotes./</LI>
+ * </P>
*
- * <P><LI>
- * Options that have no value are marked as {@code true/false} - according
- * to the {@link #BOOLEAN_OPTION_NEGATION_INDICATOR}.
- * </LI></P>
+ * <P>
+ * <LI>Options that have no value are marked as {@code true/false} - according to the
+ * {@link #BOOLEAN_OPTION_NEGATION_INDICATOR}.</LI>
+ * </P>
*
- * <P><LI>
- * Options that appear multiple times are simply concatenated using comma as separator.
- * </LI></P>
+ * <P>
+ * <LI>Options that appear multiple times are simply concatenated using comma as separator.</LI>
+ * </P>
* </UL>
*
- * @param options The options line to parse - ignored if {@code null}/empty/blank
- * @return A {@link NavigableMap} where key=case <U>insensitive</U> option name and value=the parsed value.
- * @see #addLoginOption(Map, String) addLoginOption
+ * @param options The options line to parse - ignored if {@code null}/empty/blank
+ * @return A {@link NavigableMap} where key=case <U>insensitive</U> option name and value=the parsed value.
+ * @see #addLoginOption(Map, String) addLoginOption
*/
public static NavigableMap<String, String> parseLoginOptions(String options) {
String line = GenericUtils.replaceWhitespaceAndTrim(options);
@@ -433,12 +434,12 @@ public class AuthorizedKeyEntry extends PublicKeyEntry {
}
/**
- * Parses and adds a new option to the options map. If a valued option is re-specified then
- * its value(s) are concatenated using comma as separator.
+ * Parses and adds a new option to the options map. If a valued option is re-specified then its value(s) are
+ * concatenated using comma as separator.
*
- * @param optsMap Options map to add to
- * @param option The option data to parse - ignored if {@code null}/empty/blank
- * @return The updated entry - {@code null} if no option updated in the map
+ * @param optsMap Options map to add to
+ * @param option The option data to parse - ignored if {@code null}/empty/blank
+ * @return The updated entry - {@code null} if no option updated in the map
* @throws IllegalStateException If a boolean option is re-specified
*/
public static SimpleImmutableEntry<String, String> addLoginOption(Map<String, String> optsMap, String option) {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/BuiltinIdentities.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/BuiltinIdentities.java
index e4058cf..2b6c9f6 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/BuiltinIdentities.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/BuiltinIdentities.java
@@ -52,7 +52,7 @@ public enum BuiltinIdentities implements Identity {
RSA(Constants.RSA, RSAPublicKey.class, RSAPrivateKey.class, KeyPairProvider.SSH_RSA),
DSA(Constants.DSA, DSAPublicKey.class, DSAPrivateKey.class, KeyPairProvider.SSH_DSS),
ECDSA(Constants.ECDSA, KeyUtils.EC_ALGORITHM, ECPublicKey.class, ECPrivateKey.class,
- ECCurves.VALUES.stream().map(KeyTypeIndicator::getKeyType).collect(Collectors.toList())) {
+ ECCurves.VALUES.stream().map(KeyTypeIndicator::getKeyType).collect(Collectors.toList())) {
@Override
public boolean isSupported() {
return SecurityUtils.isECCSupported();
@@ -68,16 +68,14 @@ public enum BuiltinIdentities implements Identity {
}
};
- public static final Set<BuiltinIdentities> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(BuiltinIdentities.class));
+ public static final Set<BuiltinIdentities> VALUES = Collections.unmodifiableSet(EnumSet.allOf(BuiltinIdentities.class));
/**
* A case <u>insensitive</u> {@link NavigableSet} of all built-in identities names
*/
- public static final NavigableSet<String> NAMES =
- Collections.unmodifiableNavigableSet(
+ public static final NavigableSet<String> NAMES = Collections.unmodifiableNavigableSet(
GenericUtils.asSortedSet(
- String.CASE_INSENSITIVE_ORDER, NamedResource.getNameList(VALUES)));
+ String.CASE_INSENSITIVE_ORDER, NamedResource.getNameList(VALUES)));
private final String name;
private final String algorithm;
@@ -90,25 +88,25 @@ public enum BuiltinIdentities implements Identity {
}
BuiltinIdentities(String name, String algorithm,
- Class<? extends PublicKey> pubType,
- Class<? extends PrivateKey> prvType,
- String keyType) {
+ Class<? extends PublicKey> pubType,
+ Class<? extends PrivateKey> prvType,
+ String keyType) {
this(name, algorithm, pubType, prvType,
- Collections.singletonList(
- ValidateUtils.checkNotNullAndNotEmpty(keyType, "No key type specified")));
+ Collections.singletonList(
+ ValidateUtils.checkNotNullAndNotEmpty(keyType, "No key type specified")));
}
BuiltinIdentities(String name, String algorithm,
- Class<? extends PublicKey> pubType,
- Class<? extends PrivateKey> prvType,
- Collection<String> keyTypes) {
+ Class<? extends PublicKey> pubType,
+ Class<? extends PrivateKey> prvType,
+ Collection<String> keyTypes) {
this.name = name.toLowerCase();
this.algorithm = algorithm.toUpperCase();
this.pubType = pubType;
this.prvType = prvType;
this.types = Collections.unmodifiableNavigableSet(
- GenericUtils.asSortedSet(String.CASE_INSENSITIVE_ORDER,
- ValidateUtils.checkNotNullAndNotEmpty(keyTypes, "No key type names provided")));
+ GenericUtils.asSortedSet(String.CASE_INSENSITIVE_ORDER,
+ ValidateUtils.checkNotNullAndNotEmpty(keyTypes, "No key type names provided")));
}
@Override
@@ -142,18 +140,18 @@ public enum BuiltinIdentities implements Identity {
}
/**
- * @param name The identity name - ignored if {@code null}/empty
- * @return The matching {@link BuiltinIdentities} whose {@link #getName()}
- * value matches case <U>insensitive</U> or {@code null} if no match found
+ * @param name The identity name - ignored if {@code null}/empty
+ * @return The matching {@link BuiltinIdentities} whose {@link #getName()} value matches case
+ * <U>insensitive</U> or {@code null} if no match found
*/
public static BuiltinIdentities fromName(String name) {
return NamedResource.findByName(name, String.CASE_INSENSITIVE_ORDER, VALUES);
}
/**
- * @param algorithm The algorithm - ignored if {@code null}/empty
- * @return The matching {@link BuiltinIdentities} whose {@link #getAlgorithm()}
- * value matches case <U>insensitive</U> or {@code null} if no match found
+ * @param algorithm The algorithm - ignored if {@code null}/empty
+ * @return The matching {@link BuiltinIdentities} whose {@link #getAlgorithm()} value matches case
+ * <U>insensitive</U> or {@code null} if no match found
*/
public static BuiltinIdentities fromAlgorithm(String algorithm) {
if (GenericUtils.isEmpty(algorithm)) {
@@ -170,11 +168,10 @@ public enum BuiltinIdentities implements Identity {
}
/**
- * @param kp The {@link KeyPair} - ignored if {@code null}
- * @return The matching {@link BuiltinIdentities} provided <U>both</U>
- * public and public keys are of the same type - {@code null} if no
- * match could be found
- * @see #fromKey(Key)
+ * @param kp The {@link KeyPair} - ignored if {@code null}
+ * @return The matching {@link BuiltinIdentities} provided <U>both</U> public and public keys are of the same
+ * type - {@code null} if no match could be found
+ * @see #fromKey(Key)
*/
public static BuiltinIdentities fromKeyPair(KeyPair kp) {
if (kp == null) {
@@ -186,27 +183,26 @@ public enum BuiltinIdentities implements Identity {
if (Objects.equals(i1, i2)) {
return i1;
} else {
- return null; // some kind of mixed keys...
+ return null; // some kind of mixed keys...
}
}
/**
- * @param key The {@link Key} instance - ignored if {@code null}
- * @return The matching {@link BuiltinIdentities} whose either public or
- * private key type matches the requested one or {@code null} if no match found
- * @see #fromKeyType(Class)
+ * @param key The {@link Key} instance - ignored if {@code null}
+ * @return The matching {@link BuiltinIdentities} whose either public or private key type matches the requested
+ * one or {@code null} if no match found
+ * @see #fromKeyType(Class)
*/
public static BuiltinIdentities fromKey(Key key) {
return fromKeyType((key == null) ? null : key.getClass());
}
/**
- * @param clazz The key type - ignored if {@code null} or not
- * a {@link Key} class
- * @return The matching {@link BuiltinIdentities} whose either public or
- * private key type matches the requested one or {@code null} if no match found
- * @see #getPublicKeyType()
- * @see #getPrivateKeyType()
+ * @param clazz The key type - ignored if {@code null} or not a {@link Key} class
+ * @return The matching {@link BuiltinIdentities} whose either public or private key type matches the
+ * requested one or {@code null} if no match found
+ * @see #getPublicKeyType()
+ * @see #getPrivateKeyType()
*/
public static BuiltinIdentities fromKeyType(Class<?> clazz) {
if ((clazz == null) || (!Key.class.isAssignableFrom(clazz))) {
@@ -232,12 +228,11 @@ public enum BuiltinIdentities implements Identity {
}
/**
- * @param typeName The {@code OpenSSH} key type e.g., {@code ssh-rsa, ssh-dss, ecdsa-sha2-nistp384}.
- * Ignored if {@code null}/empty.
- * @return The {@link BuiltinIdentities} that reported the type name
- * as its {@link #getSupportedKeyTypes()} (case <U>insensitive</U>) - {@code null}
- * if no match found
- * @see KeyTypeNamesSupport#findSupporterByKeyTypeName(String, Collection)
+ * @param typeName The {@code OpenSSH} key type e.g., {@code ssh-rsa, ssh-dss, ecdsa-sha2-nistp384}. Ignored if
+ * {@code null}/empty.
+ * @return The {@link BuiltinIdentities} that reported the type name as its {@link #getSupportedKeyTypes()}
+ * (case <U>insensitive</U>) - {@code null} if no match found
+ * @see KeyTypeNamesSupport#findSupporterByKeyTypeName(String, Collection)
*/
public static BuiltinIdentities fromKeyTypeName(String typeName) {
return KeyTypeNamesSupport.findSupporterByKeyTypeName(typeName, VALUES);
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/FilePasswordProvider.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/FilePasswordProvider.java
index 19276b0..cab86c7 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/FilePasswordProvider.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/FilePasswordProvider.java
@@ -41,8 +41,8 @@ public interface FilePasswordProvider {
/** Skip attempt and see if can proceed without the key */
IGNORE;
- public static final Set<ResourceDecodeResult> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(ResourceDecodeResult.class));
+ public static final Set<ResourceDecodeResult> VALUES
+ = Collections.unmodifiableSet(EnumSet.allOf(ResourceDecodeResult.class));
}
/**
@@ -51,38 +51,39 @@ public interface FilePasswordProvider {
FilePasswordProvider EMPTY = (session, resourceKey, retryIndex) -> null;
/**
- * @param session The {@link SessionContext} for invoking this load command - may
- * be {@code null} if not invoked within a session context (e.g., offline tool or session unknown).
- * @param resourceKey The resource key representing the <U>private</U> file
- * @param retryIndex The zero-based index of the invocation for the specific
- * resource (in case invoked several times for the same resource)
- * @return The password - if {@code null}/empty then no password is required
+ * @param session The {@link SessionContext} for invoking this load command - may be {@code null} if not
+ * invoked within a session context (e.g., offline tool or session unknown).
+ * @param resourceKey The resource key representing the <U>private</U> file
+ * @param retryIndex The zero-based index of the invocation for the specific resource (in case invoked several
+ * times for the same resource)
+ * @return The password - if {@code null}/empty then no password is required
* @throws IOException if cannot resolve password
- * @see #handleDecodeAttemptResult(SessionContext, NamedResource, int, String, Exception)
+ * @see #handleDecodeAttemptResult(SessionContext, NamedResource, int, String, Exception)
*/
String getPassword(SessionContext session, NamedResource resourceKey, int retryIndex) throws IOException;
/**
- * Invoked to inform the password provide about the decoding result. <b>Note:</b>
- * any exception thrown from this method (including if called to inform about
- * success) will be propagated instead of the original (if any was reported)
+ * Invoked to inform the password provide about the decoding result. <b>Note:</b> any exception thrown from this
+ * method (including if called to inform about success) will be propagated instead of the original (if any was
+ * reported)
*
- * @param session The {@link SessionContext} for invoking this load command - may
- * be {@code null} if not invoked within a session context (e.g., offline tool or session unknown).
- * @param resourceKey The resource key representing the <U>private</U> file
- * @param retryIndex The zero-based index of the invocation for the specific
- * resource (in case invoked several times for the same resource). If success
- * report, it indicates the number of retries it took to succeed
- * @param password The password that was attempted
- * @param err The attempt result - {@code null} for success
- * @return How to proceed in case of error - <u>ignored</u> if invoked in order
- * to report success. <b>Note:</b> {@code null} is same as {@link ResourceDecodeResult#TERMINATE}.
- * @throws IOException If cannot resolve a new password
+ * @param session The {@link SessionContext} for invoking this load command - may be {@code null}
+ * if not invoked within a session context (e.g., offline tool or session unknown).
+ * @param resourceKey The resource key representing the <U>private</U> file
+ * @param retryIndex The zero-based index of the invocation for the specific resource (in case
+ * invoked several times for the same resource). If success report, it indicates
+ * the number of retries it took to succeed
+ * @param password The password that was attempted
+ * @param err The attempt result - {@code null} for success
+ * @return How to proceed in case of error - <u>ignored</u> if invoked in order to report
+ * success. <b>Note:</b> {@code null} is same as
+ * {@link ResourceDecodeResult#TERMINATE}.
+ * @throws IOException If cannot resolve a new password
* @throws GeneralSecurityException If not attempting to resolve a new password
*/
default ResourceDecodeResult handleDecodeAttemptResult(
SessionContext session, NamedResource resourceKey, int retryIndex, String password, Exception err)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
return ResourceDecodeResult.TERMINATE;
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/FilePasswordProviderHolder.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/FilePasswordProviderHolder.java
index 9e2ce16..3d55630 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/FilePasswordProviderHolder.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/FilePasswordProviderHolder.java
@@ -25,9 +25,8 @@ package org.apache.sshd.common.config.keys;
@FunctionalInterface
public interface FilePasswordProviderHolder {
/**
- * @return The {@link FilePasswordProvider} to use if need to load encrypted
- * identities keys - never {@code null}
- * @see FilePasswordProvider#EMPTY
+ * @return The {@link FilePasswordProvider} to use if need to load encrypted identities keys - never {@code null}
+ * @see FilePasswordProvider#EMPTY
*/
FilePasswordProvider getFilePasswordProvider();
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/Identity.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/Identity.java
index 50d3d3e..cc80510 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/Identity.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/Identity.java
@@ -27,8 +27,8 @@ import org.apache.sshd.common.NamedResource;
import org.apache.sshd.common.OptionalFeature;
/**
- * Represents an SSH key type - the referenced algorithm is the one used to generate
- * the key - e.g., "RSA", "DSA", "EC".
+ * Represents an SSH key type - the referenced algorithm is the one used to generate the key - e.g., "RSA",
+ * "DSA", "EC".
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/IdentityResourceLoader.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/IdentityResourceLoader.java
index 209c049..026c69b 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/IdentityResourceLoader.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/IdentityResourceLoader.java
@@ -23,26 +23,23 @@ import java.security.PrivateKey;
import java.security.PublicKey;
/**
- * @param <PUB> Type of {@link PublicKey}
- * @param <PRV> Type of {@link PrivateKey}
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ * @param <PUB> Type of {@link PublicKey}
+ * @param <PRV> Type of {@link PrivateKey}
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public interface IdentityResourceLoader<PUB extends PublicKey, PRV extends PrivateKey> extends KeyTypeNamesSupport {
/**
- * A reasonable max. number of octets used for a {@link BigInteger} in the
- * context of keys based on such numbers
+ * A reasonable max. number of octets used for a {@link BigInteger} in the context of keys based on such numbers
*/
int MAX_BIGINT_OCTETS_COUNT = Short.MAX_VALUE;
/**
- * @return The {@link Class} of the {@link PublicKey} that is
- * the result of decoding
+ * @return The {@link Class} of the {@link PublicKey} that is the result of decoding
*/
Class<PUB> getPublicKeyType();
/**
- * @return The {@link Class} of the {@link PrivateKey} that
- * matches the public one
+ * @return The {@link Class} of the {@link PrivateKey} that matches the public one
*/
Class<PRV> getPrivateKeyType();
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/IdentityUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/IdentityUtils.java
index 178c914..370b5f9 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/IdentityUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/IdentityUtils.java
@@ -48,10 +48,10 @@ public final class IdentityUtils {
}
private static final class LazyDefaultUserHomeFolderHolder {
- private static final Path PATH =
- Paths.get(ValidateUtils.checkNotNullAndNotEmpty(System.getProperty("user.home"), "No user home"))
- .toAbsolutePath()
- .normalize();
+ private static final Path PATH
+ = Paths.get(ValidateUtils.checkNotNullAndNotEmpty(System.getProperty("user.home"), "No user home"))
+ .toAbsolutePath()
+ .normalize();
private LazyDefaultUserHomeFolderHolder() {
throw new UnsupportedOperationException("No instance allowed");
@@ -67,29 +67,28 @@ public final class IdentityUtils {
}
/**
- * @param prefix The file name prefix - ignored if {@code null}/empty
- * @param type The identity type - ignored if {@code null}/empty
- * @param suffix The file name suffix - ignored if {@code null}/empty
- * @return The identity file name or {@code null} if no name
+ * @param prefix The file name prefix - ignored if {@code null}/empty
+ * @param type The identity type - ignored if {@code null}/empty
+ * @param suffix The file name suffix - ignored if {@code null}/empty
+ * @return The identity file name or {@code null} if no name
*/
public static String getIdentityFileName(String prefix, String type, String suffix) {
if (GenericUtils.isEmpty(type)) {
return null;
} else {
return GenericUtils.trimToEmpty(prefix)
- + type.toLowerCase()
- + GenericUtils.trimToEmpty(suffix);
+ + type.toLowerCase()
+ + GenericUtils.trimToEmpty(suffix);
}
}
/**
- * @param ids A {@link Map} of the loaded identities where key=the identity type,
- * value=the matching {@link KeyPair} - ignored if {@code null}/empty
- * @param supportedOnly If {@code true} then ignore identities that are not
- * supported internally
- * @return A {@link KeyPair} for the identities - {@code null} if no identities
- * available (e.g., after filtering unsupported ones)
- * @see BuiltinIdentities
+ * @param ids A {@link Map} of the loaded identities where key=the identity type, value=the matching
+ * {@link KeyPair} - ignored if {@code null}/empty
+ * @param supportedOnly If {@code true} then ignore identities that are not supported internally
+ * @return A {@link KeyPair} for the identities - {@code null} if no identities available (e.g., after
+ * filtering unsupported ones)
+ * @see BuiltinIdentities
*/
public static KeyPairProvider createKeyPairProvider(Map<String, KeyPair> ids, boolean supportedOnly) {
if (GenericUtils.isEmpty(ids)) {
@@ -114,7 +113,7 @@ public final class IdentityUtils {
KeyPair prev = pairsMap.put(keyType, kp);
if (prev != null) {
- return; // less of an offense if 2 pairs mapped to same key type
+ return; // less of an offense if 2 pairs mapped to same key type
}
});
@@ -126,23 +125,23 @@ public final class IdentityUtils {
}
/**
- * @param session The {@link SessionContext} for invoking this load command - may
- * be {@code null} if not invoked within a session context (e.g., offline tool or session unknown).
- * @param paths A {@link Map} of the identities where key=identity type (case
- * <U>insensitive</U>), value=the {@link Path} of file with the identity key
- * @param provider A {@link FilePasswordProvider} - may be {@code null}
- * if the loaded keys are <U>guaranteed</U> not to be encrypted. The argument
- * to {@code FilePasswordProvider#getPassword} is the path of the
- * file whose key is to be loaded
- * @param options The {@link OpenOption}s to use when reading the key data
- * @return A {@link NavigableMap} of the identities where key=identity type (case
- * <U>insensitive</U>), value=the {@link KeyPair} of the identity
+ * @param session The {@link SessionContext} for invoking this load command - may be {@code null}
+ * if not invoked within a session context (e.g., offline tool or session unknown).
+ * @param paths A {@link Map} of the identities where key=identity type (case
+ * <U>insensitive</U>), value=the {@link Path} of file with the identity key
+ * @param provider A {@link FilePasswordProvider} - may be {@code null} if the loaded keys are
+ * <U>guaranteed</U> not to be encrypted. The argument to
+ * {@code FilePasswordProvider#getPassword} is the path of the file whose key is to
+ * be loaded
+ * @param options The {@link OpenOption}s to use when reading the key data
+ * @return A {@link NavigableMap} of the identities where key=identity type (case
+ * <U>insensitive</U>), value=the {@link KeyPair} of the identity
* @throws IOException If failed to access the file system
* @throws GeneralSecurityException If failed to load the keys
*/
public static NavigableMap<String, KeyPair> loadIdentities(
SessionContext session, Map<String, ? extends Path> paths, FilePasswordProvider provider, OpenOption... options)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
if (GenericUtils.isEmpty(paths)) {
return Collections.emptyNavigableMap();
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyEntryResolver.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyEntryResolver.java
index b00b3d6..3dd5e7b 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyEntryResolver.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyEntryResolver.java
@@ -40,15 +40,15 @@ import org.apache.sshd.common.util.NumberUtils;
import org.apache.sshd.common.util.io.IoUtils;
/**
- * @param <PUB> Type of {@link PublicKey}
- * @param <PRV> Type of {@link PrivateKey}
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ * @param <PUB> Type of {@link PublicKey}
+ * @param <PRV> Type of {@link PrivateKey}
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>
extends IdentityResourceLoader<PUB, PRV> {
/**
- * @param keySize Key size in bits
- * @return A {@link KeyPair} with the specified key size
+ * @param keySize Key size in bits
+ * @return A {@link KeyPair} with the specified key size
* @throws GeneralSecurityException if unable to generate the pair
*/
default KeyPair generateKeyPair(int keySize) throws GeneralSecurityException {
@@ -58,12 +58,12 @@ public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>
}
/**
- * @param kp The {@link KeyPair} to be cloned - ignored if {@code null}
- * @return A cloned pair (or {@code null} if no original pair)
- * @throws GeneralSecurityException If failed to clone - e.g., provided key
- * pair does not contain keys of the expected type
- * @see #getPublicKeyType()
- * @see #getPrivateKeyType()
+ * @param kp The {@link KeyPair} to be cloned - ignored if {@code null}
+ * @return A cloned pair (or {@code null} if no original pair)
+ * @throws GeneralSecurityException If failed to clone - e.g., provided key pair does not contain keys of the
+ * expected type
+ * @see #getPublicKeyType()
+ * @see #getPrivateKeyType()
*/
default KeyPair cloneKeyPair(KeyPair kp) throws GeneralSecurityException {
if (kp == null) {
@@ -77,7 +77,8 @@ public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>
Class<?> orgType = pubOriginal.getClass();
if (!pubExpected.isAssignableFrom(orgType)) {
throw new InvalidKeyException(
- "Mismatched public key types: expected=" + pubExpected.getSimpleName() + ", actual=" + orgType.getSimpleName());
+ "Mismatched public key types: expected=" + pubExpected.getSimpleName() + ", actual="
+ + orgType.getSimpleName());
}
PUB castPub = pubExpected.cast(pubOriginal);
@@ -91,7 +92,8 @@ public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>
Class<?> orgType = prvOriginal.getClass();
if (!prvExpected.isAssignableFrom(orgType)) {
throw new InvalidKeyException(
- "Mismatched private key types: expected=" + prvExpected.getSimpleName() + ", actual=" + orgType.getSimpleName());
+ "Mismatched private key types: expected=" + prvExpected.getSimpleName() + ", actual="
+ + orgType.getSimpleName());
}
PRV castPrv = prvExpected.cast(prvOriginal);
@@ -102,27 +104,27 @@ public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>
}
/**
- * @param key The {@link PublicKey} to clone - ignored if {@code null}
- * @return The cloned key (or {@code null} if no original key)
+ * @param key The {@link PublicKey} to clone - ignored if {@code null}
+ * @return The cloned key (or {@code null} if no original key)
* @throws GeneralSecurityException If failed to clone the key
*/
PUB clonePublicKey(PUB key) throws GeneralSecurityException;
/**
- * @param key The {@link PrivateKey} to clone - ignored if {@code null}
- * @return The cloned key (or {@code null} if no original key)
+ * @param key The {@link PrivateKey} to clone - ignored if {@code null}
+ * @return The cloned key (or {@code null} if no original key)
* @throws GeneralSecurityException If failed to clone the key
*/
PRV clonePrivateKey(PRV key) throws GeneralSecurityException;
/**
- * @return A {@link KeyPairGenerator} suitable for this decoder
+ * @return A {@link KeyPairGenerator} suitable for this decoder
* @throws GeneralSecurityException If failed to create the generator
*/
KeyPairGenerator getKeyPairGenerator() throws GeneralSecurityException;
/**
- * @return A {@link KeyFactory} suitable for the specific decoder type
+ * @return A {@link KeyFactory} suitable for the specific decoder type
* @throws GeneralSecurityException If failed to create one
*/
KeyFactory getKeyFactoryInstance() throws GeneralSecurityException;
@@ -155,10 +157,10 @@ public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>
static byte[] encodeInt(OutputStream s, int v) throws IOException {
byte[] bytes = {
- (byte) ((v >> 24) & 0xFF),
- (byte) ((v >> 16) & 0xFF),
- (byte) ((v >> 8) & 0xFF),
- (byte) (v & 0xFF)
+ (byte) ((v >> 24) & 0xFF),
+ (byte) ((v >> 16) & 0xFF),
+ (byte) ((v >> 8) & 0xFF),
+ (byte) (v & 0xFF)
};
s.write(bytes);
return bytes;
@@ -184,7 +186,8 @@ public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>
static byte[] readRLEBytes(InputStream s, int maxAllowed) throws IOException {
int len = decodeInt(s);
if (len > maxAllowed) {
- throw new StreamCorruptedException("Requested block length (" + len + ") exceeds max. allowed (" + maxAllowed + ")");
+ throw new StreamCorruptedException(
+ "Requested block length (" + len + ") exceeds max. allowed (" + maxAllowed + ")");
}
if (len < 0) {
throw new StreamCorruptedException("Negative block length requested: " + len);
@@ -196,12 +199,12 @@ public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>
}
static int decodeInt(InputStream s) throws IOException {
- byte[] bytes = {0, 0, 0, 0};
+ byte[] bytes = { 0, 0, 0, 0 };
IoUtils.readFully(s, bytes);
return ((bytes[0] & 0xFF) << 24)
- | ((bytes[1] & 0xFF) << 16)
- | ((bytes[2] & 0xFF) << 8)
- | (bytes[3] & 0xFF);
+ | ((bytes[1] & 0xFF) << 16)
+ | ((bytes[2] & 0xFF) << 8)
+ | (bytes[3] & 0xFF);
}
static Map.Entry<String, Integer> decodeString(byte[] buf, int maxChars) {
@@ -219,19 +222,21 @@ public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>
/**
* Decodes a run-length encoded string
*
- * @param buf The buffer with the data bytes
- * @param offset The offset in the buffer to decode the string
- * @param available The max. available data starting from the offset
- * @param cs The {@link Charset} to use to decode the string
- * @param maxChars Max. allowed characters in string - if more than
- * that is encoded then an {@link IndexOutOfBoundsException} will be thrown
- * @return The decoded string + the offset of the next byte after it
- * @see #readRLEBytes(byte[], int, int, int)
+ * @param buf The buffer with the data bytes
+ * @param offset The offset in the buffer to decode the string
+ * @param available The max. available data starting from the offset
+ * @param cs The {@link Charset} to use to decode the string
+ * @param maxChars Max. allowed characters in string - if more than that is encoded then an
+ * {@link IndexOutOfBoundsException} will be thrown
+ * @return The decoded string + the offset of the next byte after it
+ * @see #readRLEBytes(byte[], int, int, int)
*/
static Map.Entry<String, Integer> decodeString(
byte[] buf, int offset, int available, Charset cs, int maxChars) {
- Map.Entry<byte[], Integer> result =
- readRLEBytes(buf, offset, available, maxChars * 4 /* in case UTF-8 with weird characters */);
+ Map.Entry<byte[], Integer> result = readRLEBytes(buf, offset, available, maxChars * 4 /*
+ * in case UTF-8 with
+ * weird characters
+ */);
byte[] bytes = result.getKey();
Integer nextOffset = result.getValue();
return new SimpleImmutableEntry<>(new String(bytes, cs), nextOffset);
@@ -244,17 +249,18 @@ public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>
/**
* Decodes a run-length encoded byte array
*
- * @param buf The buffer with the data bytes
- * @param offset The offset in the buffer to decode the array
- * @param available The max. available data starting from the offset
- * @param maxAllowed Max. allowed data in decoded buffer - if more than
- * that is encoded then an {@link IndexOutOfBoundsException} will be thrown
- * @return The decoded data buffer + the offset of the next byte after it
+ * @param buf The buffer with the data bytes
+ * @param offset The offset in the buffer to decode the array
+ * @param available The max. available data starting from the offset
+ * @param maxAllowed Max. allowed data in decoded buffer - if more than that is encoded then an
+ * {@link IndexOutOfBoundsException} will be thrown
+ * @return The decoded data buffer + the offset of the next byte after it
*/
static Map.Entry<byte[], Integer> readRLEBytes(byte[] buf, int offset, int available, int maxAllowed) {
int len = decodeInt(buf, offset, available);
if (len > maxAllowed) {
- throw new IndexOutOfBoundsException("Requested block length (" + len + ") exceeds max. allowed (" + maxAllowed + ")");
+ throw new IndexOutOfBoundsException(
+ "Requested block length (" + len + ") exceeds max. allowed (" + maxAllowed + ")");
}
if (len < 0) {
throw new IndexOutOfBoundsException("Negative block length requested: " + len);
@@ -277,12 +283,13 @@ public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>
static int decodeInt(byte[] buf, int offset, int available) {
if (available < Integer.BYTES) {
- throw new IndexOutOfBoundsException("Available data length (" + available + ") cannot accommodate integer encoding");
+ throw new IndexOutOfBoundsException(
+ "Available data length (" + available + ") cannot accommodate integer encoding");
}
return ((buf[offset] & 0xFF) << 24)
- | ((buf[offset + 1] & 0xFF) << 16)
- | ((buf[offset + 2] & 0xFF) << 8)
- | (buf[offset + 3] & 0xFF);
+ | ((buf[offset + 1] & 0xFF) << 16)
+ | ((buf[offset + 2] & 0xFF) << 8)
+ | (buf[offset + 3] & 0xFF);
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyRandomArt.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyRandomArt.java
index 5159a8b..eed719f 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyRandomArt.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyRandomArt.java
@@ -41,18 +41,16 @@ import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
/**
- * Draw an ASCII-Art representing the fingerprint so human brain can
- * profit from its built-in pattern recognition ability.
- * This technique is called "random art" and can be found in some
- * scientific publications like this original paper:
+ * Draw an ASCII-Art representing the fingerprint so human brain can profit from its built-in pattern recognition
+ * ability. This technique is called "random art" and can be found in some scientific publications like this original
+ * paper:
*
- * "Hash Visualization: a New Technique to improve Real-World Security",
- * Perrig A. and Song D., 1999, International Workshop on Cryptographic
- * Techniques and E-Commerce (CrypTEC '99)
+ * "Hash Visualization: a New Technique to improve Real-World Security", Perrig A. and Song D., 1999,
+ * International Workshop on Cryptographic Techniques and E-Commerce (CrypTEC '99)
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- * @see <a href="http://sparrow.ece.cmu.edu/~adrian/projects/validation/validation.pdf">Original article</a>
- * @see <a href="http://opensource.apple.com/source/OpenSSH/OpenSSH-175/openssh/key.c">C implementation</a>
+ * @see <a href="http://sparrow.ece.cmu.edu/~adrian/projects/validation/validation.pdf">Original article</a>
+ * @see <a href="http://opensource.apple.com/source/OpenSSH/OpenSSH-175/openssh/key.c">C implementation</a>
*/
public class KeyRandomArt implements AlgorithmNameProvider, KeySizeIndicator {
public static final int FLDBASE = 8;
@@ -80,8 +78,8 @@ public class KeyRandomArt implements AlgorithmNameProvider, KeySizeIndicator {
/**
* @param algorithm The key algorithm
- * @param keySize The key size in bits
- * @param digest The key digest
+ * @param keySize The key size in bits
+ * @param digest The key digest
*/
public KeyRandomArt(String algorithm, int keySize, byte[] digest) {
this.algorithm = ValidateUtils.checkNotNullAndNotEmpty(algorithm, "No algorithm provided");
@@ -114,14 +112,13 @@ public class KeyRandomArt implements AlgorithmNameProvider, KeySizeIndicator {
}
}
- /* mark starting point and end point*/
+ /* mark starting point and end point */
field[FLDSIZE_X / 2][FLDSIZE_Y / 2] = (char) (len - 1);
field[x][y] = (char) len;
}
/**
- * @return The algorithm that was used to generate the key - e.g.,
- * "RSA", "DSA", "EC".
+ * @return The algorithm that was used to generate the key - e.g., "RSA", "DSA", "EC".
*/
@Override
public String getAlgorithm() {
@@ -136,9 +133,9 @@ public class KeyRandomArt implements AlgorithmNameProvider, KeySizeIndicator {
/**
* Outputs the generated random art
*
- * @param <A> The {@link Appendable} output writer
- * @param sb The writer
- * @return The updated writer instance
+ * @param <A> The {@link Appendable} output writer
+ * @param sb The writer
+ * @return The updated writer instance
* @throws IOException If failed to write the combined result
*/
public <A extends Appendable> A append(A sb) throws IOException {
@@ -179,17 +176,16 @@ public class KeyRandomArt implements AlgorithmNameProvider, KeySizeIndicator {
try {
return append(new StringBuilder((FLDSIZE_X + 4) * (FLDSIZE_Y + 3))).toString();
} catch (IOException e) {
- return e.getClass().getSimpleName(); // unexpected
+ return e.getClass().getSimpleName(); // unexpected
}
}
/**
* Combines the arts in a user-friendly way so they are aligned with each other
*
- * @param separator The separator to use between the arts - if empty char
- * ('\0') then no separation is done
- * @param arts The {@link KeyRandomArt}s to combine - ignored if {@code null}/empty
- * @return The combined result
+ * @param separator The separator to use between the arts - if empty char ('\0') then no separation is done
+ * @param arts The {@link KeyRandomArt}s to combine - ignored if {@code null}/empty
+ * @return The combined result
*/
public static String combine(char separator, Collection<? extends KeyRandomArt> arts) {
if (GenericUtils.isEmpty(arts)) {
@@ -199,64 +195,60 @@ public class KeyRandomArt implements AlgorithmNameProvider, KeySizeIndicator {
try {
return combine(new StringBuilder(arts.size() * (FLDSIZE_X + 4) * (FLDSIZE_Y + 3)), separator, arts).toString();
} catch (IOException e) {
- return e.getClass().getSimpleName(); // unexpected
+ return e.getClass().getSimpleName(); // unexpected
}
}
/**
* Creates the combined representation of the random art entries for the provided keys
*
- * @param session The {@link SessionContext} for invoking this load command - may
- * be {@code null} if not invoked within a session context (e.g., offline tool or session unknown).
- * @param separator The separator to use between the arts - if empty char
- * ('\0') then no separation is done
- * @param provider The {@link KeyIdentityProvider} - ignored if {@code null}
- * or has no keys to provide
- * @return The combined representation
+ * @param session The {@link SessionContext} for invoking this load command - may be {@code null} if not invoked
+ * within a session context (e.g., offline tool or session unknown).
+ * @param separator The separator to use between the arts - if empty char ('\0') then no separation is done
+ * @param provider The {@link KeyIdentityProvider} - ignored if {@code null} or has no keys to provide
+ * @return The combined representation
* @throws Exception If failed to extract or combine the entries
- * @see #combine(SessionContext, Appendable, char, KeyIdentityProvider)
+ * @see #combine(SessionContext, Appendable, char, KeyIdentityProvider)
*/
public static String combine(
SessionContext session, char separator, KeyIdentityProvider provider)
- throws Exception {
+ throws Exception {
return combine(session, new StringBuilder(4 * (FLDSIZE_X + 4) * (FLDSIZE_Y + 3)), separator, provider).toString();
}
/**
* Appends the combined random art entries for the provided keys
*
- * @param <A> The {@link Appendable} output writer
- * @param session The {@link SessionContext} for invoking this load command - may
- * be {@code null} if not invoked within a session context (e.g., offline tool or session unknown).
- * @param sb The writer
- * @param separator The separator to use between the arts - if empty char
- * ('\0') then no separation is done
- * @param provider The {@link KeyIdentityProvider} - ignored if {@code null}
- * or has no keys to provide
- * @return The updated writer instance
+ * @param <A> The {@link Appendable} output writer
+ * @param session The {@link SessionContext} for invoking this load command - may be {@code null} if not invoked
+ * within a session context (e.g., offline tool or session unknown).
+ * @param sb The writer
+ * @param separator The separator to use between the arts - if empty char ('\0') then no separation is done
+ * @param provider The {@link KeyIdentityProvider} - ignored if {@code null} or has no keys to provide
+ * @return The updated writer instance
* @throws Exception If failed to extract or write the entries
- * @see #generate(SessionContext, KeyIdentityProvider)
- * @see #combine(Appendable, char, Collection)
+ * @see #generate(SessionContext, KeyIdentityProvider)
+ * @see #combine(Appendable, char, Collection)
*/
public static <A extends Appendable> A combine(
- SessionContext session, A sb, char separator, KeyIdentityProvider provider) throws Exception {
+ SessionContext session, A sb, char separator, KeyIdentityProvider provider)
+ throws Exception {
return combine(sb, separator, generate(session, provider));
}
/**
* Extracts and generates random art entries for all key in the provider
*
- * @param session The {@link SessionContext} for invoking this load command - may
- * be {@code null} if not invoked within a session context (e.g., offline tool or session unknown).
- * @param provider The {@link KeyIdentityProvider} - ignored if {@code null}
- * or has no keys to provide
- * @return The extracted {@link KeyRandomArt}s
+ * @param session The {@link SessionContext} for invoking this load command - may be {@code null} if not invoked
+ * within a session context (e.g., offline tool or session unknown).
+ * @param provider The {@link KeyIdentityProvider} - ignored if {@code null} or has no keys to provide
+ * @return The extracted {@link KeyRandomArt}s
* @throws Exception If failed to extract the entries
- * @see KeyIdentityProvider#loadKeys(SessionContext)
+ * @see KeyIdentityProvider#loadKeys(SessionContext)
*/
public static Collection<KeyRandomArt> generate(
SessionContext session, KeyIdentityProvider provider)
- throws Exception {
+ throws Exception {
Iterable<KeyPair> keys = (provider == null) ? null : provider.loadKeys(session);
Iterator<KeyPair> iter = (keys == null) ? null : keys.iterator();
if ((iter == null) || (!iter.hasNext())) {
@@ -276,15 +268,15 @@ public class KeyRandomArt implements AlgorithmNameProvider, KeySizeIndicator {
/**
* Combines the arts in a user-friendly way so they are aligned with each other
*
- * @param <A> The {@link Appendable} output writer
- * @param sb The writer
- * @param separator The separator to use between the arts - if empty char
- * ('\0') then no separation is done
- * @param arts The {@link KeyRandomArt}s to combine - ignored if {@code null}/empty
- * @return The updated writer instance
+ * @param <A> The {@link Appendable} output writer
+ * @param sb The writer
+ * @param separator The separator to use between the arts - if empty char ('\0') then no separation is done
+ * @param arts The {@link KeyRandomArt}s to combine - ignored if {@code null}/empty
+ * @return The updated writer instance
* @throws IOException If failed to write the combined result
*/
- public static <A extends Appendable> A combine(A sb, char separator, Collection<? extends KeyRandomArt> arts) throws IOException {
+ public static <A extends Appendable> A combine(A sb, char separator, Collection<? extends KeyRandomArt> arts)
+ throws IOException {
if (GenericUtils.isEmpty(arts)) {
return sb;
}
@@ -298,7 +290,8 @@ public class KeyRandomArt implements AlgorithmNameProvider, KeySizeIndicator {
numLines = lines.length;
} else {
if (numLines != lines.length) {
- throw new StreamCorruptedException("Mismatched lines count: expected=" + numLines + ", actual=" + lines.length);
+ throw new StreamCorruptedException(
+ "Mismatched lines count: expected=" + numLines + ", actual=" + lines.length);
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyTypeNamesSupport.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyTypeNamesSupport.java
index c9cee51..911b1f7 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyTypeNamesSupport.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyTypeNamesSupport.java
@@ -33,30 +33,29 @@ import org.apache.sshd.common.util.GenericUtils;
@FunctionalInterface
public interface KeyTypeNamesSupport {
/**
- * @return The case insensitive {@link NavigableSet} of {@code OpenSSH} key type
- * names that are supported by this decoder - e.g., {@code ssh-rsa, ssh-dss, ecdsa-sha2-nistp384}.
- * This is not a single name - e.g., ECDSA keys have several curve names.
- * <B>Caveat:</B> this collection may be un-modifiable...
+ * @return The case insensitive {@link NavigableSet} of {@code OpenSSH} key type names that are supported by this
+ * decoder - e.g., {@code ssh-rsa, ssh-dss, ecdsa-sha2-nistp384}. This is not a single name - e.g., ECDSA
+ * keys have several curve names. <B>Caveat:</B> this collection may be un-modifiable...
*/
NavigableSet<String> getSupportedKeyTypes();
/**
- * @param <S> Generic supporter type
- * @param typeName The {@code OpenSSH} key type e.g., {@code ssh-rsa, ssh-dss, ecdsa-sha2-nistp384}.
- * Ignored if {@code null}/empty.
- * @param supporters The {@link KeyTypeNamesSupport}-ers to query - ignored if {@code null}/empty.
- * @return The <U>first</U> instance whose {@link #getSupportedKeyTypes()} contains the type name.
+ * @param <S> Generic supporter type
+ * @param typeName The {@code OpenSSH} key type e.g., {@code ssh-rsa, ssh-dss, ecdsa-sha2-nistp384}. Ignored if
+ * {@code null}/empty.
+ * @param supporters The {@link KeyTypeNamesSupport}-ers to query - ignored if {@code null}/empty.
+ * @return The <U>first</U> instance whose {@link #getSupportedKeyTypes()} contains the type name.
*/
static <S extends KeyTypeNamesSupport> S findSupporterByKeyTypeName(String typeName, Collection<? extends S> supporters) {
return (GenericUtils.isEmpty(typeName) || GenericUtils.isEmpty(supporters))
- ? null
- : supporters.stream()
- .filter(s -> {
- Collection<String> names = (s == null)
- ? Collections.emptyNavigableSet()
- : s.getSupportedKeyTypes();
- return GenericUtils.isNotEmpty(names) && names.contains(typeName);
- }).findFirst()
- .orElse(null);
+ ? null
+ : supporters.stream()
+ .filter(s -> {
+ Collection<String> names = (s == null)
+ ? Collections.emptyNavigableSet()
+ : s.getSupportedKeyTypes();
+ return GenericUtils.isNotEmpty(names) && names.contains(typeName);
+ }).findFirst()
+ .orElse(null);
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyUtils.java
index fd89f9e..19d6a0e 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyUtils.java
@@ -115,25 +115,22 @@ public final class KeyUtils {
public static final String EC_ALGORITHM = "EC";
/**
- * The {@link Set} of {@link PosixFilePermission} <U>not</U> allowed if strict
- * permissions are enforced on key files
+ * The {@link Set} of {@link PosixFilePermission} <U>not</U> allowed if strict permissions are enforced on key files
*/
- public static final Set<PosixFilePermission> STRICTLY_PROHIBITED_FILE_PERMISSION =
- Collections.unmodifiableSet(
+ public static final Set<PosixFilePermission> STRICTLY_PROHIBITED_FILE_PERMISSION = Collections.unmodifiableSet(
EnumSet.of(
- PosixFilePermission.GROUP_READ, PosixFilePermission.GROUP_WRITE, PosixFilePermission.GROUP_EXECUTE,
- PosixFilePermission.OTHERS_READ, PosixFilePermission.OTHERS_WRITE, PosixFilePermission.OTHERS_EXECUTE));
+ PosixFilePermission.GROUP_READ, PosixFilePermission.GROUP_WRITE, PosixFilePermission.GROUP_EXECUTE,
+ PosixFilePermission.OTHERS_READ, PosixFilePermission.OTHERS_WRITE, PosixFilePermission.OTHERS_EXECUTE));
/**
- * System property that can be used to control the default fingerprint factory used for keys.
- * If not set the {@link #DEFAULT_FINGERPRINT_DIGEST_FACTORY} is used
+ * System property that can be used to control the default fingerprint factory used for keys. If not set the
+ * {@link #DEFAULT_FINGERPRINT_DIGEST_FACTORY} is used
*/
public static final String KEY_FINGERPRINT_FACTORY_PROP = "org.apache.sshd.keyFingerprintFactory";
/**
- * The default {@link Factory} of {@link Digest}s initialized
- * as the value of {@link #getDefaultFingerPrintFactory()} if not
- * overridden by {@link #KEY_FINGERPRINT_FACTORY_PROP} or
+ * The default {@link Factory} of {@link Digest}s initialized as the value of
+ * {@link #getDefaultFingerPrintFactory()} if not overridden by {@link #KEY_FINGERPRINT_FACTORY_PROP} or
* {@link #setDefaultFingerPrintFactory(DigestFactory)}
*/
public static final DigestFactory DEFAULT_FINGERPRINT_DIGEST_FACTORY = BuiltinDigests.sha256;
@@ -146,19 +143,18 @@ public final class KeyUtils {
private static final AtomicReference<DigestFactory> DEFAULT_DIGEST_HOLDER = new AtomicReference<>();
- private static final Map<String, PublicKeyEntryDecoder<?, ?>> BY_KEY_TYPE_DECODERS_MAP =
- new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ private static final Map<String, PublicKeyEntryDecoder<?, ?>> BY_KEY_TYPE_DECODERS_MAP
+ = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
- private static final Map<Class<?>, PublicKeyEntryDecoder<?, ?>> BY_KEY_CLASS_DECODERS_MAP =
- new HashMap<>();
+ private static final Map<Class<?>, PublicKeyEntryDecoder<?, ?>> BY_KEY_CLASS_DECODERS_MAP = new HashMap<>();
- private static final Map<String, String> KEY_TYPE_ALIASES =
- NavigableMapBuilder.<String, String>builder(String.CASE_INSENSITIVE_ORDER)
- .put(RSA_SHA256_KEY_TYPE_ALIAS, KeyPairProvider.SSH_RSA)
- .put(RSA_SHA512_KEY_TYPE_ALIAS, KeyPairProvider.SSH_RSA)
- .put(RSA_SHA256_CERT_TYPE_ALIAS, KeyPairProvider.SSH_RSA_CERT)
- .put(RSA_SHA512_CERT_TYPE_ALIAS, KeyPairProvider.SSH_RSA_CERT)
- .build();
+ private static final Map<String, String> KEY_TYPE_ALIASES
+ = NavigableMapBuilder.<String, String> builder(String.CASE_INSENSITIVE_ORDER)
+ .put(RSA_SHA256_KEY_TYPE_ALIAS, KeyPairProvider.SSH_RSA)
+ .put(RSA_SHA512_KEY_TYPE_ALIAS, KeyPairProvider.SSH_RSA)
+ .put(RSA_SHA256_CERT_TYPE_ALIAS, KeyPairProvider.SSH_RSA_CERT)
+ .put(RSA_SHA512_CERT_TYPE_ALIAS, KeyPairProvider.SSH_RSA_CERT)
+ .build();
static {
registerPublicKeyEntryDecoder(OpenSSHCertificateDecoder.INSTANCE);
@@ -180,47 +176,58 @@ public final class KeyUtils {
}
/**
- * <P>Checks if a path has strict permissions</P>
+ * <P>
+ * Checks if a path has strict permissions
+ * </P>
* <UL>
- * <LI><P>
- * The path may not have {@link PosixFilePermission#OTHERS_EXECUTE}
- * permission
- * </P></LI>
+ * <LI>
+ * <P>
+ * The path may not have {@link PosixFilePermission#OTHERS_EXECUTE} permission
+ * </P>
+ * </LI>
*
- * <LI><P>
+ * <LI>
+ * <P>
* (For {@code Unix}) The path may not have group or others permissions
- * </P></LI>
+ * </P>
+ * </LI>
*
- * <LI><P>
- * (For {@code Unix}) If the path is a file, then its folder may not have
- * group or others permissions
- * </P></LI>
+ * <LI>
+ * <P>
+ * (For {@code Unix}) If the path is a file, then its folder may not have group or others permissions
+ * </P>
+ * </LI>
*
- * <LI><P>
+ * <LI>
+ * <P>
* The path must be owned by current user.
- * </P></LI>
+ * </P>
+ * </LI>
*
- * <LI><P>
+ * <LI>
+ * <P>
* (For {@code Unix}) The path may be owned by root.
- * </P></LI>
+ * </P>
+ * </LI>
*
- * <LI><P>
- * (For {@code Unix}) If the path is a file, then its folder must also
- * have valid owner.
- * </P></LI>
+ * <LI>
+ * <P>
+ * (For {@code Unix}) If the path is a file, then its folder must also have valid owner.
+ * </P>
+ * </LI>
*
* </UL>
*
- * @param path The {@link Path} to be checked - ignored if {@code null}
- * or does not exist
- * @param options The {@link LinkOption}s to use to query the file's permissions
- * @return The violated permission as {@link SimpleImmutableEntry} where key is a message and
- * value is the offending object {@link PosixFilePermission} or {@link String} for owner - {@code null}
- * if no violations detected
+ * @param path The {@link Path} to be checked - ignored if {@code null} or does not exist
+ * @param options The {@link LinkOption}s to use to query the file's permissions
+ * @return The violated permission as {@link SimpleImmutableEntry} where key is a message and value is
+ * the offending object {@link PosixFilePermission} or {@link String} for owner - {@code null}
+ * if no violations detected
* @throws IOException If failed to retrieve the permissions
- * @see #STRICTLY_PROHIBITED_FILE_PERMISSION
+ * @see #STRICTLY_PROHIBITED_FILE_PERMISSION
*/
- public static SimpleImmutableEntry<String, Object> validateStrictKeyFilePermissions(Path path, LinkOption... options) throws IOException {
+ public static SimpleImmutableEntry<String, Object> validateStrictKeyFilePermissions(Path path, LinkOption... options)
+ throws IOException {
if ((path == null) || (!Files.exists(path, options))) {
return null;
}
@@ -243,7 +250,8 @@ public final class KeyUtils {
if (Files.isRegularFile(path, options)) {
Path parent = path.getParent();
- p = IoUtils.validateExcludedPermissions(IoUtils.getPermissions(parent, options), STRICTLY_PROHIBITED_FILE_PERMISSION);
+ p = IoUtils.validateExcludedPermissions(IoUtils.getPermissions(parent, options),
+ STRICTLY_PROHIBITED_FILE_PERMISSION);
if (p != null) {
return new SimpleImmutableEntry<>(String.format("Parent permissions violation (%s)", p), p);
}
@@ -283,12 +291,12 @@ public final class KeyUtils {
}
/**
- * @param keyType The key type - {@code OpenSSH} name - e.g., {@code ssh-rsa, ssh-dss}
- * @param keySize The key size (in bits)
- * @return A {@link KeyPair} of the specified type and size
+ * @param keyType The key type - {@code OpenSSH} name - e.g., {@code ssh-rsa, ssh-dss}
+ * @param keySize The key size (in bits)
+ * @return A {@link KeyPair} of the specified type and size
* @throws GeneralSecurityException If failed to generate the key pair
- * @see #getPublicKeyEntryDecoder(String)
- * @see PublicKeyEntryDecoder#generateKeyPair(int)
+ * @see #getPublicKeyEntryDecoder(String)
+ * @see PublicKeyEntryDecoder#generateKeyPair(int)
*/
public static KeyPair generateKeyPair(String keyType, int keySize) throws GeneralSecurityException {
PublicKeyEntryDecoder<?, ?> decoder = getPublicKeyEntryDecoder(keyType);
@@ -300,12 +308,12 @@ public final class KeyUtils {
}
/**
- * Performs a deep-clone of the original {@link KeyPair} - i.e., creates
- * <U>new</U> public/private keys that are clones of the original one
+ * Performs a deep-clone of the original {@link KeyPair} - i.e., creates <U>new</U> public/private keys that are
+ * clones of the original one
*
- * @param keyType The key type - {@code OpenSSH} name - e.g., {@code ssh-rsa, ssh-dss}
- * @param kp The {@link KeyPair} to clone - ignored if {@code null}
- * @return The cloned instance
+ * @param keyType The key type - {@code OpenSSH} name - e.g., {@code ssh-rsa, ssh-dss}
+ * @param kp The {@link KeyPair} to clone - ignored if {@code null}
+ * @return The cloned instance
* @throws GeneralSecurityException If failed to clone the pair
*/
public static KeyPair cloneKeyPair(String keyType, KeyPair kp) throws GeneralSecurityException {
@@ -318,10 +326,10 @@ public final class KeyUtils {
}
/**
- * @param decoder The decoder to register
+ * @param decoder The decoder to register
* @throws IllegalArgumentException if no decoder or not key type or no supported names for the decoder
- * @see PublicKeyEntryDecoder#getPublicKeyType()
- * @see PublicKeyEntryDecoder#getSupportedKeyTypes()
+ * @see PublicKeyEntryDecoder#getPublicKeyType()
+ * @see PublicKeyEntryDecoder#getSupportedKeyTypes()
*/
public static void registerPublicKeyEntryDecoder(PublicKeyEntryDecoder<?, ?> decoder) {
Objects.requireNonNull(decoder, "No decoder specified");
@@ -337,31 +345,33 @@ public final class KeyUtils {
}
/**
- * Registers the specified decoder for all the types it {@link PublicKeyEntryDecoder#getSupportedKeyTypes() supports}
+ * Registers the specified decoder for all the types it {@link PublicKeyEntryDecoder#getSupportedKeyTypes()
+ * supports}
*
* @param decoder The (never {@code null}) {@link PublicKeyEntryDecoder decoder} to register
- * @see #registerPublicKeyEntryDecoderForKeyType(String, PublicKeyEntryDecoder)
... 67083 lines suppressed ...