| | |
| | | import com.gitblit.Keys; |
| | | import com.gitblit.manager.IGitblit; |
| | | import com.gitblit.transport.ssh.commands.SshCommandFactory; |
| | | import com.gitblit.utils.IdGenerator; |
| | | import com.gitblit.utils.JnaUtils; |
| | | import com.gitblit.utils.StringUtils; |
| | | import com.gitblit.utils.WorkQueue; |
| | | import com.google.common.io.Files; |
| | | |
| | | /** |
| | |
| | | * Construct the Gitblit SSH daemon. |
| | | * |
| | | * @param gitblit |
| | | * @param workQueue |
| | | */ |
| | | public SshDaemon(IGitblit gitblit, IdGenerator idGenerator) { |
| | | public SshDaemon(IGitblit gitblit, WorkQueue workQueue) { |
| | | this.gitblit = gitblit; |
| | | |
| | | IStoredSettings settings = gitblit.getSettings(); |
| | |
| | | sshd.setSessionFactory(new SshServerSessionFactory()); |
| | | sshd.setFileSystemFactory(new DisabledFilesystemFactory()); |
| | | sshd.setTcpipForwardingFilter(new NonForwardingFilter()); |
| | | sshd.setCommandFactory(new SshCommandFactory(gitblit, idGenerator)); |
| | | sshd.setCommandFactory(new SshCommandFactory(gitblit, workQueue)); |
| | | sshd.setShellFactory(new WelcomeShell(settings)); |
| | | |
| | | // Set the server id. This can be queried with: |
| | |
| | | public String formatUrl(String gituser, String servername, String repository) { |
| | | if (sshd.getPort() == DEFAULT_PORT) { |
| | | // standard port |
| | | return MessageFormat.format("{0}@{1}/{2}", gituser, servername, |
| | | return MessageFormat.format("ssh://{0}@{1}/{2}", gituser, servername, |
| | | repository); |
| | | } else { |
| | | // non-standard port |
| | |
| | | Files.touch(file); |
| | | try { |
| | | JnaUtils.setFilemode(file, JnaUtils.S_IRUSR | JnaUtils.S_IWUSR); |
| | | } catch (UnsupportedOperationException e) { |
| | | // Windows |
| | | } catch (UnsatisfiedLinkError | UnsupportedOperationException e) { |
| | | // Unexpected/Unsupported OS or Architecture |
| | | } |
| | | |
| | | FileOutputStream os = new FileOutputStream(file); |