| | |
| | | import com.gitblit.models.RepositoryModel; |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.transport.git.GitDaemonClient; |
| | | import com.gitblit.transport.ssh.SshSession; |
| | | import com.gitblit.transport.ssh.SshDaemonClient; |
| | | |
| | | /** |
| | | * Resolves repositories and grants export access. |
| | |
| | | // git request |
| | | GitDaemonClient client = (GitDaemonClient) req; |
| | | client.setRepositoryName(name); |
| | | } else if (req instanceof SshSession) { |
| | | SshSession s = (SshSession)req; |
| | | s.setRepositoryName(name); |
| | | } else if (req instanceof SshDaemonClient) { |
| | | SshDaemonClient client = (SshDaemonClient) req; |
| | | client.setRepositoryName(name); |
| | | } |
| | | return repo; |
| | | } |
| | |
| | | user = UserModel.ANONYMOUS; |
| | | } else if (req instanceof HttpServletRequest) { |
| | | // http/https request |
| | | HttpServletRequest httpRequest = (HttpServletRequest) req; |
| | | scheme = httpRequest.getScheme(); |
| | | origin = httpRequest.getRemoteAddr(); |
| | | user = gitblit.authenticate(httpRequest); |
| | | HttpServletRequest client = (HttpServletRequest) req; |
| | | scheme = client.getScheme(); |
| | | origin = client.getRemoteAddr(); |
| | | user = gitblit.authenticate(client); |
| | | if (user == null) { |
| | | user = UserModel.ANONYMOUS; |
| | | } |
| | | } else if (req instanceof SshSession) { |
| | | } else if (req instanceof SshDaemonClient) { |
| | | // ssh is always authenticated |
| | | SshSession s = (SshSession) req; |
| | | user = gitblit.getUserModel(s.getRemoteUser()); |
| | | SshDaemonClient client = (SshDaemonClient) req; |
| | | user = client.getUser(); |
| | | } |
| | | |
| | | if (user.canClone(model)) { |