| | |
| | |
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.utils.ConnectionUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.google.gson.Gson;
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean supportsCookies() {
|
| | | return false;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserModel authenticate(String username, char[] password) {
|
| | | String urlText = this.settings.getString(Keys.realm.redmine.url, "");
|
| | | if (!urlText.endsWith("/")) {
|
| | |
| | | RedmineCurrent current = new Gson().fromJson(jsonString, RedmineCurrent.class);
|
| | | String login = current.user.login;
|
| | |
|
| | | if (username.equalsIgnoreCase(login)) {
|
| | | UserModel userModel = new UserModel(login);
|
| | | userModel.displayName = current.user.firstname + " " + current.user.lastname;
|
| | | userModel.emailAddress = current.user.mail;
|
| | | userModel.canAdmin = true;
|
| | | return userModel;
|
| | | boolean canAdmin = true;
|
| | | // non admin user can not get login name
|
| | | if (StringUtils.isEmpty(login)) {
|
| | | canAdmin = false;
|
| | | login = current.user.mail;
|
| | | }
|
| | |
|
| | | UserModel userModel = new UserModel(login);
|
| | | userModel.canAdmin = canAdmin;
|
| | | userModel.displayName = current.user.firstname + " " + current.user.lastname;
|
| | | userModel.emailAddress = current.user.mail;
|
| | | userModel.cookie = StringUtils.getSHA1(userModel.username + new String(password));
|
| | |
|
| | | return userModel;
|
| | | } catch (IOException e) {
|
| | | logger.error("authenticate", e);
|
| | | }
|