Package com.gitblit.Constants

Examples of com.gitblit.Constants.AccessPermission


    String username = StringUtils.encodeUsername(UserModel.ANONYMOUS.equals(user) ? "" : user.username);

    List<RepositoryUrl> list = new ArrayList<RepositoryUrl>();
    // http/https url
    if (settings.getBoolean(Keys.git.enableGitServlet, true)) {
      AccessPermission permission = user.getRepositoryPermission(repository).permission;
      if (permission.exceeds(AccessPermission.NONE)) {
        list.add(new RepositoryUrl(getRepositoryUrl(request, username, repository), permission));
      }
    }

    // add all other urls
View Full Code Here


    return null;
  }

  public AccessPermission getGitDaemonAccessPermission(UserModel user, RepositoryModel repository) {
    if (gitDaemon != null && user.canClone(repository)) {
      AccessPermission gitDaemonPermission = user.getRepositoryPermission(repository).permission;
      if (gitDaemonPermission.atLeast(AccessPermission.CLONE)) {
        if (repository.accessRestriction.atLeast(AccessRestrictionType.CLONE)) {
          // can not authenticate clone via anonymous git protocol
          gitDaemonPermission = AccessPermission.NONE;
        } else if (repository.accessRestriction.atLeast(AccessRestrictionType.PUSH)) {
          // can not authenticate push via anonymous git protocol
View Full Code Here

    try {
      read();
      // identify users which require role rename
      for (UserModel model : users.values()) {
        if (model.hasRepositoryPermission(oldRole)) {
          AccessPermission permission = model.removeRepositoryPermission(oldRole);
          model.setRepositoryPermission(newRole, permission);
        }
      }

      // identify teams which require role rename
      for (TeamModel model : teams.values()) {
        if (model.hasRepositoryPermission(oldRole)) {
          AccessPermission permission = model.removeRepositoryPermission(oldRole);
          model.setRepositoryPermission(newRole, permission);
        }
      }
      // persist changes
      write();
View Full Code Here

    List<RepositoryUrl> list = new ArrayList<RepositoryUrl>();

    // http/https url
    if (settings.getBoolean(Keys.git.enableGitServlet, true)) {
      AccessPermission permission = user.getRepositoryPermission(repository).permission;
      if (permission.exceeds(AccessPermission.NONE)) {
        Transport transport = Transport.fromString(request.getScheme());
        if (permission.atLeast(AccessPermission.PUSH) && !acceptPush(transport)) {
          // downgrade the repo permission for this transport
          // because it is not an acceptable PUSH transport
          permission = AccessPermission.CLONE;
        }
        list.add(new RepositoryUrl(getRepositoryUrl(request, username, repository), permission));
      }
    }

    // ssh daemon url
    String sshDaemonUrl = servicesManager.getSshDaemonUrl(request, user, repository);
    if (!StringUtils.isEmpty(sshDaemonUrl)) {
      AccessPermission permission = user.getRepositoryPermission(repository).permission;
      if (permission.exceeds(AccessPermission.NONE)) {
        if (permission.atLeast(AccessPermission.PUSH) && !acceptPush(Transport.SSH)) {
          // downgrade the repo permission for this transport
          // because it is not an acceptable PUSH transport
          permission = AccessPermission.CLONE;
        }

        list.add(new RepositoryUrl(sshDaemonUrl, permission));
      }
    }

    // git daemon url
    String gitDaemonUrl = servicesManager.getGitDaemonUrl(request, user, repository);
    if (!StringUtils.isEmpty(gitDaemonUrl)) {
      AccessPermission permission = servicesManager.getGitDaemonAccessPermission(user, repository);
      if (permission.exceeds(AccessPermission.NONE)) {
        if (permission.atLeast(AccessPermission.PUSH) && !acceptPush(Transport.GIT)) {
          // downgrade the repo permission for this transport
          // because it is not an acceptable PUSH transport
          permission = AccessPermission.CLONE;
        }
        list.add(new RepositoryUrl(gitDaemonUrl, permission));
View Full Code Here

    String username = StringUtils.encodeUsername(UserModel.ANONYMOUS.equals(user) ? "" : user.username);

    List<RepositoryUrl> list = new ArrayList<RepositoryUrl>();
    // http/https url
    if (settings.getBoolean(Keys.git.enableGitServlet, true)) {
      AccessPermission permission = user.getRepositoryPermission(repository).permission;
      if (permission.exceeds(AccessPermission.NONE)) {
        list.add(new RepositoryUrl(getRepositoryUrl(request, username, repository), permission));
      }
    }

    // add all other urls
View Full Code Here

    try {
      read();
      // identify users which require role rename
      for (UserModel model : users.values()) {
        if (model.hasRepositoryPermission(oldRole)) {
          AccessPermission permission = model.removeRepositoryPermission(oldRole);
          model.setRepositoryPermission(newRole, permission);
        }
      }

      // identify teams which require role rename
      for (TeamModel model : teams.values()) {
        if (model.hasRepositoryPermission(oldRole)) {
          AccessPermission permission = model.removeRepositoryPermission(oldRole);
          model.setRepositoryPermission(newRole, permission);
        }
      }
      // persist changes
      write();
View Full Code Here

    List<RepositoryUrl> list = new ArrayList<RepositoryUrl>();

    // http/https url
    if (settings.getBoolean(Keys.git.enableGitServlet, true)) {
      AccessPermission permission = user.getRepositoryPermission(repository).permission;
      if (permission.exceeds(AccessPermission.NONE)) {
        Transport transport = Transport.fromString(request.getScheme());
        if (permission.atLeast(AccessPermission.PUSH) && !acceptPush(transport)) {
          // downgrade the repo permission for this transport
          // because it is not an acceptable PUSH transport
          permission = AccessPermission.CLONE;
        }
        list.add(new RepositoryUrl(getRepositoryUrl(request, username, repository), permission));
      }
    }

    // ssh daemon url
    String sshDaemonUrl = servicesManager.getSshDaemonUrl(request, user, repository);
    if (!StringUtils.isEmpty(sshDaemonUrl)) {
      AccessPermission permission = user.getRepositoryPermission(repository).permission;
      if (permission.exceeds(AccessPermission.NONE)) {
        if (permission.atLeast(AccessPermission.PUSH) && !acceptPush(Transport.SSH)) {
          // downgrade the repo permission for this transport
          // because it is not an acceptable PUSH transport
          permission = AccessPermission.CLONE;
        }

        list.add(new RepositoryUrl(sshDaemonUrl, permission));
      }
    }

    // git daemon url
    String gitDaemonUrl = servicesManager.getGitDaemonUrl(request, user, repository);
    if (!StringUtils.isEmpty(gitDaemonUrl)) {
      AccessPermission permission = servicesManager.getGitDaemonAccessPermission(user, repository);
      if (permission.exceeds(AccessPermission.NONE)) {
        if (permission.atLeast(AccessPermission.PUSH) && !acceptPush(Transport.GIT)) {
          // downgrade the repo permission for this transport
          // because it is not an acceptable PUSH transport
          permission = AccessPermission.CLONE;
        }
        list.add(new RepositoryUrl(gitDaemonUrl, permission));
View Full Code Here

    return null;
  }

  public AccessPermission getGitDaemonAccessPermission(UserModel user, RepositoryModel repository) {
    if (gitDaemon != null && user.canClone(repository)) {
      AccessPermission gitDaemonPermission = user.getRepositoryPermission(repository).permission;
      if (gitDaemonPermission.atLeast(AccessPermission.CLONE)) {
        if (repository.accessRestriction.atLeast(AccessRestrictionType.CLONE)) {
          // can not authenticate clone via anonymous git protocol
          gitDaemonPermission = AccessPermission.NONE;
        } else if (repository.accessRestriction.atLeast(AccessRestrictionType.PUSH)) {
          // can not authenticate push via anonymous git protocol
View Full Code Here

      // user has REWIND access to all repositories
      return list;
    }
    for (Map.Entry<String, AccessPermission> entry : permissions.entrySet()) {
      String registrant = entry.getKey();
      AccessPermission ap = entry.getValue();
      String source = null;
      boolean mutable = true;
      PermissionType pType = PermissionType.EXPLICIT;
      if (isMyPersonalRepository(registrant)) {
        pType = PermissionType.OWNER;
View Full Code Here

      return true;
    } else {
      // search for regex permission match
      for (String key : permissions.keySet()) {
        if (name.matches(key)) {
          AccessPermission p = permissions.get(key);
          if (p != null) {
            return true;
          }
        }
      }
View Full Code Here

TOP

Related Classes of com.gitblit.Constants.AccessPermission

Copyright © 2018 www.massapicom. 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.