| | |
| | | import com.gitblit.Constants.RegistrantType;
|
| | | import com.gitblit.Constants.Unused;
|
| | | import com.gitblit.utils.ArrayUtils;
|
| | | import com.gitblit.utils.ModelUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | |
|
| | | /**
|
| | |
| | | // non-persisted fields
|
| | | public boolean isAuthenticated;
|
| | | public AccountType accountType;
|
| | |
|
| | | public UserPreferences userPreferences;
|
| | |
|
| | | public UserModel(String username) {
|
| | | this.username = username;
|
| | | this.isAuthenticated = true;
|
| | | this.accountType = AccountType.LOCAL;
|
| | | this.userPreferences = new UserPreferences(this.username);
|
| | | }
|
| | |
|
| | | private UserModel() {
|
| | | this.username = "$anonymous";
|
| | | this.isAuthenticated = false;
|
| | | this.accountType = AccountType.LOCAL;
|
| | | this.userPreferences = new UserPreferences(this.username);
|
| | | }
|
| | |
|
| | | public boolean isLocalAccount() {
|
| | |
| | | }
|
| | |
|
| | | public void setRepositoryPermission(String repository, AccessPermission permission) {
|
| | | permissions.put(repository.toLowerCase(), permission);
|
| | | if (permission == null) {
|
| | | // remove the permission
|
| | | permissions.remove(repository.toLowerCase());
|
| | | } else {
|
| | | // set the new permission
|
| | | permissions.put(repository.toLowerCase(), permission);
|
| | | }
|
| | | }
|
| | |
|
| | | public RegistrantAccessPermission getRepositoryPermission(RepositoryModel repository) {
|
| | |
| | | }
|
| | | if (canCreate) {
|
| | | String projectPath = StringUtils.getFirstPathElement(repository);
|
| | | if (!StringUtils.isEmpty(projectPath) && projectPath.equalsIgnoreCase("~" + username)) {
|
| | | if (!StringUtils.isEmpty(projectPath) && projectPath.equalsIgnoreCase(getPersonalPath())) {
|
| | | // personal repository
|
| | | return true;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | public String getPersonalPath() {
|
| | | return "~" + username;
|
| | | return ModelUtils.getPersonalPath(username);
|
| | | }
|
| | | |
| | | public UserPreferences getPreferences() {
|
| | | return userPreferences;
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | |
|
| | | public boolean isMyPersonalRepository(String repository) {
|
| | | String projectPath = StringUtils.getFirstPathElement(repository);
|
| | | return !StringUtils.isEmpty(projectPath) && projectPath.equalsIgnoreCase("~" + username);
|
| | | return !StringUtils.isEmpty(projectPath) && projectPath.equalsIgnoreCase(getPersonalPath());
|
| | | }
|
| | | }
|