| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import com.gitblit.GitBlit; |
| | | import com.gitblit.IStoredSettings; |
| | | import com.gitblit.Keys; |
| | | import com.gitblit.manager.IGitblit; |
| | | import com.gitblit.models.RepositoryModel; |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.utils.HttpUtils; |
| | |
| | | public class GitblitReceivePackFactory<X> implements ReceivePackFactory<X> { |
| | | |
| | | protected final Logger logger = LoggerFactory.getLogger(GitblitReceivePackFactory.class); |
| | | |
| | | private final IStoredSettings settings; |
| | | |
| | | private final IGitblit gitblit; |
| | | |
| | | public GitblitReceivePackFactory(IGitblit gitblit) { |
| | | super(); |
| | | this.settings = gitblit.getSettings(); |
| | | this.gitblit = gitblit; |
| | | } |
| | | |
| | | @Override |
| | | public ReceivePack create(X req, Repository db) |
| | |
| | | // determine pushing user |
| | | String username = request.getRemoteUser(); |
| | | if (!StringUtils.isEmpty(username)) { |
| | | UserModel u = GitBlit.self().getUserModel(username); |
| | | UserModel u = gitblit.getUserModel(username); |
| | | if (u != null) { |
| | | user = u; |
| | | } |
| | |
| | | timeout = client.getDaemon().getTimeout(); |
| | | } |
| | | |
| | | boolean allowAnonymousPushes = GitBlit.getBoolean(Keys.git.allowAnonymousPushes, false); |
| | | boolean allowAnonymousPushes = settings.getBoolean(Keys.git.allowAnonymousPushes, false); |
| | | if (!allowAnonymousPushes && UserModel.ANONYMOUS.equals(user)) { |
| | | // prohibit anonymous pushes |
| | | throw new ServiceNotEnabledException(); |
| | | } |
| | | |
| | | final RepositoryModel repository = GitBlit.self().getRepositoryModel(repositoryName); |
| | | final RepositoryModel repository = gitblit.getRepositoryModel(repositoryName); |
| | | |
| | | final GitblitReceivePack rp = new GitblitReceivePack(db, repository, user); |
| | | final GitblitReceivePack rp = new GitblitReceivePack(gitblit, db, repository, user); |
| | | rp.setGitblitUrl(gitblitUrl); |
| | | rp.setRepositoryUrl(repositoryUrl); |
| | | rp.setRefLogIdent(new PersonIdent(user.username, user.username + "@" + origin)); |