| | |
| | | |
| | | import org.apache.wicket.MarkupContainer; |
| | | import org.apache.wicket.PageParameters; |
| | | import org.apache.wicket.RequestCycle; |
| | | import org.apache.wicket.behavior.HeaderContributor; |
| | | import org.apache.wicket.markup.html.IHeaderContributor; |
| | | import org.apache.wicket.markup.html.IHeaderResponse; |
| | | import org.apache.wicket.markup.html.basic.Label; |
| | | import org.apache.wicket.markup.html.form.PasswordTextField; |
| | | import org.apache.wicket.markup.html.form.TextField; |
| | | import org.apache.wicket.markup.html.link.BookmarkablePageLink; |
| | | import org.apache.wicket.markup.html.panel.Fragment; |
| | |
| | | import com.gitblit.utils.ModelUtils; |
| | | import com.gitblit.utils.StringUtils; |
| | | import com.gitblit.wicket.GitBlitWebSession; |
| | | import com.gitblit.wicket.NonTrimmedPasswordTextField; |
| | | import com.gitblit.wicket.SessionlessForm; |
| | | import com.gitblit.wicket.WicketUtils; |
| | | import com.gitblit.wicket.panels.GravatarImage; |
| | | import com.gitblit.wicket.panels.AvatarImage; |
| | | import com.gitblit.wicket.panels.LinkPanel; |
| | | import com.gitblit.wicket.panels.NavigationPanel; |
| | | |
| | |
| | | boolean authenticateAdmin = app().settings().getBoolean(Keys.web.authenticateAdminPages, true); |
| | | boolean allowAdmin = app().settings().getBoolean(Keys.web.allowAdministration, true); |
| | | boolean allowLucene = app().settings().getBoolean(Keys.web.allowLuceneIndexing, true); |
| | | boolean displayUserPanel = app().settings().getBoolean(Keys.web.displayUserPanel, true); |
| | | boolean isLoggedIn = GitBlitWebSession.get().isLoggedIn(); |
| | | |
| | | if (authenticateAdmin) { |
| | |
| | | } |
| | | } |
| | | |
| | | if (authenticateView || authenticateAdmin) { |
| | | if (displayUserPanel && (authenticateView || authenticateAdmin)) { |
| | | if (isLoggedIn) { |
| | | UserMenu userFragment = new UserMenu("userPanel", "userMenuFragment", RootPage.this); |
| | | add(userFragment); |
| | |
| | | // navigation links |
| | | List<NavLink> navLinks = new ArrayList<NavLink>(); |
| | | if (!authenticateView || (authenticateView && isLoggedIn)) { |
| | | UserModel user = UserModel.ANONYMOUS; |
| | | if (isLoggedIn) { |
| | | user = GitBlitWebSession.get().getUser(); |
| | | } |
| | | |
| | | navLinks.add(new PageNavLink(isLoggedIn ? "gb.myDashboard" : "gb.dashboard", MyDashboardPage.class, |
| | | getRootPageParameters())); |
| | | if (isLoggedIn && app().tickets().isReady()) { |
| | |
| | | } |
| | | navLinks.add(new PageNavLink("gb.repositories", RepositoriesPage.class, |
| | | getRootPageParameters())); |
| | | |
| | | navLinks.add(new PageNavLink("gb.filestore", FilestorePage.class, getRootPageParameters())); |
| | | |
| | | navLinks.add(new PageNavLink("gb.activity", ActivityPage.class, getRootPageParameters())); |
| | | if (allowLucene) { |
| | | navLinks.add(new PageNavLink("gb.search", LuceneSearchPage.class)); |
| | |
| | | |
| | | if (!authenticateView || (authenticateView && isLoggedIn)) { |
| | | addDropDownMenus(navLinks); |
| | | } |
| | | |
| | | UserModel user = UserModel.ANONYMOUS; |
| | | if (isLoggedIn) { |
| | | user = GitBlitWebSession.get().getUser(); |
| | | } |
| | | |
| | | // add nav link extensions |
| | |
| | | |
| | | request = ((WebRequest) getRequest()).getHttpServletRequest(); |
| | | response = ((WebResponse) getResponse()).getHttpServletResponse(); |
| | | request.getSession().setAttribute(Constants.AUTHENTICATION_TYPE, AuthenticationType.CREDENTIALS); |
| | | request.getSession().setAttribute(Constants.ATTRIB_AUTHTYPE, AuthenticationType.CREDENTIALS); |
| | | |
| | | // Set Cookie |
| | | app().authentication().setCookie(request, response, user); |
| | |
| | | String username = RootPage.this.username.getObject(); |
| | | char[] password = RootPage.this.password.getObject().toCharArray(); |
| | | |
| | | UserModel user = app().authentication().authenticate(username, password); |
| | | HttpServletRequest request = ((WebRequest)RequestCycle.get().getRequest()).getHttpServletRequest(); |
| | | |
| | | UserModel user = app().authentication().authenticate(username, password, request.getRemoteAddr()); |
| | | if (user == null) { |
| | | error(getString("gb.invalidUsernameOrPassword")); |
| | | } else if (user.username.equals(Constants.FEDERATION_USER)) { |
| | |
| | | TextField<String> unameField = new TextField<String>("username", username); |
| | | WicketUtils.setInputPlaceholder(unameField, markupProvider.getString("gb.username")); |
| | | loginForm.add(unameField); |
| | | PasswordTextField pwField = new PasswordTextField("password", password); |
| | | NonTrimmedPasswordTextField pwField = new NonTrimmedPasswordTextField("password", password); |
| | | WicketUtils.setInputPlaceholder(pwField, markupProvider.getString("gb.password")); |
| | | loginForm.add(pwField); |
| | | add(loginForm); |
| | |
| | | UserModel user = session.getUser(); |
| | | boolean editCredentials = app().authentication().supportsCredentialChanges(user); |
| | | HttpServletRequest request = ((WebRequest) getRequest()).getHttpServletRequest(); |
| | | AuthenticationType authenticationType = (AuthenticationType) request.getSession().getAttribute(Constants.AUTHENTICATION_TYPE); |
| | | boolean standardLogin = authenticationType.isStandard(); |
| | | AuthenticationType authenticationType = (AuthenticationType) request.getAttribute(Constants.ATTRIB_AUTHTYPE); |
| | | boolean standardLogin = (null != authenticationType) ? authenticationType.isStandard() : true; |
| | | |
| | | if (app().settings().getBoolean(Keys.web.allowGravatar, true)) { |
| | | add(new GravatarImage("username", user, "navbarGravatar", 20, false)); |
| | | add(new AvatarImage("username", user, "navbarGravatar", 20, false)); |
| | | } else { |
| | | add(new Label("username", user.getDisplayName())); |
| | | } |