| | |
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import com.gitblit.AuthenticationFilter.AuthenticatedRequest;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.utils.StringUtils;
|
| | |
| | | * @return action of the request
|
| | | */
|
| | | protected abstract String getUrlRequestAction(String url);
|
| | |
|
| | | /**
|
| | | * Determine if the action may be executed on the repository.
|
| | | * |
| | | * @param repository
|
| | | * @param action
|
| | | * @return true if the action may be performed
|
| | | */
|
| | | protected abstract boolean isActionAllowed(RepositoryModel repository, String action);
|
| | |
|
| | | /**
|
| | | * Determine if the repository requires authentication.
|
| | |
| | | httpResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
|
| | | return;
|
| | | }
|
| | | |
| | | // Confirm that the action may be executed on the repository
|
| | | if (!isActionAllowed(model, urlRequestType)) {
|
| | | logger.info(MessageFormat.format("ARF: action {0} on {1} forbidden ({2})",
|
| | | urlRequestType, model, HttpServletResponse.SC_FORBIDDEN));
|
| | | httpResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
|
| | | return;
|
| | | }
|
| | |
|
| | | // Wrap the HttpServletRequest with the AccessRestrictionRequest which
|
| | | // overrides the servlet container user principal methods.
|