| | |
| | |
|
| | | import org.apache.wicket.PageParameters;
|
| | | import org.apache.wicket.markup.html.form.PasswordTextField;
|
| | | import org.apache.wicket.markup.html.form.StatelessForm;
|
| | | import org.apache.wicket.markup.html.form.TextField;
|
| | | import org.apache.wicket.model.IModel;
|
| | | import org.apache.wicket.model.Model;
|
| | |
| | | import com.gitblit.wicket.GitBlitWebSession;
|
| | | import com.gitblit.wicket.PageRegistration;
|
| | | import com.gitblit.wicket.PageRegistration.DropDownMenuItem;
|
| | | import com.gitblit.wicket.SessionlessForm;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | | import com.gitblit.wicket.panels.NavigationPanel;
|
| | |
|
| | |
| | | pages.add(new PageRegistration("gb.repositories", RepositoriesPage.class,
|
| | | getRootPageParameters()));
|
| | | pages.add(new PageRegistration("gb.activity", ActivityPage.class, getRootPageParameters()));
|
| | | if (GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true)) {
|
| | | pages.add(new PageRegistration("gb.search", LuceneSearchPage.class));
|
| | | }
|
| | | if (showAdmin) {
|
| | | pages.add(new PageRegistration("gb.users", UsersPage.class));
|
| | | }
|
| | |
| | | add(navPanel);
|
| | |
|
| | | // login form
|
| | | StatelessForm<Void> loginForm = new StatelessForm<Void>("loginForm") {
|
| | | SessionlessForm<Void> loginForm = new SessionlessForm<Void>("loginForm", getClass(), getPageParameters()) {
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | |
| | |
|
| | | UserModel user = GitBlit.self().authenticate(username, password);
|
| | | if (user == null) {
|
| | | error("Invalid username or password!");
|
| | | error(getString("gb.invalidUsernameOrPassword"));
|
| | | } else if (user.username.equals(Constants.FEDERATION_USER)) {
|
| | | // disallow the federation user from logging in via the
|
| | | // web ui
|
| | | error("Invalid username or password!");
|
| | | error(getString("gb.invalidUsernameOrPassword"));
|
| | | user = null;
|
| | | } else {
|
| | | loginUser(user);
|
| | |
| | | } else if (showAdmin) {
|
| | | int pendingProposals = GitBlit.self().getPendingFederationProposals().size();
|
| | | if (pendingProposals == 1) {
|
| | | info("There is 1 federation proposal awaiting review.");
|
| | | info(getString("gb.OneProposalToReview"));
|
| | | } else if (pendingProposals > 1) {
|
| | | info(MessageFormat.format("There are {0} federation proposals awaiting review.",
|
| | | info(MessageFormat.format(getString("gb.nFederationProposalsToReview"),
|
| | | pendingProposals));
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | private PageParameters getRootPageParameters() {
|
| | | if (reusePageParameters()) {
|
| | | PageParameters params = getPageParameters();
|
| | | if (params != null) {
|
| | | PageParameters pp = getPageParameters();
|
| | | if (pp != null) {
|
| | | PageParameters params = new PageParameters(pp);
|
| | | // remove named repository parameter
|
| | | params.remove("r");
|
| | | }
|
| | | return params;
|
| | |
|
| | | // remove days back parameter if it is the default value
|
| | | if (params.containsKey("db")
|
| | | && params.getInt("db") == GitBlit.getInteger(Keys.web.activityDuration, 14)) {
|
| | | params.remove("db");
|
| | | }
|
| | | return params;
|
| | | } |
| | | }
|
| | | return null;
|
| | | }
|
| | |
| | | private void loginUser(UserModel user) {
|
| | | if (user != null) {
|
| | | // Set the user into the session
|
| | | GitBlitWebSession.get().setUser(user);
|
| | | GitBlitWebSession session = GitBlitWebSession.get();
|
| | | // issue 62: fix session fixation vulnerability
|
| | | session.replaceSession();
|
| | | session.setUser(user);
|
| | |
|
| | | // Set Cookie
|
| | | if (GitBlit.getBoolean(Keys.web.allowCookieAuthentication, false)) {
|
| | |
| | | }
|
| | |
|
| | | if (!continueToOriginalDestination()) {
|
| | | // Redirect to home page
|
| | | setResponsePage(getApplication().getHomePage());
|
| | | PageParameters params = getPageParameters();
|
| | | if (params == null) {
|
| | | // redirect to this page
|
| | | setResponsePage(getClass());
|
| | | } else {
|
| | | // Strip username and password and redirect to this page
|
| | | params.remove("username");
|
| | | params.remove("password");
|
| | | setResponsePage(getClass(), params);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | if (addedExpression) {
|
| | | filters.add(new DropDownMenuItem());
|
| | | }
|
| | | } |
| | | }
|
| | | return new ArrayList<DropDownMenuItem>(filters);
|
| | | }
|
| | |
|
| | |
| | | Set<Integer> choicesSet = new HashSet<Integer>(Arrays.asList(daysBack, 14, 28, 60, 90, 180));
|
| | | List<Integer> choices = new ArrayList<Integer>(choicesSet);
|
| | | Collections.sort(choices);
|
| | | String lastDaysPattern = getString("gb.lastNDays");
|
| | | for (Integer db : choices) {
|
| | | String txt = "last " + db + (db.intValue() > 1 ? " days" : "day");
|
| | | String txt = MessageFormat.format(lastDaysPattern, db);
|
| | | items.add(new DropDownMenuItem(txt, "db", db.toString(), params));
|
| | | }
|
| | | items.add(new DropDownMenuItem());
|
| | |
| | | if (!hasParameter) {
|
| | | models.addAll(availableModels);
|
| | | }
|
| | | |
| | |
|
| | | // time-filter the list
|
| | | if (daysBack > 0) {
|
| | | Calendar cal = Calendar.getInstance();
|