From 997c16d6826cfa1bef33ba08e15055cc407b9398 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Tue, 13 Dec 2011 17:36:58 -0500 Subject: [PATCH] Federation support for Teams --- src/com/gitblit/FederationServlet.java | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) diff --git a/src/com/gitblit/FederationServlet.java b/src/com/gitblit/FederationServlet.java index 0be1066..f2ed903 100644 --- a/src/com/gitblit/FederationServlet.java +++ b/src/com/gitblit/FederationServlet.java @@ -27,6 +27,7 @@ import com.gitblit.Constants.FederationRequest; import com.gitblit.models.FederationModel; import com.gitblit.models.FederationProposal; +import com.gitblit.models.TeamModel; import com.gitblit.models.UserModel; import com.gitblit.utils.FederationUtils; import com.gitblit.utils.HttpUtils; @@ -90,7 +91,7 @@ if (proposal == null) { return; } - + // reject proposal, if not receipt prohibited if (!GitBlit.getBoolean(Keys.federation.allowProposals, false)) { logger.error(MessageFormat.format("Rejected {0} federation proposal from {1}", @@ -198,6 +199,23 @@ } } result = users; + } else if (FederationRequest.PULL_TEAMS.equals(reqType)) { + // pull teams + if (!GitBlit.self().validateFederationRequest(reqType, token)) { + // invalid token to pull teams + logger.warn(MessageFormat.format( + "Federation token from {0} not authorized to pull TEAMS", + request.getRemoteAddr())); + response.sendError(HttpServletResponse.SC_FORBIDDEN); + return; + } + List<String> teamnames = GitBlit.self().getAllTeamnames(); + List<TeamModel> teams = new ArrayList<TeamModel>(); + for (String teamname : teamnames) { + TeamModel user = GitBlit.self().getTeamModel(teamname); + teams.add(user); + } + result = teams; } } -- Gitblit v1.9.1