Examples of GitBlitWebSession


Examples of com.gitblit.wicket.GitBlitWebSession

    final List<RegistrantAccessPermission> repositoryUsers = new ArrayList<RegistrantAccessPermission>();
    final List<RegistrantAccessPermission> repositoryTeams = new ArrayList<RegistrantAccessPermission>();
    List<String> preReceiveScripts = new ArrayList<String>();
    List<String> postReceiveScripts = new ArrayList<String>();

    GitBlitWebSession session = GitBlitWebSession.get();
    final UserModel user = session.getUser() == null ? UserModel.ANONYMOUS : session.getUser();
    final boolean allowEditName = isCreate || isAdmin || repositoryModel.isUsersPersonalRepository(user.username);

    if (isCreate) {
      if (user.canAdmin()) {
        super.setupPage(getString("gb.newRepository"), "");
View Full Code Here

Examples of com.gitblit.wicket.GitBlitWebSession

   */
  private void checkPermissions(RepositoryModel model) {
    boolean authenticateAdmin = app().settings().getBoolean(Keys.web.authenticateAdminPages, true);
    boolean allowAdmin = app().settings().getBoolean(Keys.web.allowAdministration, true);

    GitBlitWebSession session = GitBlitWebSession.get();
    UserModel user = session.getUser();

    if (allowAdmin) {
      if (authenticateAdmin) {
        if (user == null) {
          // No Login Available
View Full Code Here

Examples of com.gitblit.wicket.GitBlitWebSession

  protected GitBlitWebApp app() {
    return GitBlitWebApp.get();
  }

  private void login() {
    GitBlitWebSession session = GitBlitWebSession.get();
    HttpServletRequest request = ((WebRequest) getRequest()).getHttpServletRequest();
    HttpServletResponse response = ((WebResponse) getResponse()).getHttpServletResponse();

    if (session.isLoggedIn() && !session.isSessionInvalidated()) {
      // already have a session, refresh usermodel to pick up
      // any changes to permissions or roles (issue-186)
      UserModel user = app().users().getUserModel(session.getUser().username);

      if (user == null || user.disabled) {
        // user was deleted/disabled during session
        app().authentication().logout(request, response, user);
        session.setUser(null);
        session.invalidateNow();
        return;
      }

      // validate cookie during session (issue-361)
      if (user != null && app().settings().getBoolean(Keys.web.allowCookieAuthentication, true)) {
        String requestCookie = app().authentication().getCookie(request);
        if (!StringUtils.isEmpty(requestCookie) && !StringUtils.isEmpty(user.cookie)) {
          if (!requestCookie.equals(user.cookie)) {
            // cookie was changed during our session
            app().authentication().logout(request, response, user);
            session.setUser(null);
            session.invalidateNow();
            return;
          }
        }
      }
      session.setUser(user);
      return;
    }

    // try to authenticate by servlet request
    UserModel user = app().authentication().authenticate(request);

    // Login the user
    if (user != null) {
      // preserve the authentication type across session replacement
      AuthenticationType authenticationType = (AuthenticationType) request.getSession()
          .getAttribute(Constants.AUTHENTICATION_TYPE);

      // issue 62: fix session fixation vulnerability
      session.replaceSession();
      session.setUser(user);

      request.getSession().setAttribute(Constants.AUTHENTICATION_TYPE, authenticationType);

      // Set Cookie
      app().authentication().setCookie(request, response, user);

      session.continueRequest();
    }
  }
View Full Code Here

Examples of com.gitblit.wicket.GitBlitWebSession

  public ForkPage(PageParameters params) {
    super(params);

    setVersioned(false);

    GitBlitWebSession session = GitBlitWebSession.get();

    RepositoryModel repository = getRepositoryModel();
    UserModel user = session.getUser();
    boolean canFork = user.canFork(repository);

    if (!canFork) {
      // redirect to the summary page if this repository is not empty
      GitBlitWebSession.get().cacheErrorMessage(
          MessageFormat.format(getString("gb.forkNotAuthorized"), repository.name));
      throw new GitblitRedirectException(SummaryPage.class, WicketUtils.newRepositoryParameter(repository.name));
    }

    String fork = app().repositories().getFork(user.username, repository.name);
    if (fork != null) {
      // redirect to user's fork
      throw new GitblitRedirectException(SummaryPage.class, WicketUtils.newRepositoryParameter(fork));
    }

    add(new Label("forkText", getString("gb.preparingFork")));

    if (!session.isForking()) {
      // prepare session
      session.isForking(true);

      // fork it
      ForkThread forker = new ForkThread(app(), repository, session);
      forker.start();
    }
View Full Code Here

Examples of com.gitblit.wicket.GitBlitWebSession

        final String repositoryName = WicketUtils.getRepositoryName(params);
        final String objectId = WicketUtils.getObject(params);
        final String blobPath = WicketUtils.getPath(params);

        String[] encodings = getEncodings();
        GitBlitWebSession session = GitBlitWebSession.get();
        UserModel user = session.getUser();

        RepositoryModel model = app().repositories().getRepositoryModel(user, repositoryName);
        if (model == null) {
          // user does not have permission
          error(getString("gb.canNotLoadRepository") + " " + repositoryName);
View Full Code Here

Examples of com.gitblit.wicket.GitBlitWebSession

public class LogoutPage extends BasePage {

  public LogoutPage() {
    super();
    GitBlitWebSession session = GitBlitWebSession.get();
    UserModel user = session.getUser();
    app().authentication().logout(((WebRequest) getRequest()).getHttpServletRequest(),
        ((WebResponse) getResponse()).getHttpServletResponse(), user);
    session.invalidate();

    /*
     * Now check whether the authentication was realized via the Authorization in the header.
     * If so, it is likely to be cached by the browser, and cannot be undone. Effectively, this means
     * that you cannot log out...
View Full Code Here

Examples of com.gitblit.wicket.GitBlitWebSession

    if (user != null) {
      HttpServletRequest request = ((WebRequest) getRequest()).getHttpServletRequest();
      HttpServletResponse response = ((WebResponse) getResponse()).getHttpServletResponse();

      // Set the user into the session
      GitBlitWebSession session = GitBlitWebSession.get();

      // issue 62: fix session fixation vulnerability
      session.replaceSession();
      session.setUser(user);

      request = ((WebRequest) getRequest()).getHttpServletRequest();
      response = ((WebResponse) getResponse()).getHttpServletResponse();
      request.getSession().setAttribute(Constants.AUTHENTICATION_TYPE, AuthenticationType.CREDENTIALS);

      // Set Cookie
      app().authentication().setCookie(request, response, user);

      if (!session.continueRequest()) {
        PageParameters params = getPageParameters();
        if (params == null) {
          // redirect to this page
          redirectTo(getClass());
        } else {
View Full Code Here

Examples of com.gitblit.wicket.GitBlitWebSession

    @Override
    protected void onInitialize() {
      super.onInitialize();

      GitBlitWebSession session = GitBlitWebSession.get();
      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();
View Full Code Here

Examples of com.gitblit.wicket.GitBlitWebSession

  private TextField<String> nameField;

  public RepositoryNamePanel(String wicketId, RepositoryModel repository) {
    super(wicketId);

    GitBlitWebSession session = GitBlitWebSession.get();
    UserModel user = session.getUser();
    if (user == null) {
      user = UserModel.ANONYMOUS;
    }

    // build project set for repository destination
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.