import com.gitblit.manager.IUserManager;
import com.gitblit.models.TeamModel;
import com.gitblit.models.UserModel;
+import com.gitblit.utils.ArrayUtils;
+import com.gitblit.utils.StringUtils;
public abstract class AuthenticationProvider {
return serviceName;
}
+ protected void setCookie(UserModel user, char [] password) {
+ // create a user cookie
+ if (StringUtils.isEmpty(user.cookie) && !ArrayUtils.isEmpty(password)) {
+ user.cookie = StringUtils.getSHA1(user.username + new String(password));
+ }
+ }
+
protected void updateUser(UserModel userModel) {
// TODO implement user model change detection
// account for new user and revised user
import com.gitblit.Keys;
import com.gitblit.auth.AuthenticationProvider.UsernamePasswordAuthenticationProvider;
import com.gitblit.models.UserModel;
-import com.gitblit.utils.ArrayUtils;
-import com.gitblit.utils.StringUtils;
/**
}
// create a user cookie
- if (StringUtils.isEmpty(user.cookie) && !ArrayUtils.isEmpty(password)) {
- user.cookie = StringUtils.getSHA1(user.username + passwd);
- }
+ setCookie(user, password);
// Set user attributes, hide password from backing user service.
user.password = Constants.EXTERNAL_ACCOUNT;
}
// create a user cookie
- if (StringUtils.isEmpty(user.cookie) && !ArrayUtils.isEmpty(password)) {
- user.cookie = StringUtils.getSHA1(user.username + new String(password));
- }
+ setCookie(user, password);
if (!supportsTeamMembershipChanges()) {
getTeamsFromLdap(ldapConnection, simpleUsername, loggingInUser, user);
import com.gitblit.Keys;
import com.gitblit.auth.AuthenticationProvider.UsernamePasswordAuthenticationProvider;
import com.gitblit.models.UserModel;
-import com.gitblit.utils.ArrayUtils;
-import com.gitblit.utils.StringUtils;
/**
* Implementation of PAM authentication for Linux/Unix/MacOSX.
}
UserModel user = userManager.getUserModel(username);
- if (user == null) // create user object for new authenticated user
+ if (user == null) {
+ // create user object for new authenticated user
user = new UserModel(username.toLowerCase());
+ }
// create a user cookie
- if (StringUtils.isEmpty(user.cookie) && !ArrayUtils.isEmpty(password)) {
- user.cookie = StringUtils.getSHA1(user.username + new String(password));
- }
+ setCookie(user, password);
// update user attributes from UnixUser
user.accountType = getAccountType();
import com.gitblit.Keys;
import com.gitblit.auth.AuthenticationProvider.UsernamePasswordAuthenticationProvider;
import com.gitblit.models.UserModel;
-import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.ConnectionUtils;
import com.gitblit.utils.StringUtils;
import com.google.gson.Gson;
}
UserModel user = userManager.getUserModel(username);
- if (user == null) // create user object for new authenticated user
+ if (user == null) {
+ // create user object for new authenticated user
user = new UserModel(username.toLowerCase());
+ }
// create a user cookie
- if (StringUtils.isEmpty(user.cookie) && !ArrayUtils.isEmpty(password)) {
- user.cookie = StringUtils.getSHA1(user.username + new String(password));
- }
+ setCookie(user, password);
// update user attributes from Redmine
user.accountType = getAccountType();
import com.gitblit.Keys;
import com.gitblit.auth.AuthenticationProvider.UsernamePasswordAuthenticationProvider;
import com.gitblit.models.UserModel;
-import com.gitblit.utils.ArrayUtils;
-import com.gitblit.utils.StringUtils;
import com.sforce.soap.partner.Connector;
import com.sforce.soap.partner.GetUserInfoResult;
import com.sforce.soap.partner.PartnerConnection;
UserModel user = null;
synchronized (this) {
user = userManager.getUserModel(simpleUsername);
- if (user == null)
+ if (user == null) {
user = new UserModel(simpleUsername);
-
- if (StringUtils.isEmpty(user.cookie)
- && !ArrayUtils.isEmpty(password)) {
- user.cookie = StringUtils.getSHA1(user.username
- + new String(password));
}
+ setCookie(user, password);
setUserAttributes(user, info);
updateUser(user);
import com.gitblit.Keys;
import com.gitblit.auth.AuthenticationProvider.UsernamePasswordAuthenticationProvider;
import com.gitblit.models.UserModel;
-import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.StringUtils;
import com.sun.jna.platform.win32.Win32Exception;
}
UserModel user = userManager.getUserModel(username);
- if (user == null) // create user object for new authenticated user
+ if (user == null) {
+ // create user object for new authenticated user
user = new UserModel(username.toLowerCase());
+ }
// create a user cookie
- if (StringUtils.isEmpty(user.cookie) && !ArrayUtils.isEmpty(password)) {
- user.cookie = StringUtils.getSHA1(user.username + new String(password));
- }
+ setCookie(user, password);
// update user attributes from Windows identity
user.accountType = getAccountType();