[SSHD-542] Checkstyle validation Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/17f2d627 Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/17f2d627 Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/17f2d627
Branch: refs/heads/master Commit: 17f2d627a9798483230b7a3a747842ff7d967cb9 Parents: 0d86de5 Author: Guillaume Nodet <[email protected]> Authored: Fri Jul 17 17:48:23 2015 +0200 Committer: Guillaume Nodet <[email protected]> Committed: Fri Jul 17 18:12:39 2015 +0200 ---------------------------------------------------------------------- pom.xml | 302 ++++ sshd-core/pom.xml | 10 +- .../org/apache/sshd/agent/SshAgentFactory.java | 1 + .../org/apache/sshd/agent/SshAgentServer.java | 15 +- .../sshd/agent/common/AbstractAgentClient.java | 100 +- .../sshd/agent/common/AbstractAgentProxy.java | 26 +- .../sshd/agent/common/AgentForwardSupport.java | 4 +- .../org/apache/sshd/agent/local/AgentImpl.java | 1 - .../sshd/agent/local/AgentServerProxy.java | 5 +- .../org/apache/sshd/agent/unix/AgentClient.java | 13 +- .../org/apache/sshd/agent/unix/AgentServer.java | 43 +- .../sshd/agent/unix/AgentServerProxy.java | 84 +- .../org/apache/sshd/agent/unix/AprLibrary.java | 86 +- .../sshd/agent/unix/ChannelAgentForwarding.java | 37 +- .../unix/ChannelAgentForwardingFactory.java | 4 +- .../sshd/agent/unix/UnixAgentFactory.java | 24 +- .../org/apache/sshd/client/ClientBuilder.java | 43 +- .../sshd/client/ClientFactoryManager.java | 24 +- .../apache/sshd/client/ServerKeyVerifier.java | 4 +- .../org/apache/sshd/client/SessionFactory.java | 3 +- .../java/org/apache/sshd/client/SshClient.java | 141 +- .../java/org/apache/sshd/client/SshKeyScan.java | 105 +- .../sshd/client/auth/UserAuthFactory.java | 11 +- .../auth/UserAuthKeyboardInteractive.java | 33 +- .../sshd/client/auth/UserAuthPublicKey.java | 11 +- .../sshd/client/auth/UserInteraction.java | 10 +- .../client/channel/AbstractClientChannel.java | 4 +- .../sshd/client/channel/ChannelDirectTcpip.java | 6 +- .../apache/sshd/client/channel/ChannelExec.java | 1 - .../sshd/client/channel/ChannelSession.java | 23 +- .../sshd/client/channel/ChannelSubsystem.java | 1 - .../sshd/client/channel/ClientChannel.java | 8 +- .../channel/PtyCapableChannelSession.java | 62 +- .../sshd/client/config/keys/ClientIdentity.java | 250 +-- .../apache/sshd/client/future/AuthFuture.java | 5 +- .../sshd/client/future/ConnectFuture.java | 7 +- .../sshd/client/future/DefaultAuthFuture.java | 3 +- .../client/future/DefaultConnectFuture.java | 3 +- .../sshd/client/future/DefaultOpenFuture.java | 3 +- .../apache/sshd/client/future/OpenFuture.java | 5 +- .../client/kex/AbstractDHClientKeyExchange.java | 5 +- .../org/apache/sshd/client/kex/DHGClient.java | 46 +- .../org/apache/sshd/client/kex/DHGEXClient.java | 35 +- .../keyverifier/AcceptAllServerKeyVerifier.java | 8 +- .../DelegatingServerKeyVerifier.java | 24 +- .../keyverifier/RequiredServerKeyVerifier.java | 30 +- .../keyverifier/StaticServerKeyVerifier.java | 7 +- .../sshd/client/scp/AbstractScpClient.java | 29 +- .../sshd/client/scp/DefaultScpClient.java | 110 +- .../org/apache/sshd/client/scp/ScpClient.java | 17 +- .../client/session/ClientConnectionService.java | 1 - .../sshd/client/session/ClientSession.java | 76 +- .../sshd/client/session/ClientSessionImpl.java | 89 +- .../client/session/ClientUserAuthService.java | 12 +- .../subsystem/sftp/AbstractSftpClient.java | 504 +++--- .../subsystem/sftp/DefaultSftpClient.java | 50 +- .../client/subsystem/sftp/RawSftpClient.java | 4 +- .../sshd/client/subsystem/sftp/SftpClient.java | 130 +- .../sshd/client/subsystem/sftp/SftpCommand.java | 521 ++++--- .../client/subsystem/sftp/SftpFileChannel.java | 39 +- .../client/subsystem/sftp/SftpFileStore.java | 12 +- .../client/subsystem/sftp/SftpFileSystem.java | 29 +- .../subsystem/sftp/SftpFileSystemProvider.java | 475 +++--- .../subsystem/sftp/SftpVersionSelector.java | 26 +- .../extensions/BuiltinSftpClientExtensions.java | 143 +- .../extensions/CheckFileHandleExtension.java | 12 +- .../sftp/extensions/CheckFileNameExtension.java | 12 +- .../sftp/extensions/CopyDataExtension.java | 1 + .../sftp/extensions/CopyFileExtension.java | 4 +- .../sftp/extensions/MD5FileExtension.java | 8 +- .../sftp/extensions/MD5HandleExtension.java | 8 +- .../extensions/SftpClientExtensionFactory.java | 3 +- .../extensions/SpaceAvailableExtension.java | 3 +- .../impl/AbstractCheckFileExtension.java | 14 +- .../impl/AbstractMD5HashExtension.java | 12 +- .../impl/AbstractSftpClientExtension.java | 22 +- .../impl/CheckFileHandleExtensionImpl.java | 2 +- .../impl/CheckFileNameExtensionImpl.java | 2 +- .../extensions/impl/CopyDataExtensionImpl.java | 9 +- .../extensions/impl/CopyFileExtensionImpl.java | 6 +- .../extensions/impl/MD5FileExtensionImpl.java | 2 +- .../extensions/impl/MD5HandleExtensionImpl.java | 2 +- .../impl/SpaceAvailableExtensionImpl.java | 2 +- .../openssh/OpenSSHFsyncExtension.java | 1 + .../openssh/OpenSSHStatExtensionInfo.java | 81 +- .../openssh/OpenSSHStatHandleExtension.java | 1 + .../openssh/OpenSSHStatPathExtension.java | 1 + .../AbstractOpenSSHStatCommandExtension.java | 8 +- .../openssh/impl/OpenSSHFsyncExtensionImpl.java | 2 +- .../impl/OpenSSHStatHandleExtensionImpl.java | 2 +- .../impl/OpenSSHStatPathExtensionImpl.java | 2 +- .../sshd/common/AbstractFactoryManager.java | 7 +- .../org/apache/sshd/common/BaseBuilder.java | 172 +- .../org/apache/sshd/common/BuiltinFactory.java | 51 + .../java/org/apache/sshd/common/Factory.java | 1 - .../org/apache/sshd/common/FactoryManager.java | 18 +- .../apache/sshd/common/FactoryManagerUtils.java | 35 +- .../org/apache/sshd/common/NamedFactory.java | 26 +- .../org/apache/sshd/common/NamedResource.java | 72 +- .../java/org/apache/sshd/common/Service.java | 4 +- .../org/apache/sshd/common/ServiceFactory.java | 10 +- .../org/apache/sshd/common/SshConstants.java | 142 +- .../apache/sshd/common/SshdSocketAddress.java | 49 +- .../sshd/common/channel/AbstractChannel.java | 19 +- .../common/channel/ChannelAsyncInputStream.java | 2 +- .../sshd/common/channel/ChannelFactory.java | 10 +- .../common/channel/ChannelOutputStream.java | 22 +- .../common/channel/ChannelPipedInputStream.java | 5 +- .../sshd/common/channel/ChannelPipedSink.java | 4 +- .../common/channel/ChannelRequestHandler.java | 19 +- .../sshd/common/channel/IoWriteFutureImpl.java | 1 - .../org/apache/sshd/common/channel/PtyMode.java | 27 +- .../apache/sshd/common/channel/SttySupport.java | 69 +- .../org/apache/sshd/common/channel/Window.java | 17 +- .../common/channel/WindowClosedException.java | 2 +- .../apache/sshd/common/cipher/BaseCipher.java | 9 +- .../sshd/common/cipher/BaseRC4Cipher.java | 4 +- .../sshd/common/cipher/BuiltinCiphers.java | 125 +- .../org/apache/sshd/common/cipher/Cipher.java | 13 +- .../sshd/common/cipher/CipherFactory.java | 15 +- .../org/apache/sshd/common/cipher/ECCurves.java | 227 +-- .../org/apache/sshd/common/cipher/package.html | 4 +- .../common/compression/BuiltinCompressions.java | 131 +- .../sshd/common/compression/Compression.java | 4 +- .../compression/CompressionDelayedZlib.java | 3 +- .../common/compression/CompressionFactory.java | 15 +- .../common/compression/CompressionZlib.java | 3 +- .../common/config/AllowTcpForwardingValue.java | 2 +- .../common/config/CompressionConfigValue.java | 22 +- .../common/config/FactoriesListParseResult.java | 4 +- .../sshd/common/config/ListParseResult.java | 6 +- .../sshd/common/config/LogLevelValue.java | 2 +- .../config/NamedFactoriesListParseResult.java | 8 +- .../config/NamedResourceListParseResult.java | 3 +- .../sshd/common/config/SshConfigFileReader.java | 304 ++-- .../sshd/common/config/SyslogFacilityValue.java | 2 +- .../sshd/common/config/TimeValueConfig.java | 73 +- .../sshd/common/config/VersionProperties.java | 31 +- .../keys/AbstractPublicKeyEntryDecoder.java | 93 +- .../common/config/keys/BuiltinIdentities.java | 68 +- .../config/keys/DSSPublicKeyEntryDecoder.java | 21 +- .../config/keys/ECDSAPublicKeyEntryDecoder.java | 201 +-- .../config/keys/FilePasswordProvider.java | 2 +- .../sshd/common/config/keys/Identity.java | 4 +- .../sshd/common/config/keys/IdentityUtils.java | 50 +- .../sshd/common/config/keys/KeyUtils.java | 294 ++-- .../sshd/common/config/keys/PublicKeyEntry.java | 106 +- .../config/keys/PublicKeyEntryDecoder.java | 22 +- .../common/config/keys/RSAPublicKeyDecoder.java | 13 +- .../apache/sshd/common/digest/BaseDigest.java | 23 +- .../sshd/common/digest/BuiltinDigests.java | 18 +- .../org/apache/sshd/common/digest/Digest.java | 1 + .../sshd/common/digest/DigestFactory.java | 9 +- .../apache/sshd/common/digest/DigestUtils.java | 38 +- .../sshd/common/file/FileSystemFactory.java | 3 +- .../file/nativefs/NativeFileSystemFactory.java | 6 +- .../file/root/RootedFileSystemProvider.java | 22 +- .../sshd/common/file/util/BaseFileSystem.java | 146 +- .../apache/sshd/common/file/util/BasePath.java | 10 +- .../sshd/common/file/util/ImmutableList.java | 3 +- .../virtualfs/VirtualFileSystemFactory.java | 4 +- .../common/forward/DefaultTcpipForwarder.java | 64 +- .../forward/DefaultTcpipForwarderFactory.java | 2 +- .../common/forward/LocalForwardingEntry.java | 12 +- .../apache/sshd/common/forward/SocksProxy.java | 31 +- .../sshd/common/forward/TcpipClientChannel.java | 6 +- .../sshd/common/forward/TcpipForwarder.java | 28 +- .../sshd/common/future/DefaultSshFuture.java | 73 +- .../apache/sshd/common/future/SshFuture.java | 9 +- .../sshd/common/future/SshFutureListener.java | 4 +- .../io/AbstractIoServiceFactoryFactory.java | 6 +- .../io/BuiltinIoServiceFactoryFactories.java | 25 +- .../io/DefaultIoServiceFactoryFactory.java | 6 +- .../apache/sshd/common/io/IoConnectFuture.java | 2 +- .../org/apache/sshd/common/io/IoHandler.java | 2 +- .../apache/sshd/common/io/IoHandlerFactory.java | 11 +- .../org/apache/sshd/common/io/IoReadFuture.java | 3 + .../apache/sshd/common/io/IoWriteFuture.java | 3 + .../sshd/common/io/mina/MinaAcceptor.java | 11 +- .../sshd/common/io/mina/MinaConnector.java | 5 +- .../apache/sshd/common/io/mina/MinaService.java | 15 +- .../sshd/common/io/mina/MinaServiceFactory.java | 4 +- .../io/mina/MinaServiceFactoryFactory.java | 12 +- .../apache/sshd/common/io/mina/MinaSession.java | 3 +- .../apache/sshd/common/io/mina/MinaSupport.java | 6 +- .../sshd/common/io/nio2/Nio2Acceptor.java | 22 +- .../common/io/nio2/Nio2CompletionHandler.java | 2 +- .../sshd/common/io/nio2/Nio2Connector.java | 6 + .../io/nio2/Nio2DefaultIoWriteFuture.java | 1 - .../sshd/common/io/nio2/Nio2ServiceFactory.java | 8 +- .../io/nio2/Nio2ServiceFactoryFactory.java | 13 +- .../apache/sshd/common/io/nio2/Nio2Session.java | 25 +- .../org/apache/sshd/common/kex/AbstractDH.java | 19 +- .../sshd/common/kex/BuiltinDHFactories.java | 88 +- .../java/org/apache/sshd/common/kex/DHG.java | 1 - .../org/apache/sshd/common/kex/DHGroupData.java | 114 +- .../java/org/apache/sshd/common/kex/ECDH.java | 2 - .../sshd/common/kex/KexProposalOption.java | 74 +- .../org/apache/sshd/common/kex/KexState.java | 3 +- .../org/apache/sshd/common/kex/KeyExchange.java | 14 +- .../sshd/common/kex/KeyExchangeFactory.java | 9 +- .../common/kex/dh/AbstractDHKeyExchange.java | 30 +- ...actClassLoadableResourceKeyPairProvider.java | 5 +- .../AbstractFileKeyPairProvider.java | 1 + .../AbstractResourceKeyPairProvider.java | 139 +- .../common/keyprovider/KeyPairProvider.java | 44 +- .../keyprovider/MappedKeyPairProvider.java | 14 +- .../org/apache/sshd/common/mac/BuiltinMacs.java | 73 +- .../org/apache/sshd/common/mac/MacFactory.java | 15 +- .../sshd/common/random/AbstractRandom.java | 2 +- .../apache/sshd/common/random/JceRandom.java | 4 +- .../sshd/common/random/JceRandomFactory.java | 2 +- .../org/apache/sshd/common/random/Random.java | 4 +- .../sshd/common/random/RandomFactory.java | 15 +- .../scp/LocalFileScpSourceStreamResolver.java | 4 +- .../scp/LocalFileScpTargetStreamResolver.java | 10 +- .../org/apache/sshd/common/scp/ScpHelper.java | 80 +- .../sshd/common/scp/ScpReceiveLineHandler.java | 4 +- .../common/scp/ScpSourceStreamResolver.java | 4 +- .../common/scp/ScpTargetStreamResolver.java | 16 +- .../apache/sshd/common/scp/ScpTimestamp.java | 25 +- .../common/scp/ScpTransferEventListener.java | 53 +- .../session/AbstractConnectionService.java | 50 +- .../sshd/common/session/AbstractSession.java | 509 +++--- .../common/session/AbstractSessionFactory.java | 2 +- .../sshd/common/session/ConnectionService.java | 2 + .../ConnectionServiceRequestHandler.java | 12 +- .../sshd/common/session/PendingWriteFuture.java | 2 +- .../org/apache/sshd/common/session/Session.java | 24 +- .../sshd/common/session/SessionListener.java | 3 + .../common/session/SessionTimeoutListener.java | 2 +- .../common/signature/AbstractSignature.java | 13 +- .../common/signature/BuiltinSignatures.java | 83 +- .../apache/sshd/common/signature/Signature.java | 7 +- .../sshd/common/signature/SignatureDSA.java | 21 +- .../sshd/common/signature/SignatureECDSA.java | 27 +- .../sshd/common/signature/SignatureFactory.java | 15 +- .../sshd/common/signature/SignatureRSA.java | 2 +- .../common/subsystem/sftp/SftpConstants.java | 381 ++--- .../sftp/extensions/AbstractParser.java | 4 +- .../sftp/extensions/ExtensionParser.java | 1 + .../sftp/extensions/NewlineParser.java | 9 +- .../subsystem/sftp/extensions/ParserUtils.java | 70 +- .../extensions/SpaceAvailableExtensionInfo.java | 50 +- .../sftp/extensions/Supported2Parser.java | 32 +- .../sftp/extensions/SupportedParser.java | 16 +- .../sftp/extensions/VendorIdParser.java | 7 +- .../sftp/extensions/VersionsParser.java | 11 +- .../openssh/AbstractOpenSSHExtensionParser.java | 18 +- .../org/apache/sshd/common/util/Base64.java | 132 +- .../apache/sshd/common/util/CloseableUtils.java | 47 +- .../sshd/common/util/DirectoryScanner.java | 33 +- .../apache/sshd/common/util/GenericUtils.java | 224 ++- .../sshd/common/util/Int2IntFunction.java | 26 +- .../apache/sshd/common/util/ObjectBuilder.java | 3 +- .../org/apache/sshd/common/util/OsUtils.java | 24 +- .../java/org/apache/sshd/common/util/Pair.java | 3 +- .../apache/sshd/common/util/SecurityUtils.java | 66 +- .../apache/sshd/common/util/SelectorUtils.java | 64 +- .../apache/sshd/common/util/Transformer.java | 56 +- .../apache/sshd/common/util/ValidateUtils.java | 18 +- .../apache/sshd/common/util/buffer/Buffer.java | 136 +- .../sshd/common/util/buffer/BufferUtils.java | 163 +- .../common/util/buffer/ByteArrayBuffer.java | 1 + .../util/io/CloseableEmptyInputStream.java | 3 +- .../apache/sshd/common/util/io/DERParser.java | 51 +- .../apache/sshd/common/util/io/DERWriter.java | 13 +- .../sshd/common/util/io/EmptyInputStream.java | 5 +- .../sshd/common/util/io/FileInfoExtractor.java | 16 +- .../org/apache/sshd/common/util/io/IoUtils.java | 129 +- .../sshd/common/util/io/LimitInputStream.java | 1 + .../util/io/LoggingFilterOutputStream.java | 2 +- .../common/util/io/ModifiableFileWatcher.java | 25 +- .../sshd/common/util/io/NoCloseReader.java | 2 +- .../sshd/common/util/io/NoCloseWriter.java | 2 +- .../util/logging/AbstractLoggingBean.java | 6 +- .../sshd/common/util/logging/LoggingUtils.java | 62 +- .../sshd/common/util/logging/SimplifiedLog.java | 42 +- .../util/threads/ExecutorServiceCarrier.java | 1 + .../util/threads/ExecutorServiceConfigurer.java | 1 + .../sshd/common/util/threads/ThreadUtils.java | 55 +- .../org/apache/sshd/server/AsyncCommand.java | 3 + .../apache/sshd/server/ChannelSessionAware.java | 3 +- .../java/org/apache/sshd/server/Command.java | 6 +- .../org/apache/sshd/server/Environment.java | 10 +- .../org/apache/sshd/server/ExitCallback.java | 2 +- .../org/apache/sshd/server/ServerBuilder.java | 66 +- .../sshd/server/ServerFactoryManager.java | 8 +- .../java/org/apache/sshd/server/Signal.java | 18 +- .../org/apache/sshd/server/SignalListener.java | 1 - .../java/org/apache/sshd/server/SshServer.java | 80 +- .../auth/CachingPublicKeyAuthenticator.java | 3 +- .../org/apache/sshd/server/auth/UserAuth.java | 10 +- .../sshd/server/auth/UserAuthFactory.java | 9 +- .../auth/UserAuthKeyboardInteractive.java | 11 +- .../sshd/server/auth/UserAuthNoneFactory.java | 1 + .../sshd/server/auth/UserAuthPassword.java | 1 - .../server/auth/UserAuthPasswordFactory.java | 3 +- .../sshd/server/auth/UserAuthPublicKey.java | 3 +- .../server/auth/UserAuthPublicKeyFactory.java | 1 + .../sshd/server/auth/gss/CredentialHelper.java | 9 +- .../sshd/server/auth/gss/GSSAuthenticator.java | 1 - .../sshd/server/auth/gss/UserAuthGSS.java | 9 +- .../server/auth/gss/UserAuthGSSFactory.java | 2 +- .../auth/password/PasswordAuthenticator.java | 4 +- .../password/StaticPasswordAuthenticator.java | 4 +- .../pubkey/KeySetPublickeyAuthenticator.java | 8 +- .../auth/pubkey/PublickeyAuthenticator.java | 5 +- .../pubkey/StaticPublickeyAuthenticator.java | 4 +- .../server/channel/AbstractServerChannel.java | 2 +- .../server/channel/ChannelDataReceiver.java | 67 +- .../sshd/server/channel/ChannelSession.java | 39 +- .../server/channel/ChannelSessionFactory.java | 2 +- .../server/channel/OpenChannelException.java | 10 +- .../server/channel/PuttyRequestHandler.java | 2 +- .../apache/sshd/server/command/ScpCommand.java | 27 +- .../sshd/server/command/ScpCommandFactory.java | 34 +- .../server/config/keys/AuthorizedKeyEntry.java | 133 +- .../keys/AuthorizedKeysAuthenticator.java | 17 +- .../DefaultAuthorizedKeysAuthenticator.java | 26 +- .../sshd/server/config/keys/ServerIdentity.java | 91 +- .../sshd/server/forward/DirectTcpipFactory.java | 2 +- .../server/forward/ForwardedTcpipFactory.java | 2 +- .../sshd/server/forward/ForwardingFilter.java | 43 +- .../forward/StaticDecisionForwardingFilter.java | 8 +- .../sshd/server/forward/TcpipServerChannel.java | 46 +- .../global/CancelTcpipForwardHandler.java | 4 +- .../sshd/server/global/TcpipForwardHandler.java | 2 +- .../server/jaas/JaasPasswordAuthenticator.java | 7 +- .../server/kex/AbstractDHServerKeyExchange.java | 5 +- .../org/apache/sshd/server/kex/DHGEXServer.java | 41 +- .../org/apache/sshd/server/kex/DHGServer.java | 43 +- .../java/org/apache/sshd/server/kex/Moduli.java | 10 +- .../AbstractGeneratorHostKeyProvider.java | 31 +- .../SimpleGeneratorHostKeyProvider.java | 4 +- .../server/session/ServerConnectionService.java | 3 +- .../sshd/server/session/ServerSession.java | 6 +- .../sshd/server/session/ServerSessionImpl.java | 43 +- .../server/session/ServerUserAuthService.java | 8 +- .../sshd/server/session/SessionFactory.java | 5 +- .../shell/InteractiveProcessShellFactory.java | 24 +- .../apache/sshd/server/shell/InvertedShell.java | 5 +- .../sshd/server/shell/InvertedShellWrapper.java | 12 +- .../sshd/server/shell/ProcessShellFactory.java | 19 +- .../sshd/server/subsystem/SubsystemFactory.java | 9 +- .../subsystem/sftp/DefaultGroupPrincipal.java | 32 + .../subsystem/sftp/DefaultUserPrincipal.java | 32 + .../server/subsystem/sftp/DirectoryHandle.java | 94 ++ .../sshd/server/subsystem/sftp/FileHandle.java | 188 +++ .../sshd/server/subsystem/sftp/Handle.java | 48 + .../subsystem/sftp/InvalidHandleException.java | 32 + .../server/subsystem/sftp/PrincipalBase.java | 65 + .../sshd/server/subsystem/sftp/SftpHelper.java | 545 +++++++ .../server/subsystem/sftp/SftpSubsystem.java | 1472 +++++------------- .../server/subsystem/sftp/UnixDateFormat.java | 97 ++ .../sshd/server/x11/X11ForwardSupport.java | 20 +- .../org/apache/sshd/AuthenticationTest.java | 43 +- .../java/org/apache/sshd/KeepAliveTest.java | 64 +- .../java/org/apache/sshd/KeyReExchangeTest.java | 83 +- .../src/test/java/org/apache/sshd/LoadTest.java | 24 +- .../org/apache/sshd/PortForwardingLoadTest.java | 161 +- .../org/apache/sshd/PortForwardingTest.java | 260 ++-- .../test/java/org/apache/sshd/ProxyTest.java | 26 +- .../apache/sshd/SinglePublicKeyAuthTest.java | 19 +- .../java/org/apache/sshd/WelcomeBannerTest.java | 9 +- .../java/org/apache/sshd/WindowAdjustTest.java | 26 +- .../test/java/org/apache/sshd/WindowTest.java | 105 +- .../java/org/apache/sshd/agent/AgentTest.java | 60 +- .../java/org/apache/sshd/client/ClientTest.java | 430 ++--- .../org/apache/sshd/client/SshClientMain.java | 1 + .../client/config/keys/ClientIdentityTest.java | 10 +- .../org/apache/sshd/client/kex/KexTest.java | 45 +- .../StaticServerKeyVerifierTest.java | 20 +- .../org/apache/sshd/client/scp/ScpTest.java | 133 +- .../client/session/ClientSessionImplTest.java | 20 +- .../sftp/AbstractSftpClientTestSupport.java | 4 +- .../sftp/DefaultCloseableHandleTest.java | 34 +- .../client/subsystem/sftp/SftpCommandMain.java | 1 + .../subsystem/sftp/SftpFileSystemTest.java | 104 +- .../sshd/client/subsystem/sftp/SftpTest.java | 227 +-- .../BuiltinSftpClientExtensionsTest.java | 8 +- .../impl/AbstractCheckFileExtensionTest.java | 57 +- .../impl/AbstractMD5HashExtensionTest.java | 38 +- .../impl/CopyDataExtensionImplTest.java | 85 +- .../impl/CopyFileExtensionImplTest.java | 16 +- .../impl/SpaceAvailableExtensionImplTest.java | 34 +- .../openssh/impl/OpenSSHExtensionsTest.java | 132 +- .../sshd/common/FactoryManagerUtilsTest.java | 68 +- .../sshd/common/ForwardingFilterTest.java | 11 +- .../org/apache/sshd/common/SshBuilderTest.java | 24 +- .../channel/ChannelPipedInputStreamTest.java | 12 +- .../channel/ChannelPipedOutputStreamTest.java | 36 +- .../sshd/common/cipher/AES192CTRTest.java | 18 +- .../sshd/common/cipher/AES256CBCTest.java | 18 +- .../sshd/common/cipher/ARCFOUR128Test.java | 14 +- .../sshd/common/cipher/ARCFOUR256Test.java | 18 +- .../sshd/common/cipher/BaseCipherTest.java | 89 +- .../sshd/common/cipher/BuiltinCiphersTest.java | 111 +- .../apache/sshd/common/cipher/CipherTest.java | 48 +- .../apache/sshd/common/cipher/ECCurvesTest.java | 10 +- .../compression/BuiltinCompressionsTest.java | 78 +- .../common/compression/CompressionTest.java | 19 +- .../common/config/SshConfigFileReaderTest.java | 100 +- .../sshd/common/config/TimeValueConfigTest.java | 12 +- .../config/keys/BuiltinIdentitiesTest.java | 6 +- .../sshd/common/config/keys/KeyUtilsTest.java | 54 +- .../BuiltinIoServiceFactoryFactoriesTest.java | 6 +- .../io/DefaultIoServiceFactoryFactoryTest.java | 16 +- .../apache/sshd/common/kex/AbstractDHTest.java | 14 +- .../sshd/common/kex/BuiltinDHFactoriesTest.java | 60 +- .../sshd/common/kex/KexProposalOptionTest.java | 26 +- .../common/keyprovider/KeyPairProviderTest.java | 28 +- .../apache/sshd/common/mac/BuiltinMacsTest.java | 71 +- .../org/apache/sshd/common/mac/MacTest.java | 24 +- .../common/session/AbstractSessionTest.java | 10 + .../AbstractSignatureFactoryTestSupport.java | 11 +- .../common/signature/BuiltinSignaturesTest.java | 61 +- .../signature/SignatureDSSFactoryTest.java | 2 +- .../signature/SignatureECDSAFactoryTest.java | 5 +- .../signature/SignatureRSAFactoryTest.java | 2 +- .../sshd/common/util/CloseableUtilsTest.java | 146 +- .../sshd/common/util/GenericUtilsTest.java | 56 +- .../sshd/common/util/SecurityUtilsTest.java | 26 +- .../sshd/common/util/ThreadUtilsTest.java | 12 +- .../sshd/common/util/ValidateUtilsTest.java | 2 +- .../common/util/io/EmptyInputStreamTest.java | 18 +- .../common/util/io/LimitInputStreamTest.java | 24 +- .../deprecated/ClientUserAuthServiceOld.java | 9 +- .../apache/sshd/deprecated/UserAuthAgent.java | 3 +- .../deprecated/UserAuthKeyboardInteractive.java | 12 +- .../sshd/deprecated/UserAuthPassword.java | 3 +- .../sshd/deprecated/UserAuthPublicKey.java | 3 +- .../sshd/server/PasswordAuthenticatorTest.java | 18 +- .../sshd/server/PublickeyAuthenticatorTest.java | 20 +- .../java/org/apache/sshd/server/ServerMain.java | 1 + .../java/org/apache/sshd/server/ServerTest.java | 292 ++-- .../org/apache/sshd/server/SshServerMain.java | 1 + .../org/apache/sshd/server/SshServerTest.java | 20 +- .../sshd/server/channel/ChannelSessionTest.java | 2 +- .../server/command/ScpCommandFactoryTest.java | 50 +- .../config/keys/AuthorizedKeyEntryTest.java | 30 +- .../keys/AuthorizedKeysAuthenticatorTest.java | 28 +- .../DefaultAuthorizedKeysAuthenticatorTest.java | 12 +- .../server/config/keys/ServerIdentityTest.java | 16 +- .../jaas/JaasPasswordAuthenticatorTest.java | 14 +- .../PEMGeneratorHostKeyProviderTest.java | 14 +- .../SimpleGeneratorHostKeyProviderTest.java | 14 +- .../server/shell/InvertedShellWrapperTest.java | 10 +- .../sftp/SftpSubsystemFactoryTest.java | 2 - .../server/subsystem/sftp/SshFsMounter.java | 25 +- .../apache/sshd/spring/SpringConfigTest.java | 11 +- .../org/apache/sshd/util/BaseTestSupport.java | 104 +- .../sshd/util/BogusPasswordAuthenticator.java | 2 +- .../org/apache/sshd/util/EchoShellFactory.java | 2 +- .../java/org/apache/sshd/util/JSchLogger.java | 44 +- .../org/apache/sshd/util/SimpleUserInfo.java | 2 +- .../test/java/org/apache/sshd/util/Utils.java | 166 +- .../org/apache/sshd/spring/SpringConfigTest.xml | 9 +- .../apache/sshd/git/pack/GitPackCommand.java | 28 +- .../sshd/git/pgm/EmbeddedCommandRunner.java | 16 +- .../org/apache/sshd/git/pgm/GitPgmCommand.java | 30 +- .../git/transport/GitSshdSessionFactory.java | 13 +- 462 files changed, 10429 insertions(+), 9173 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index c310ec4..200a002 100644 --- a/pom.xml +++ b/pom.xml @@ -568,6 +568,308 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>2.15</version> + <executions> + <execution> + <id>verify-style</id> + <phase>process-classes</phase> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + <configuration> + <logViolationsToConsole>true</logViolationsToConsole> + <resourceExcludes>**/sshd-version.properties</resourceExcludes> + <checkstyleRules> + <module name="Checker"> + <!-- Checks whether files end with a new line. --> + <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile --> + <!-- + <module name="NewlineAtEndOfFile"/> + --> + + <!-- Checks that property files contain the same keys. --> + <!-- See http://checkstyle.sf.net/config_misc.html#Translation --> + <module name="Translation" /> + + <!--<module name="StrictDuplicateCode"/>--> + + <module name="TreeWalker"> + <!-- Enable FileContentsHolder to allow us to in turn turn on suppression comments --> + <module name="FileContentsHolder" /> + <!-- Checks for Javadoc comments. --> + <!-- See http://checkstyle.sf.net/config_javadoc.html --> + <!-- + <module name="PackageHtml"/> + <module name="JavadocMethod"/> + <module name="JavadocType"/> + <module name="JavadocVariable"/> + <module name="JavadocStyle"/> + --> + + + <!-- Checks for Naming Conventions. --> + <!-- See http://checkstyle.sf.net/config_naming.html --> + <module name="ConstantName" /> + <module name="LocalFinalVariableName" /> + <module name="LocalVariableName"> + <property name="format" value="^[a-z][a-zA-Z0-9_]*$"/> + </module> + <module name="MemberName"> + <property name="format" value="^[a-z][a-zA-Z0-9_]*$"/> + </module> + <module name="MethodName" /> + <module name="PackageName" /> + <module name="ParameterName"> + <property name="format" value="^[a-z][a-zA-Z0-9_]*$"/> + </module> + <module name="StaticVariableName" /> + <module name="TypeName" /> + + + <!-- Checks for imports --> + <!-- See http://checkstyle.sf.net/config_import.html --> + <module name="AvoidStarImport" /> + <module name="IllegalImport" /><!-- defaults to sun.* packages --> + <module name="RedundantImport" /> + <module name="UnusedImports" /> + <module name="ImportOrder"> + <property name="groups" + value="java,javax,org.w3c,org.xml,junit,antlr,com.,net,org,*" /> + <property name="ordered" value="true" /> + </module> + <!-- + <module name="ImportControl"> + <property name="file" value="etc/import-control.xml"/> + </module> + --> + + + <!-- Checks for Size Violations. --> + <!-- See http://checkstyle.sf.net/config_sizes.html --> + <module name="AnonInnerLength"> + <property name="max" value="40" /> + </module> + <module name="ExecutableStatementCount"> + <property name="max" value="100" /> + </module> + <module name="LineLength"> + <property name="max" value="180" /> + </module> + <module name="MethodLength"> + <property name="max" value="150" /> + <property name="countEmpty" value="false" /> + </module> + <!-- DISABLED + <module name="ParameterNumber"> + <property name="max" value="7" /> + </module> + --> + + <!-- Checks for whitespace --> + <!-- See http://checkstyle.sf.net/config_whitespace.html --> + <module name="EmptyForIteratorPad" /> + <module name="EmptyForInitializerPad" /> + <module name="MethodParamPad" /> + <module name="NoWhitespaceAfter"> + <property name="tokens" + value="ARRAY_INIT,BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS" /> + </module> + <module name="NoWhitespaceBefore" /> + <module name="OperatorWrap" /> + <module name="ParenPad" /> + <module name="TypecastParenPad" /> + <module name="WhitespaceAfter"> + <property name="tokens" value="COMMA, SEMI" /> + </module> + <module name="WhitespaceAround"> + <property name="tokens" + value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN,TYPE_EXTENSION_AND" /> + </module> + + <!-- Modifier Checks --> + <!-- See http://checkstyle.sf.net/config_modifiers.html --> + <module name="ModifierOrder" /> + <module name="RedundantModifier" /> + + + <!-- Checks for blocks. You know, those {}'s --> + <!-- See http://checkstyle.sf.net/config_blocks.html --> + <module name="AvoidNestedBlocks"> + <property name="allowInSwitchCase" value="true" /> + </module> + <module name="EmptyBlock"> + <property name="option" value="text" /> + </module> + <module name="LeftCurly" /> + <module name="NeedBraces" /> + <module name="RightCurly" /> + + + <!-- Checks for common coding problems --> + <!-- See http://checkstyle.sf.net/config_coding.html --> + <!--<module name="ArrayTrailingComma"/>--> + <!--<module name="AvoidInlineConditionals"/>--> + <module name="CovariantEquals" /> + <module name="EmptyStatement" /> + <module name="EqualsHashCode" /> + <!--<module name="FinalLocalVariable"/>--> + <!-- DISABLED + <module name="HiddenField"> + <property name="ignoreConstructorParameter" value="true" /> + <property name="ignoreSetter" value="true" /> + </module> + --> + <module name="IllegalInstantiation" /> + <!--<module name="IllegalToken"/>--> + <!--<module name="IllegalTokenText"/>--> + <module name="InnerAssignment" /> + <!--<module name="MagicNumber"/>--> + <module name="MissingSwitchDefault" /> + <!--module name="ModifiedControlVariable"/--> + <module name="SimplifyBooleanExpression" /> + <module name="SimplifyBooleanReturn" /> + <module name="StringLiteralEquality" /> + <module name="NestedIfDepth"> + <property name="max" value="3" /> + </module> + <module name="NestedTryDepth"> + <property name="max" value="3" /> + </module> + <module name="SuperClone" /> + <module name="SuperFinalize" /> + <!--<module name="IllegalCatch"/>--> + <module name="IllegalThrows"> + <property name="illegalClassNames" + value="java.lang.Error,java.lang.RuntimeException" /> + </module> + <!--<module name="RedundantThrows"/>--> + <module name="PackageDeclaration" /> + <module name="ReturnCount"> + <property name="max" value="15" /> + </module> + + <module name="IllegalType"> + <property name="format" value="^xxx$" /> + <property name="illegalClassNames" + value="java.util.GregorianCalendar, java.util.Hashtable, java.util.HashSet, java.util.HashMap, java.util.ArrayList, java.util.LinkedList, java.util.LinkedHashMap, java.util.LinkedHashSet, java.util.TreeSet, java.util.TreeMap" /> + </module> + <module name="DeclarationOrder" /> + <!--<module name="ParameterAssignment"/>--> + <module name="ExplicitInitialization" /> + <module name="DefaultComesLast" /> + <!--<module name="MissingCtor"/>--> + <module name="FallThrough" /> + <!--<module name="MultipleStringLiterals"/>--> + <module name="MultipleVariableDeclarations" /> + <!--<module name="RequireThis"/>--> + <module name="UnnecessaryParentheses" /> + + + + <!-- Checks for class design --> + <!-- See http://checkstyle.sf.net/config_design.html --> + <!--<module name="DesignForExtension"/>--> + <module name="FinalClass" /> + <module name="HideUtilityClassConstructor" /> + <module name="InterfaceIsType" /> + <!--<module name="MutableException"/>--> + <module name="ThrowsCount"> + <property name="max" value="5" /> + </module> + <module name="VisibilityModifier"> + <property name="protectedAllowed" value="true" /> + <property name="packageAllowed" value="true" /> + <!-- this is needed for the resource injection unit tests. It will removed + when private member inject is supported. + --> + <property name="publicMemberPattern" value="resource[12].*" /> + </module> + + + + <!-- Metrics checks. --> + <!-- See http://checkstyle.sf.net/config_metrics.html --> + <module name="BooleanExpressionComplexity"> + <property name="max" value="10" /> + </module> + <!--<module name="ClassDataAbstractionCoupling"/>--> + <!--<module name="ClassFanOutComplexity"/>--> + <!--<module name="CyclomaticComplexity"/>--> + <!--<module name="NPathComplexity"/>--> + <module name="JavaNCSS"> + <property name="methodMaximum" value="150" /> + <property name="classMaximum" value="2000" /> + </module> + + + <!-- Miscellaneous other checks. --> + <!-- See http://checkstyle.sf.net/config_misc.html --> + <!-- + <module name="ArrayTypeStyle"/> + <module name="FinalParameters"/> + --> + <!-- + <module name="GenericIllegalRegexp"> + <property name="format" value="\s+$"/> + <property name="message" value="Line has trailing spaces."/> + </module> + --> + <!-- DISABLED + <module name="TodoComment"> + <property name="format" value="TODO" /> + </module> + --> + + <module name="UpperEll" /> + + <!--Assert statement may have side effects:--> + <module name="DescendantToken"> + <property name="tokens" value="LITERAL_ASSERT" /> + <property name="limitedTokens" + value="ASSIGN,DEC,INC,POST_DEC,POST_INC,PLUS_ASSIGN,MINUS_ASSIGN,STAR_ASSIGN,DIV_ASSIGN,MOD_ASSIGN,BSR_ASSIGN,SR_ASSIGN,SL_ASSIGN,BAND_ASSIGN,BXOR_ASSIGN,BOR_ASSIGN" /> + <property name="maximumNumber" value="0" /> + </module> + + <!--<module name="UncommentedMain"/>--> + <!--module name="TrailingComment"/--> + <module name="Indentation"> + <property name="caseIndent" value="4" /> + <property name="lineWrappingIndentation" value="0"/> + </module> + <!--<module name="RequiredRegexp">--> + <module name="SuppressWarningsHolder" /> + </module> + <module name="SuppressionCommentFilter"> + <property name="offCommentFormat" value="CHECKSTYLE\:OFF"/> + <property name="onCommentFormat" value="CHECKSTYLE\:ON"/> + </module> + <module name="SuppressionCommentFilter"> + <property name="offCommentFormat" value="CHECKSTYLE.OFF\:([\w\|]+)"/> + <property name="onCommentFormat" value="CHECKSTYLE.ON\:([\w\|]+)"/> + <property name="checkFormat" value="$1"/> + </module> + <module name="SuppressWarningsFilter"/> + <!-- Header checks --> + <module name="Header"> + <property name="header" + value="/*\n * Licensed to the Apache Software Foundation (ASF) under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The ASF licenses this file\n * to you under the Apache License, Version 2.0 (the\n * &quot;License&quot;); you may not use this file except in compliance\n * with the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n" /> + </module> + <!-- <module name="RegexpHeader"/> --> + <module name="FileLength"> + <property name="max" value="3000" /> + </module> + <module name="FileTabCharacter"> + <property name="eachLine" value="true"/> + </module> + </module> + </checkstyleRules> + </configuration> + </plugin> </plugins> </build> http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/pom.xml ---------------------------------------------------------------------- diff --git a/sshd-core/pom.xml b/sshd-core/pom.xml index 9abaf96..78526c0 100644 --- a/sshd-core/pom.xml +++ b/sshd-core/pom.xml @@ -1,4 +1,5 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <!-- @@ -125,7 +126,8 @@ <redirectTestOutputToFile>true</redirectTestOutputToFile> <reportsDirectory>${project.build.directory}/surefire-reports-nio2</reportsDirectory> <systemProperties> - <org.apache.sshd.common.io.IoServiceFactory>org.apache.sshd.common.io.nio2.Nio2ServiceFactory</org.apache.sshd.common.io.IoServiceFactory> + <org.apache.sshd.common.io.IoServiceFactory>org.apache.sshd.common.io.nio2.Nio2ServiceFactory + </org.apache.sshd.common.io.IoServiceFactory> </systemProperties> <excludes> <exclude>**/*LoadTest.java</exclude> @@ -140,7 +142,9 @@ <configuration> <reportsDirectory>${project.build.directory}/surefire-reports-mina</reportsDirectory> <systemProperties> - <org.apache.sshd.common.io.IoServiceFactory>org.apache.sshd.common.io.mina.MinaServiceFactory</org.apache.sshd.common.io.IoServiceFactory> + <org.apache.sshd.common.io.IoServiceFactory> + org.apache.sshd.common.io.mina.MinaServiceFactory + </org.apache.sshd.common.io.IoServiceFactory> </systemProperties> </configuration> </execution> http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentFactory.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentFactory.java b/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentFactory.java index 33ff448..771d5e2 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentFactory.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentFactory.java @@ -34,6 +34,7 @@ public interface SshAgentFactory { * The channels are requested by the ssh server when forwarding a client request. * The channel will receive agent requests and need to forward them to the agent, * either local or through another proxy. + * * @return The channel factory used to create channels on the client side */ NamedFactory<Channel> getChannelForwardingFactory(); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentServer.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentServer.java b/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentServer.java index 256140b..c12350a 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentServer.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/SshAgentServer.java @@ -22,16 +22,19 @@ import java.nio.channels.Channel; import java.util.concurrent.TimeUnit; public interface SshAgentServer extends Channel { - /** - * @return Agent server identifier - */ - String getId(); - + /** * Value that can be set on the {@link org.apache.sshd.common.FactoryManager} * to configure the channel open timeout value (millis). If not specified * then {@link #DEFAULT_CHANNEL_OPEN_TIMEOUT} value is used */ String CHANNEL_OPEN_TIMEOUT_PROP = "ssh-agent-server-channel-open-timeout"; - long DEFAULT_CHANNEL_OPEN_TIMEOUT = TimeUnit.SECONDS.toMillis(30L); + + long DEFAULT_CHANNEL_OPEN_TIMEOUT = TimeUnit.SECONDS.toMillis(30L); + + /** + * @return Agent server identifier + */ + String getId(); + } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/agent/common/AbstractAgentClient.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/common/AbstractAgentClient.java b/sshd-core/src/main/java/org/apache/sshd/agent/common/AbstractAgentClient.java index 0730cf6..1f8234f 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/common/AbstractAgentClient.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/common/AbstractAgentClient.java @@ -18,16 +18,6 @@ */ package org.apache.sshd.agent.common; -import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_ADD_IDENTITY; -import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_REMOVE_ALL_IDENTITIES; -import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_REMOVE_IDENTITY; -import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_REQUEST_IDENTITIES; -import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_SIGN_REQUEST; -import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENT_FAILURE; -import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENT_IDENTITIES_ANSWER; -import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENT_SIGN_RESPONSE; -import static org.apache.sshd.agent.SshAgentConstants.SSH_AGENT_SUCCESS; - import java.io.IOException; import java.security.KeyPair; import java.security.PublicKey; @@ -42,6 +32,16 @@ import org.apache.sshd.common.util.buffer.BufferUtils; import org.apache.sshd.common.util.buffer.ByteArrayBuffer; import org.apache.sshd.common.util.logging.AbstractLoggingBean; +import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_ADD_IDENTITY; +import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_REMOVE_ALL_IDENTITIES; +import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_REMOVE_IDENTITY; +import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_REQUEST_IDENTITIES; +import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_SIGN_REQUEST; +import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENT_FAILURE; +import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENT_IDENTITIES_ANSWER; +import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENT_SIGN_RESPONSE; +import static org.apache.sshd.agent.SshAgentConstants.SSH_AGENT_SUCCESS; + public abstract class AbstractAgentClient extends AbstractLoggingBean { private final Buffer buffer = new ByteArrayBuffer(); @@ -81,14 +81,14 @@ public abstract class AbstractAgentClient extends AbstractLoggingBean { rep.rpos(rep.wpos()); Buffer req = new ByteArrayBuffer(buffer.getBytes()); - int cmd = (-1); + int cmd = -1; try { cmd = req.getUByte(); process(cmd, req, rep); } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("Failed ({}) to handle command={}: {}", - e.getClass().getSimpleName(), Integer.valueOf(cmd), e.getMessage()); + e.getClass().getSimpleName(), cmd, e.getMessage()); } rep.clear(); rep.putInt(0); @@ -104,49 +104,45 @@ public abstract class AbstractAgentClient extends AbstractLoggingBean { log.debug("process(cmd={})", Integer.valueOf(cmd)); } switch (cmd) { - case SSH2_AGENTC_REQUEST_IDENTITIES: { - List<Pair<PublicKey,String>> keys = agent.getIdentities(); - rep.putByte(SSH2_AGENT_IDENTITIES_ANSWER); - rep.putInt(keys.size()); - for (Pair<PublicKey,String> key : keys) { - rep.putPublicKey(key.getFirst()); - rep.putString(key.getSecond()); - } + case SSH2_AGENTC_REQUEST_IDENTITIES: + List<Pair<PublicKey, String>> keys = agent.getIdentities(); + rep.putByte(SSH2_AGENT_IDENTITIES_ANSWER); + rep.putInt(keys.size()); + for (Pair<PublicKey, String> key : keys) { + rep.putPublicKey(key.getFirst()); + rep.putString(key.getSecond()); } break; - case SSH2_AGENTC_SIGN_REQUEST: { - PublicKey key = req.getPublicKey(); - byte[] data = req.getBytes(); - int flags = req.getInt(); - if (log.isDebugEnabled()) { - log.debug("SSH2_AGENTC_SIGN_REQUEST key={}, flags=0x{}, data={}", - key.getAlgorithm(), Integer.toHexString(flags), BufferUtils.printHex(':', data)); - } - String keyType = ValidateUtils.checkNotNullAndNotEmpty( - KeyUtils.getKeyType(key), - "Cannot resolve key type of %s", - key.getClass().getSimpleName()); - Buffer sig = new ByteArrayBuffer(); - sig.putString(keyType); - sig.putBytes(agent.sign(key, data)); - rep.putByte(SSH2_AGENT_SIGN_RESPONSE); - rep.putBytes(sig.array(), sig.rpos(), sig.available()); + case SSH2_AGENTC_SIGN_REQUEST: + PublicKey signingKey = req.getPublicKey(); + byte[] data = req.getBytes(); + int flags = req.getInt(); + if (log.isDebugEnabled()) { + log.debug("SSH2_AGENTC_SIGN_REQUEST key={}, flags=0x{}, data={}", + signingKey.getAlgorithm(), Integer.toHexString(flags), BufferUtils.printHex(':', data)); } + String keyType = ValidateUtils.checkNotNullAndNotEmpty( + KeyUtils.getKeyType(signingKey), + "Cannot resolve key type of %s", + signingKey.getClass().getSimpleName()); + Buffer sig = new ByteArrayBuffer(); + sig.putString(keyType); + sig.putBytes(agent.sign(signingKey, data)); + rep.putByte(SSH2_AGENT_SIGN_RESPONSE); + rep.putBytes(sig.array(), sig.rpos(), sig.available()); break; - case SSH2_AGENTC_ADD_IDENTITY: { - KeyPair kp = req.getKeyPair(); - String comment = req.getString(); - log.debug("SSH2_AGENTC_ADD_IDENTITY comment={}", comment); - agent.addIdentity(kp, comment); - rep.putByte(SSH_AGENT_SUCCESS); - } + case SSH2_AGENTC_ADD_IDENTITY: + KeyPair keyToAdd = req.getKeyPair(); + String comment = req.getString(); + log.debug("SSH2_AGENTC_ADD_IDENTITY comment={}", comment); + agent.addIdentity(keyToAdd, comment); + rep.putByte(SSH_AGENT_SUCCESS); break; - case SSH2_AGENTC_REMOVE_IDENTITY: { - PublicKey key = req.getPublicKey(); - log.debug("SSH2_AGENTC_REMOVE_IDENTITY {}", key.getClass().getSimpleName()); - agent.removeIdentity(key); - rep.putByte(SSH_AGENT_SUCCESS); - } + case SSH2_AGENTC_REMOVE_IDENTITY: + PublicKey keyToRemove = req.getPublicKey(); + log.debug("SSH2_AGENTC_REMOVE_IDENTITY {}", keyToRemove.getClass().getSimpleName()); + agent.removeIdentity(keyToRemove); + rep.putByte(SSH_AGENT_SUCCESS); break; case SSH2_AGENTC_REMOVE_ALL_IDENTITIES: agent.removeAllIdentities(); @@ -156,13 +152,13 @@ public abstract class AbstractAgentClient extends AbstractLoggingBean { if (log.isDebugEnabled()) { log.debug("Unknown command: {}", Integer.valueOf(cmd)); } - rep.putByte(SSH2_AGENT_FAILURE); + break; } } protected Buffer prepare(Buffer buf) { - int len = buf.available(); + int len = buf.available(); int rpos = buf.rpos(); int wpos = buf.wpos(); buf.rpos(rpos - 4); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/agent/common/AbstractAgentProxy.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/common/AbstractAgentProxy.java b/sshd-core/src/main/java/org/apache/sshd/agent/common/AbstractAgentProxy.java index 227af6c..509d7bd 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/common/AbstractAgentProxy.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/common/AbstractAgentProxy.java @@ -18,15 +18,6 @@ */ package org.apache.sshd.agent.common; -import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_ADD_IDENTITY; -import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_REMOVE_ALL_IDENTITIES; -import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_REMOVE_IDENTITY; -import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_REQUEST_IDENTITIES; -import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_SIGN_REQUEST; -import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENT_IDENTITIES_ANSWER; -import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENT_SIGN_RESPONSE; -import static org.apache.sshd.agent.SshAgentConstants.SSH_AGENT_SUCCESS; - import java.io.IOException; import java.security.KeyPair; import java.security.PublicKey; @@ -45,6 +36,15 @@ import org.apache.sshd.common.util.buffer.ByteArrayBuffer; import org.apache.sshd.common.util.logging.AbstractLoggingBean; import org.apache.sshd.common.util.threads.ExecutorServiceConfigurer; +import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_ADD_IDENTITY; +import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_REMOVE_ALL_IDENTITIES; +import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_REMOVE_IDENTITY; +import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_REQUEST_IDENTITIES; +import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENTC_SIGN_REQUEST; +import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENT_IDENTITIES_ANSWER; +import static org.apache.sshd.agent.SshAgentConstants.SSH2_AGENT_SIGN_RESPONSE; +import static org.apache.sshd.agent.SshAgentConstants.SSH_AGENT_SUCCESS; + public abstract class AbstractAgentProxy extends AbstractLoggingBean implements SshAgent, ExecutorServiceConfigurer { private ExecutorService executor; private boolean shutdownExecutor; @@ -102,14 +102,14 @@ public abstract class AbstractAgentProxy extends AbstractLoggingBean implements buffer.putBytes(data); buffer.putInt(0); buffer = request(prepare(buffer)); - - int responseType = buffer.getUByte(); + + int responseType = buffer.getUByte(); if (responseType != SSH2_AGENT_SIGN_RESPONSE) { throw new SshException("Bad signing response type: " + (responseType & 0xFF)); } Buffer buf = new ByteArrayBuffer(buffer.getBytes()); String algorithm = buf.getString(); - byte[] signature = buf.getBytes(); + byte[] signature = buf.getBytes(); if (log.isDebugEnabled()) { log.debug("sign(" + algorithm + "): " + BufferUtils.printHex(':', signature)); } @@ -126,7 +126,7 @@ public abstract class AbstractAgentProxy extends AbstractLoggingBean implements log.debug("addIdentity(" + comment + "): " + key.getPublic().getAlgorithm()); } buffer = request(prepare(buffer)); - + int available = buffer.available(); int response = (available >= 1) ? buffer.getUByte() : -1; if ((available != 1) || (response != SSH_AGENT_SUCCESS)) { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/agent/common/AgentForwardSupport.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/common/AgentForwardSupport.java b/sshd-core/src/main/java/org/apache/sshd/agent/common/AgentForwardSupport.java index 8184498..9da1860 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/common/AgentForwardSupport.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/common/AgentForwardSupport.java @@ -65,8 +65,8 @@ public class AgentForwardSupport extends CloseableUtils.AbstractCloseable { protected void doCloseImmediately() { try { close(); - } catch(IOException e) { - throw new RuntimeException("Failed (" + e.getClass().getSimpleName() + ") to close agent: " + e.getMessage(), e); + } catch (IOException e) { + throw new RuntimeException("Failed (" + e.getClass().getSimpleName() + ") to close agent: " + e.getMessage(), e); } super.doCloseImmediately(); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentImpl.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentImpl.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentImpl.java index 3afa6ac..55211e4 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentImpl.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentImpl.java @@ -33,7 +33,6 @@ import org.apache.sshd.common.SshException; import org.apache.sshd.common.config.keys.KeyUtils; import org.apache.sshd.common.signature.BuiltinSignatures; import org.apache.sshd.common.signature.Signature; -import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.Pair; import org.apache.sshd.common.util.ValidateUtils; http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentServerProxy.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentServerProxy.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentServerProxy.java index 004ae81..2d21d7c 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentServerProxy.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentServerProxy.java @@ -26,7 +26,6 @@ import org.apache.sshd.agent.SshAgent; import org.apache.sshd.agent.SshAgentServer; import org.apache.sshd.common.FactoryManagerUtils; import org.apache.sshd.common.session.ConnectionService; -import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.logging.AbstractLoggingBean; @@ -49,7 +48,7 @@ public class AgentServerProxy extends AbstractLoggingBean implements SshAgentSer this.service.registerChannel(channel); channel.open().verify(FactoryManagerUtils.getLongProperty(this.service.getSession(), CHANNEL_OPEN_TIMEOUT_PROP, DEFAULT_CHANNEL_OPEN_TIMEOUT)); return channel.getAgent(); - } catch(Throwable t) { + } catch (Throwable t) { if (log.isDebugEnabled()) { log.debug("createClient(" + service.getSession() + ")[" + getId() + ")" + " failed (" + t.getClass().getSimpleName() + ")" @@ -59,7 +58,7 @@ public class AgentServerProxy extends AbstractLoggingBean implements SshAgentSer if (t instanceof IOException) { throw (IOException) t; } - + throw (IOException) new IOException("Failed (" + t.getClass().getSimpleName() + ") to create client: " + t.getMessage()).initCause(t); } } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentClient.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentClient.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentClient.java index cd192be..830eb19 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentClient.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentClient.java @@ -55,7 +55,7 @@ public class AgentClient extends AbstractAgentProxy implements Runnable { public AgentClient(String authSocket, ExecutorService executor, boolean shutdownOnExit) throws IOException { this.authSocket = authSocket; - + setExecutorService((executor == null) ? ThreadUtils.newSingleThreadExecutor("AgentClient[" + authSocket + "]") : executor); setShutdownOnExit((executor == null) ? true : shutdownOnExit); @@ -68,7 +68,7 @@ public class AgentClient extends AbstractAgentProxy implements Runnable { } receiveBuffer = new ByteArrayBuffer(); messages = new ArrayBlockingQueue<Buffer>(10); - + ExecutorService service = getExecutorService(); pumper = service.submit(this); } catch (IOException e) { @@ -101,7 +101,7 @@ public class AgentClient extends AbstractAgentProxy implements Runnable { } finally { try { close(); - } catch(IOException e) { + } catch (IOException e) { if (log.isDebugEnabled()) { log.debug(e.getClass().getSimpleName() + " while closing: " + e.getMessage()); } @@ -136,7 +136,7 @@ public class AgentClient extends AbstractAgentProxy implements Runnable { if (open.getAndSet(false)) { Socket.close(handle); } - + if ((pumper != null) && isShutdownOnExit() && (!pumper.isDone())) { pumper.cancel(true); } @@ -168,13 +168,14 @@ public class AgentClient extends AbstractAgentProxy implements Runnable { /** * transform an APR error number in a more fancy exception + * * @param code APR error code * @throws java.io.IOException the produced exception for the given APR error number */ private void throwException(int code) throws IOException { throw new IOException( - org.apache.tomcat.jni.Error.strerror(-code) + - " (code: " + code + ")"); + org.apache.tomcat.jni.Error.strerror(-code) + + " (code: " + code + ")"); } } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServer.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServer.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServer.java index ca9ecdc..33e2933 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServer.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServer.java @@ -63,7 +63,7 @@ public class AgentServer extends AbstractLoggingBean implements Closeable, Execu public AgentServer(SshAgent agent, ExecutorService executor, boolean shutdownOnExit) { this.agent = agent; this.service = (executor == null) ? ThreadUtils.newSingleThreadExecutor("AgentServer[" + agent + "]") : executor; - this.shutdownExecutor = (service == executor) ? shutdownOnExit : true; + this.shutdownExecutor = (service == executor) ? shutdownOnExit : true; } public SshAgent getAgent() { @@ -93,23 +93,23 @@ public class AgentServer extends AbstractLoggingBean implements Closeable, Execu if (result != Status.APR_SUCCESS) { throwException(result); } - + ExecutorService executor = getExecutorService(); agentThread = executor.submit(new Runnable() { - @SuppressWarnings("synthetic-access") - @Override - public void run() { - try { - while (true) { - long clientSock = Local.accept(handle); - Socket.timeoutSet(clientSock, 10000000); // TODO make this configurable - new SshAgentSession(clientSock, agent).run(); - } - } catch (Exception e) { - log.error("Failed to run session", e); + @SuppressWarnings("synthetic-access") + @Override + public void run() { + try { + while (true) { + long clientSock = Local.accept(handle); + Socket.timeoutSet(clientSock, 10000000); // TODO make this configurable + new SshAgentSession(clientSock, agent).run(); } + } catch (Exception e) { + log.error("Failed to run session", e); } - }); + } + }); return authSocket; } @@ -118,12 +118,12 @@ public class AgentServer extends AbstractLoggingBean implements Closeable, Execu IOException err = null; try { agent.close(); - } catch(IOException e) { + } catch (IOException e) { err = e; } Socket.close(handle); - + try { if ((agentThread != null) && (!agentThread.isDone())) { agentThread.cancel(true); @@ -131,7 +131,7 @@ public class AgentServer extends AbstractLoggingBean implements Closeable, Execu } finally { agentThread = null; } - + ExecutorService executor = getExecutorService(); if ((executor != null) && isShutdownOnExit() && (!executor.isShutdown())) { Collection<?> runners = executor.shutdownNow(); @@ -139,7 +139,7 @@ public class AgentServer extends AbstractLoggingBean implements Closeable, Execu log.debug("Shut down runners count=" + GenericUtils.size(runners)); } } - + if (err != null) { throw err; } @@ -162,7 +162,7 @@ public class AgentServer extends AbstractLoggingBean implements Closeable, Execu while (true) { int result = Socket.recv(socket, buf, 0, buf.length); if (result == -Status.APR_EOF) { - break; + break; } else if (result < Status.APR_SUCCESS) { throwException(result); } @@ -188,13 +188,14 @@ public class AgentServer extends AbstractLoggingBean implements Closeable, Execu /** * transform an APR error number in a more fancy exception + * * @param code APR error code * @throws java.io.IOException the produced exception for the given APR error number */ private static void throwException(int code) throws IOException { throw new IOException( - org.apache.tomcat.jni.Error.strerror(-code) + - " (code: " + code + ")"); + org.apache.tomcat.jni.Error.strerror(-code) + + " (code: " + code + ")"); } } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServerProxy.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServerProxy.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServerProxy.java index a7a8fe6..fbe4c0c 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServerProxy.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServerProxy.java @@ -51,7 +51,10 @@ public class AgentServerProxy extends AbstractLoggingBean implements SshAgentSer * {@link #DEFAULT_AUTH_SOCKET_TIMEOUT} is used */ public static final String AUTH_SOCKET_TIMEOUT = "ssh-agent-server-proxy-auth-socket-timeout"; - public static final int DEFAULT_AUTH_SOCKET_TIMEOUT = 10000000; + public static final int DEFAULT_AUTH_SOCKET_TIMEOUT = 10000000; + + //used to wake the Local.listen() JNI call + private static final byte[] END_OF_STREAM_MESSAGE = new byte[]{"END_OF_STREAM".getBytes(StandardCharsets.UTF_8)[0]}; private final ConnectionService service; private final String authSocket; @@ -63,9 +66,6 @@ public class AgentServerProxy extends AbstractLoggingBean implements SshAgentSer private final AtomicBoolean open = new AtomicBoolean(true); private final AtomicBoolean innerFinished = new AtomicBoolean(false); - //used to wake the Local.listen() JNI call - private static final byte[] END_OF_STREAM_MESSAGE = new byte[] { "END_OF_STREAM".getBytes(StandardCharsets.UTF_8)[0] }; - public AgentServerProxy(ConnectionService service) throws IOException { this(service, null, false); } @@ -89,37 +89,37 @@ public class AgentServerProxy extends AbstractLoggingBean implements SshAgentSer if (result != Status.APR_SUCCESS) { throwException(result); } - + pipeService = (executor == null) ? ThreadUtils.newSingleThreadExecutor("sshd-AgentServerProxy-PIPE-" + authSocket) : executor; pipeCloseOnExit = (executor == pipeService) ? shutdownOnExit : true; piper = pipeService.submit(new Runnable() { - @SuppressWarnings("synthetic-access") - @Override - public void run() { - try { - while (isOpen()) { - try { - long clientSock = Local.accept(handle); - if (!isOpen()) { - break; - } - - Session session = AgentServerProxy.this.service.getSession(); - Socket.timeoutSet(clientSock, FactoryManagerUtils.getIntProperty(session, AUTH_SOCKET_TIMEOUT, DEFAULT_AUTH_SOCKET_TIMEOUT)); - AgentForwardedChannel channel = new AgentForwardedChannel(clientSock); - AgentServerProxy.this.service.registerChannel(channel); - channel.open().verify(FactoryManagerUtils.getLongProperty(session, CHANNEL_OPEN_TIMEOUT_PROP, DEFAULT_CHANNEL_OPEN_TIMEOUT)); - } catch (Exception e) { - if (isOpen()) { - log.info(e.getClass().getSimpleName() + " while authentication forwarding: " + e.getMessage(), e); - } + @SuppressWarnings("synthetic-access") + @Override + public void run() { + try { + while (isOpen()) { + try { + long clientSock = Local.accept(handle); + if (!isOpen()) { + break; + } + + Session session = AgentServerProxy.this.service.getSession(); + Socket.timeoutSet(clientSock, FactoryManagerUtils.getIntProperty(session, AUTH_SOCKET_TIMEOUT, DEFAULT_AUTH_SOCKET_TIMEOUT)); + AgentForwardedChannel channel = new AgentForwardedChannel(clientSock); + AgentServerProxy.this.service.registerChannel(channel); + channel.open().verify(FactoryManagerUtils.getLongProperty(session, CHANNEL_OPEN_TIMEOUT_PROP, DEFAULT_CHANNEL_OPEN_TIMEOUT)); + } catch (Exception e) { + if (isOpen()) { + log.info(e.getClass().getSimpleName() + " while authentication forwarding: " + e.getMessage(), e); } } - } finally { - innerFinished.set(true); } + } finally { + innerFinished.set(true); } - }); + } + }); } catch (IOException e) { throw e; } catch (Exception e) { @@ -194,19 +194,10 @@ public class AgentServerProxy extends AbstractLoggingBean implements SshAgentSer if (authSocket != null) { final File socketFile = new File(authSocket); if (socketFile.exists()) { - if (socketFile.delete()) { - if (isDebug) { - log.debug("Deleted PIPE socket {}", socketFile); - } - } + deleteFile(socketFile, "Deleted PIPE socket {}"); if (OsUtils.isUNIX()) { - final File parentFile = socketFile.getParentFile(); - if (parentFile.delete()) { - if (isDebug) { - log.debug("Deleted parent PIPE socket {}", parentFile); - } - } + deleteFile(socketFile.getParentFile(), "Deleted parent PIPE socket {}"); } } } @@ -216,7 +207,7 @@ public class AgentServerProxy extends AbstractLoggingBean implements SshAgentSer log.debug("Exception deleting the PIPE socket: " + authSocket, e); } } - + try { if ((piper != null) && (!piper.isDone())) { piper.cancel(true); @@ -224,18 +215,27 @@ public class AgentServerProxy extends AbstractLoggingBean implements SshAgentSer } finally { piper = null; } - + ExecutorService executor = getExecutorService(); if ((executor != null) && isShutdownOnExit() && (!executor.isShutdown())) { - Collection<?> runners = executor.shutdownNow(); + Collection<?> runners = executor.shutdownNow(); if (log.isDebugEnabled()) { log.debug("Shut down runners count=" + GenericUtils.size(runners)); } } } + private void deleteFile(File file, String msg) { + if (file.delete()) { + if (log.isDebugEnabled()) { + log.debug(msg, file); + } + } + } + /** * transform an APR error number in a more fancy exception + * * @param code APR error code * @throws java.io.IOException the produced exception for the given APR error number */ http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/agent/unix/AprLibrary.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AprLibrary.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AprLibrary.java index 823c404..8e78735 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AprLibrary.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AprLibrary.java @@ -1,21 +1,20 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * http://www.apache.org/licenses/LICENSE-2.0 * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ package org.apache.sshd.agent.unix; @@ -30,26 +29,46 @@ import org.apache.tomcat.jni.Pool; /** * Internal singleton used for initializing correctly the APR native library * and the associated root memory pool. - * + * <p/> * It'll finalize nicely the native resources (libraries and memory pools). - * + * <p/> * Each memory pool used in the APR transport module needs to be children of the * root pool {@link AprLibrary#getRootPool()}. * * @author <a href="http://mina.apache.org">Apache MINA Project</a> */ -class AprLibrary { +final class AprLibrary { // is APR library was initialized (load of native libraries) - private static AprLibrary library = null; + private static AprLibrary library; + + // APR memory pool (package wide mother pool) + private final long pool; + + /** + * APR library singleton constructor. Called only when accessing the + * singleton the first time. + * It's initializing an APR memory pool for the whole package (a.k.a mother or root pool). + */ + private AprLibrary() { + try { + Library.initialize(null); + } catch (Exception e) { + throw new RuntimeException( + "Error loading Apache Portable Runtime (APR).", e); + } + pool = Pool.create(0); + } /** * get the shared instance of APR library, if none, initialize one + * * @return the current APR library singleton */ static synchronized AprLibrary getInstance() { - if (!isInitialized()) + if (!isInitialized()) { initialize(); + } return library; } @@ -58,36 +77,20 @@ class AprLibrary { * and creating the associated singleton */ private static synchronized void initialize() { - if (library == null) + if (library == null) { library = new AprLibrary(); + } } /** * is the APR library was initialized. + * * @return true if the Library is initialized, false otherwise */ static synchronized boolean isInitialized() { return library != null; } - // APR memory pool (package wide mother pool) - private final long pool; - - /** - * APR library singleton constructor. Called only when accessing the - * singleton the first time. - * It's initializing an APR memory pool for the whole package (a.k.a mother or root pool). - */ - private AprLibrary() { - try { - Library.initialize(null); - } catch (Exception e) { - throw new RuntimeException( - "Error loading Apache Portable Runtime (APR).", e); - } - pool = Pool.create(0); - } - @Override protected void finalize() throws Throwable { library = null; @@ -99,6 +102,7 @@ class AprLibrary { /** * get the package wide root pool, the mother of all the pool created * in APR transport module. + * * @return number identifying the root pool */ long getRootPool() { @@ -121,7 +125,7 @@ class AprLibrary { } chmodOwner(dir.getAbsolutePath(), true); - File socket = File.createTempFile("mina","apr", dir); + File socket = File.createTempFile("mina", "apr", dir); socket.delete(); name = socket.getAbsolutePath(); } else { @@ -143,7 +147,7 @@ class AprLibrary { private static void chmodOwner(String authSocket, boolean execute) throws IOException { int perms = org.apache.tomcat.jni.File.APR_FPROT_UREAD - | org.apache.tomcat.jni.File.APR_FPROT_UWRITE; + | org.apache.tomcat.jni.File.APR_FPROT_UWRITE; if (execute) { perms |= org.apache.tomcat.jni.File.APR_FPROT_UEXECUTE; }
