| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import com.gitblit.git.GitblitReceivePackFactory; |
| | | import com.gitblit.git.GitblitUploadPackFactory; |
| | | import com.gitblit.git.RepositoryResolver; |
| | | import com.gitblit.manager.IGitblit; |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.transport.ssh.commands.AddKeyCommand; |
| | | import com.gitblit.transport.ssh.commands.CreateRepository; |
| | | import com.gitblit.transport.ssh.commands.DispatchCommand; |
| | | import com.gitblit.transport.ssh.commands.Receive; |
| | | import com.gitblit.transport.ssh.commands.RemoveKeyCommand; |
| | | import com.gitblit.transport.ssh.commands.ReviewCommand; |
| | | import com.gitblit.transport.ssh.commands.SetAccountCommand; |
| | | import com.gitblit.transport.ssh.commands.Upload; |
| | | import com.gitblit.transport.ssh.commands.VersionCommand; |
| | | import com.gitblit.transport.ssh.git.GitDispatchCommand; |
| | | import com.gitblit.transport.ssh.gitblit.GitblitDispatchCommand; |
| | | import com.gitblit.utils.IdGenerator; |
| | | import com.gitblit.utils.WorkQueue; |
| | | import com.google.common.util.concurrent.Atomics; |
| | |
| | | private static final Logger logger = LoggerFactory.getLogger(SshCommandFactory.class); |
| | | |
| | | private final IGitblit gitblit; |
| | | private final PublicKeyAuthenticator keyAuthenticator; |
| | | private final ScheduledExecutorService startExecutor; |
| | | |
| | | public SshCommandFactory(IGitblit gitblit, PublicKeyAuthenticator keyAuthenticator, IdGenerator idGenerator) { |
| | | public SshCommandFactory(IGitblit gitblit, IdGenerator idGenerator) { |
| | | this.gitblit = gitblit; |
| | | this.keyAuthenticator = keyAuthenticator; |
| | | |
| | | int threads = 2;// cfg.getInt("sshd","commandStartThreads", 2); |
| | | WorkQueue workQueue = new WorkQueue(idGenerator); |
| | |
| | | protected DispatchCommand createRootDispatcher(SshDaemonClient client, String cmdLine) { |
| | | final UserModel user = client.getUser(); |
| | | |
| | | DispatchCommand gitblitCmd = new DispatchCommand(); |
| | | gitblitCmd.registerCommand(user, VersionCommand.class); |
| | | gitblitCmd.registerCommand(user, AddKeyCommand.class); |
| | | gitblitCmd.registerCommand(user, RemoveKeyCommand.class); |
| | | gitblitCmd.registerCommand(user, ReviewCommand.class); |
| | | DispatchCommand root = new DispatchCommand() { |
| | | }; |
| | | root.setContext(new SshCommandContext(gitblit, client, cmdLine)); |
| | | |
| | | gitblitCmd.registerCommand(user, CreateRepository.class); |
| | | gitblitCmd.registerCommand(user, SetAccountCommand.class); |
| | | |
| | | DispatchCommand gitCmd = new DispatchCommand(); |
| | | gitCmd.registerCommand(user, Upload.class); |
| | | gitCmd.registerCommand(user, Receive.class); |
| | | |
| | | DispatchCommand root = new DispatchCommand(); |
| | | root.registerDispatcher("gitblit", gitblitCmd); |
| | | root.registerDispatcher("git", gitCmd); |
| | | |
| | | root.setRepositoryResolver(new RepositoryResolver<SshDaemonClient>(gitblit)); |
| | | root.setUploadPackFactory(new GitblitUploadPackFactory<SshDaemonClient>(gitblit)); |
| | | root.setReceivePackFactory(new GitblitReceivePackFactory<SshDaemonClient>(gitblit)); |
| | | root.setAuthenticator(keyAuthenticator); |
| | | |
| | | root.setContext(new SshCommandContext(client, cmdLine)); |
| | | // TODO convert these dispatchers to plugin extension points |
| | | root.registerDispatcher(user, GitblitDispatchCommand.class); |
| | | root.registerDispatcher(user, GitDispatchCommand.class); |
| | | |
| | | return root; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | @SuppressWarnings("unused") |
| | | private void onDestroy() { |
| | | synchronized (this) { |
| | | if (cmd != null) { |