summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2011-05-11 22:07:53 -0400
committerJames Moger <james.moger@gitblit.com>2011-05-11 22:07:53 -0400
commit511554c6bdd7daa080506fb62400bf6d295ab9e2 (patch)
treee380037512384c88ea8cb7c39a568964011dfc37 /src
parentdfb88962fdbd29f59abe92178bb042738d57c3e1 (diff)
downloadgitblit-511554c6bdd7daa080506fb62400bf6d295ab9e2.tar.gz
gitblit-511554c6bdd7daa080506fb62400bf6d295ab9e2.zip
Renamed User to UserModel.
Diffstat (limited to 'src')
-rw-r--r--src/com/gitblit/GitBlit.java18
-rw-r--r--src/com/gitblit/ILoginService.java12
-rw-r--r--src/com/gitblit/JettyLoginService.java16
-rw-r--r--src/com/gitblit/wicket/AuthorizationStrategy.java4
-rw-r--r--src/com/gitblit/wicket/GitBlitWebSession.java8
-rw-r--r--src/com/gitblit/wicket/LoginPage.java8
-rw-r--r--src/com/gitblit/wicket/models/UserModel.java (renamed from src/com/gitblit/wicket/models/User.java)4
-rw-r--r--src/com/gitblit/wicket/pages/EditUserPage.java12
-rw-r--r--src/com/gitblit/wicket/pages/RepositoriesPage.java4
9 files changed, 43 insertions, 43 deletions
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index bdfa590e..d0daa536 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
import com.gitblit.Constants.AccessRestrictionType;
import com.gitblit.utils.JGitUtils;
import com.gitblit.wicket.models.RepositoryModel;
-import com.gitblit.wicket.models.User;
+import com.gitblit.wicket.models.UserModel;
public class GitBlit implements ServletContextListener {
@@ -67,14 +67,14 @@ public class GitBlit implements ServletContextListener {
this.loginService = loginService;
}
- public User authenticate(String username, char[] password) {
+ public UserModel authenticate(String username, char[] password) {
if (loginService == null) {
return null;
}
return loginService.authenticate(username, password);
}
- public User authenticate(Cookie[] cookies) {
+ public UserModel authenticate(Cookie[] cookies) {
if (loginService == null) {
return null;
}
@@ -89,19 +89,19 @@ public class GitBlit implements ServletContextListener {
return null;
}
- public void setCookie(WebResponse response, User user) {
+ public void setCookie(WebResponse response, UserModel user) {
Cookie userCookie = new Cookie(Constants.NAME, user.getCookie());
userCookie.setMaxAge(Integer.MAX_VALUE);
userCookie.setPath("/");
response.addCookie(userCookie);
}
- public User getUser(String username) {
- User user = loginService.getUserModel(username);
+ public UserModel getUser(String username) {
+ UserModel user = loginService.getUserModel(username);
return user;
}
- public void editUserModel(User user, boolean isCreate) throws GitBlitException {
+ public void editUserModel(UserModel user, boolean isCreate) throws GitBlitException {
if (!loginService.updateUserModel(user)) {
throw new GitBlitException(isCreate ? "Failed to add user!" : "Failed to update user!");
}
@@ -125,7 +125,7 @@ public class GitBlit implements ServletContextListener {
return r;
}
- public List<RepositoryModel> getRepositoryModels(User user) {
+ public List<RepositoryModel> getRepositoryModels(UserModel user) {
List<String> list = getRepositoryList();
List<RepositoryModel> repositories = new ArrayList<RepositoryModel>();
for (String repo : list) {
@@ -137,7 +137,7 @@ public class GitBlit implements ServletContextListener {
return repositories;
}
- public RepositoryModel getRepositoryModel(User user, String repositoryName) {
+ public RepositoryModel getRepositoryModel(UserModel user, String repositoryName) {
RepositoryModel model = getRepositoryModel(repositoryName);
if (model.accessRestriction.atLeast(AccessRestrictionType.VIEW)) {
if (user != null && user.canView(model)) {
diff --git a/src/com/gitblit/ILoginService.java b/src/com/gitblit/ILoginService.java
index fc2801d9..d0c5d13d 100644
--- a/src/com/gitblit/ILoginService.java
+++ b/src/com/gitblit/ILoginService.java
@@ -1,17 +1,17 @@
package com.gitblit;
-import com.gitblit.wicket.models.User;
+import com.gitblit.wicket.models.UserModel;
public interface ILoginService {
- User authenticate(String username, char[] password);
+ UserModel authenticate(String username, char[] password);
- User authenticate(char[] cookie);
+ UserModel authenticate(char[] cookie);
- User getUserModel(String username);
+ UserModel getUserModel(String username);
- boolean updateUserModel(User model);
+ boolean updateUserModel(UserModel model);
- boolean deleteUserModel(User model);
+ boolean deleteUserModel(UserModel model);
}
diff --git a/src/com/gitblit/JettyLoginService.java b/src/com/gitblit/JettyLoginService.java
index ddd3722d..4b439647 100644
--- a/src/com/gitblit/JettyLoginService.java
+++ b/src/com/gitblit/JettyLoginService.java
@@ -18,7 +18,7 @@ import org.eclipse.jetty.server.UserIdentity;
import org.eclipse.jetty.util.log.Log;
import com.gitblit.utils.StringUtils;
-import com.gitblit.wicket.models.User;
+import com.gitblit.wicket.models.UserModel;
public class JettyLoginService extends MappedLoginService implements ILoginService {
@@ -31,12 +31,12 @@ public class JettyLoginService extends MappedLoginService implements ILoginServi
}
@Override
- public User authenticate(String username, char[] password) {
+ public UserModel authenticate(String username, char[] password) {
UserIdentity identity = login(username, new String(password));
if (identity == null || identity.equals(UserIdentity.UNAUTHENTICATED_IDENTITY)) {
return null;
}
- User user = new User(username);
+ UserModel user = new UserModel(username);
user.setCookie(StringUtils.getSHA1((Constants.NAME + username + new String(password))));
user.canAdmin(identity.isUserInRole(Constants.ADMIN_ROLE, null));
@@ -53,14 +53,14 @@ public class JettyLoginService extends MappedLoginService implements ILoginServi
}
@Override
- public User authenticate(char[] cookie) {
+ public UserModel authenticate(char[] cookie) {
// TODO cookie login
return null;
}
@Override
- public User getUserModel(String username) {
- User model = new User(username);
+ public UserModel getUserModel(String username) {
+ UserModel model = new UserModel(username);
UserIdentity identity = _users.get(username);
Subject subject = identity.getSubject();
for (Principal principal : subject.getPrincipals()) {
@@ -83,7 +83,7 @@ public class JettyLoginService extends MappedLoginService implements ILoginServi
}
@Override
- public boolean updateUserModel(User model) {
+ public boolean updateUserModel(UserModel model) {
try {
Properties properties = new Properties();
FileReader reader = new FileReader(realmFile);
@@ -129,7 +129,7 @@ public class JettyLoginService extends MappedLoginService implements ILoginServi
}
@Override
- public boolean deleteUserModel(User model) {
+ public boolean deleteUserModel(UserModel model) {
try {
// Read realm file
Properties properties = new Properties();
diff --git a/src/com/gitblit/wicket/AuthorizationStrategy.java b/src/com/gitblit/wicket/AuthorizationStrategy.java
index c4560adc..d5a59abb 100644
--- a/src/com/gitblit/wicket/AuthorizationStrategy.java
+++ b/src/com/gitblit/wicket/AuthorizationStrategy.java
@@ -7,7 +7,7 @@ import org.apache.wicket.authorization.strategies.page.AbstractPageAuthorization
import com.gitblit.GitBlit;
import com.gitblit.Keys;
-import com.gitblit.wicket.models.User;
+import com.gitblit.wicket.models.UserModel;
import com.gitblit.wicket.pages.RepositoriesPage;
public class AuthorizationStrategy extends AbstractPageAuthorizationStrategy implements IUnauthorizedComponentInstantiationListener {
@@ -29,7 +29,7 @@ public class AuthorizationStrategy extends AbstractPageAuthorizationStrategy imp
return false;
}
- User user = session.getUser();
+ UserModel user = session.getUser();
if (pageClass.isAnnotationPresent(AdminPage.class)) {
// admin page
if (allowAdmin) {
diff --git a/src/com/gitblit/wicket/GitBlitWebSession.java b/src/com/gitblit/wicket/GitBlitWebSession.java
index c6cc36d0..4996546d 100644
--- a/src/com/gitblit/wicket/GitBlitWebSession.java
+++ b/src/com/gitblit/wicket/GitBlitWebSession.java
@@ -7,7 +7,7 @@ import org.apache.wicket.Session;
import org.apache.wicket.protocol.http.WebSession;
import org.apache.wicket.protocol.http.request.WebClientInfo;
-import com.gitblit.wicket.models.User;
+import com.gitblit.wicket.models.UserModel;
public final class GitBlitWebSession extends WebSession {
@@ -15,7 +15,7 @@ public final class GitBlitWebSession extends WebSession {
protected TimeZone timezone = null;
- private User user = null;
+ private UserModel user = null;
private String errorMessage = null;
@@ -39,11 +39,11 @@ public final class GitBlitWebSession extends WebSession {
return user.canAdmin();
}
- public User getUser() {
+ public UserModel getUser() {
return user;
}
- public void setUser(User user) {
+ public void setUser(UserModel user) {
this.user = user;
}
diff --git a/src/com/gitblit/wicket/LoginPage.java b/src/com/gitblit/wicket/LoginPage.java
index 9e26a62a..db971d27 100644
--- a/src/com/gitblit/wicket/LoginPage.java
+++ b/src/com/gitblit/wicket/LoginPage.java
@@ -18,7 +18,7 @@ import org.apache.wicket.protocol.http.WebResponse;
import com.gitblit.Constants;
import com.gitblit.GitBlit;
import com.gitblit.Keys;
-import com.gitblit.wicket.models.User;
+import com.gitblit.wicket.models.UserModel;
public class LoginPage extends WebPage {
@@ -61,7 +61,7 @@ public class LoginPage extends WebPage {
String username = LoginPage.this.username.getObject();
char[] password = LoginPage.this.password.getObject().toCharArray();
- User user = GitBlit.self().authenticate(username, password);
+ UserModel user = GitBlit.self().authenticate(username, password);
if (user == null)
error("Invalid username or password!");
else
@@ -70,7 +70,7 @@ public class LoginPage extends WebPage {
}
private void tryAutomaticLogin() {
- User user = null;
+ UserModel user = null;
// Grab cookie from Browser Session
Cookie[] cookies = ((WebRequest) getRequestCycle().getRequest()).getCookies();
@@ -82,7 +82,7 @@ public class LoginPage extends WebPage {
loginUser(user);
}
- private void loginUser(User user) {
+ private void loginUser(UserModel user) {
if (user != null) {
// Set the user into the session
GitBlitWebSession.get().setUser(user);
diff --git a/src/com/gitblit/wicket/models/User.java b/src/com/gitblit/wicket/models/UserModel.java
index 07848396..c65d3564 100644
--- a/src/com/gitblit/wicket/models/User.java
+++ b/src/com/gitblit/wicket/models/UserModel.java
@@ -6,7 +6,7 @@ import java.util.List;
import com.gitblit.Constants.AccessRestrictionType;
-public class User implements Serializable {
+public class UserModel implements Serializable {
private static final long serialVersionUID = 1L;
@@ -16,7 +16,7 @@ public class User implements Serializable {
private boolean canAdmin = false;
private List<String> repositories = new ArrayList<String>();
- public User(String username) {
+ public UserModel(String username) {
this.username = username;
}
diff --git a/src/com/gitblit/wicket/pages/EditUserPage.java b/src/com/gitblit/wicket/pages/EditUserPage.java
index 84bf7bc9..250d1fde 100644
--- a/src/com/gitblit/wicket/pages/EditUserPage.java
+++ b/src/com/gitblit/wicket/pages/EditUserPage.java
@@ -22,7 +22,7 @@ import com.gitblit.GitBlitException;
import com.gitblit.wicket.AdminPage;
import com.gitblit.wicket.BasePage;
import com.gitblit.wicket.WicketUtils;
-import com.gitblit.wicket.models.User;
+import com.gitblit.wicket.models.UserModel;
@AdminPage
public class EditUserPage extends BasePage {
@@ -33,7 +33,7 @@ public class EditUserPage extends BasePage {
// create constructor
super();
isCreate = true;
- setupPage(new User(""));
+ setupPage(new UserModel(""));
}
public EditUserPage(PageParameters params) {
@@ -41,23 +41,23 @@ public class EditUserPage extends BasePage {
super(params);
isCreate = false;
String name = WicketUtils.getUsername(params);
- User model = GitBlit.self().getUser(name);
+ UserModel model = GitBlit.self().getUser(name);
setupPage(model);
}
- protected void setupPage(final User userModel) {
+ protected void setupPage(final UserModel userModel) {
if (isCreate) {
super.setupPage("", getString("gb.newUser"));
} else {
super.setupPage("", getString("gb.edit"));
}
final Model<String> confirmPassword = new Model<String>();
- CompoundPropertyModel<User> model = new CompoundPropertyModel<User>(userModel);
+ CompoundPropertyModel<UserModel> model = new CompoundPropertyModel<UserModel>(userModel);
List<String> repos = GitBlit.self().getRepositoryList();
repos.add(0, "*"); // all repositories wildcard
final Palette<String> repositories = new Palette<String>("repositories", new ListModel<String>(userModel.getRepositories()), new CollectionModel<String>(repos), new ChoiceRenderer<String>("", ""), 10, false);
- Form<User> form = new Form<User>("editForm", model) {
+ Form<UserModel> form = new Form<UserModel>("editForm", model) {
private static final long serialVersionUID = 1L;
diff --git a/src/com/gitblit/wicket/pages/RepositoriesPage.java b/src/com/gitblit/wicket/pages/RepositoriesPage.java
index 9f3aa2a3..45058296 100644
--- a/src/com/gitblit/wicket/pages/RepositoriesPage.java
+++ b/src/com/gitblit/wicket/pages/RepositoriesPage.java
@@ -33,7 +33,7 @@ import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.LinkPanel;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.models.RepositoryModel;
-import com.gitblit.wicket.models.User;
+import com.gitblit.wicket.models.UserModel;
public class RepositoriesPage extends BasePage {
@@ -99,7 +99,7 @@ public class RepositoriesPage extends BasePage {
}
add(repositoriesMessage);
- User user = GitBlitWebSession.get().getUser();
+ UserModel user = GitBlitWebSession.get().getUser();
List<RepositoryModel> rows = GitBlit.self().getRepositoryModels(user);
DataProvider dp = new DataProvider(rows);
DataView<RepositoryModel> dataView = new DataView<RepositoryModel>("repository", dp) {