| | |
| | | import javax.servlet.http.Cookie;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import org.apache.wicket.MarkupContainer;
|
| | | import org.apache.wicket.PageParameters;
|
| | | import org.apache.wicket.RestartResponseAtInterceptPageException;
|
| | | import org.apache.wicket.RestartResponseException;
|
| | | import org.apache.wicket.markup.html.WebPage;
|
| | | import org.apache.wicket.markup.html.basic.Label;
|
| | | import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
| | | import org.apache.wicket.markup.html.link.ExternalLink;
|
| | | import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
| | | import org.apache.wicket.markup.html.panel.Fragment;
|
| | | import org.apache.wicket.protocol.http.WebRequest;
|
| | | import org.apache.wicket.protocol.http.WebResponse;
|
| | | import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
|
| | |
| | |
|
| | | import com.gitblit.Constants;
|
| | | import com.gitblit.Constants.AccessRestrictionType;
|
| | | import com.gitblit.Constants.FederationStrategy;
|
| | | import com.gitblit.GitBlit;
|
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.models.UserModel;
|
| | |
| | | // Set Cookie
|
| | | WebResponse response = (WebResponse) getRequestCycle().getResponse();
|
| | | GitBlit.self().setCookie(response, user);
|
| | | continueToOriginalDestination();
|
| | | }
|
| | | }
|
| | |
|
| | | protected void setupPage(String repositoryName, String pageName) {
|
| | |
|
| | | if (repositoryName != null && repositoryName.trim().length() > 0) {
|
| | | add(new Label("title", getServerName() + " - " + repositoryName));
|
| | | } else {
|
| | | add(new Label("title", getServerName()));
|
| | | }
|
| | | // header
|
| | | String siteName = GitBlit.getString(Keys.web.siteName, Constants.NAME);
|
| | | if (siteName == null || siteName.trim().length() == 0) {
|
| | | siteName = Constants.NAME;
|
| | | }
|
| | | add(new LinkPanel("siteName", null, siteName, RepositoriesPage.class, null));
|
| | | add(new LinkPanel("repositoryName", null, repositoryName, SummaryPage.class,
|
| | | WicketUtils.newRepositoryParameter(repositoryName)));
|
| | | add(new Label("pageName", pageName));
|
| | |
|
| | | ExternalLink rootLink = new ExternalLink("rootLink", urlFor(RepositoriesPage.class, null).toString());
|
| | | WicketUtils.setHtmlTooltip(rootLink, GitBlit.getString(Keys.web.siteName, Constants.NAME));
|
| | | add(rootLink);
|
| | |
|
| | | // Feedback panel for info, warning, and non-fatal error messages
|
| | | add(new FeedbackPanel("feedback"));
|
| | |
| | | // footer
|
| | | if (GitBlit.getBoolean(Keys.web.authenticateViewPages, true)
|
| | | || GitBlit.getBoolean(Keys.web.authenticateAdminPages, true)) {
|
| | | if (GitBlitWebSession.get().isLoggedIn()) {
|
| | | // logout
|
| | | add(new LinkPanel("userPanel", null, getString("gb.logout") + " "
|
| | | + GitBlitWebSession.get().getUser().toString(), LogoutPage.class));
|
| | | } else {
|
| | | // login
|
| | | add(new LinkPanel("userPanel", null, getString("gb.login"), LoginPage.class));
|
| | | }
|
| | | UserFragment userFragment = new UserFragment("userPanel", "userFragment", BasePage.this);
|
| | | add(userFragment);
|
| | | } else {
|
| | | add(new Label("userPanel", ""));
|
| | | }
|
| | |
|
| | | add(new Label("gbVersion", "v" + Constants.VERSION));
|
| | | if (GitBlit.getBoolean(Keys.web.aggressiveHeapManagement, false)) {
|
| | | System.gc();
|
| | |
| | | break;
|
| | | case VIEW:
|
| | | map.put(type, getString("gb.viewRestricted"));
|
| | | break;
|
| | | }
|
| | | }
|
| | | return map;
|
| | | }
|
| | | |
| | | protected Map<FederationStrategy, String> getFederationTypes() {
|
| | | Map<FederationStrategy, String> map = new LinkedHashMap<FederationStrategy, String>();
|
| | | for (FederationStrategy type : FederationStrategy.values()) {
|
| | | switch (type) {
|
| | | case EXCLUDE:
|
| | | map.put(type, getString("gb.excludeFromFederation"));
|
| | | break;
|
| | | case FEDERATE_THIS:
|
| | | map.put(type, getString("gb.federateThis"));
|
| | | break;
|
| | | case FEDERATE_ORIGIN:
|
| | | map.put(type, getString("gb.federateOrigin"));
|
| | | break;
|
| | | }
|
| | | }
|
| | |
| | | if (GitBlitWebSession.get().isLoggedIn()) {
|
| | | error(message, true);
|
| | | } else {
|
| | | throw new RestartResponseAtInterceptPageException(LoginPage.class);
|
| | | throw new RestartResponseAtInterceptPageException(RepositoriesPage.class);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * Panel fragment for displaying login or logout/change_password links.
|
| | | * |
| | | */
|
| | | static class UserFragment extends Fragment {
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public UserFragment(String id, String markupId, MarkupContainer markupProvider) {
|
| | | super(id, markupId, markupProvider);
|
| | |
|
| | | if (GitBlitWebSession.get().isLoggedIn()) {
|
| | | // username, logout, and change password
|
| | | add(new Label("username", GitBlitWebSession.get().getUser().toString() + ":"));
|
| | | add(new LinkPanel("loginLink", null, markupProvider.getString("gb.logout"),
|
| | | LogoutPage.class));
|
| | | // quick and dirty hack for showing a separator
|
| | | add(new Label("separator", "|"));
|
| | | add(new BookmarkablePageLink<Void>("changePasswordLink", ChangePasswordPage.class));
|
| | | } else {
|
| | | // login
|
| | | add(new Label("username").setVisible(false));
|
| | | add(new Label("loginLink").setVisible(false));
|
| | | add(new Label("separator").setVisible(false));
|
| | | add(new Label("changePasswordLink").setVisible(false));
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|