|
1 | 1 | package hudson.plugins.redmine;
|
2 | 2 |
|
3 | 3 | import hudson.Extension;
|
| 4 | +import hudson.Util; |
4 | 5 | import hudson.model.Descriptor;
|
5 | 6 | import hudson.plugins.redmine.dao.*;
|
6 | 7 | import hudson.plugins.redmine.util.CipherUtil;
|
7 | 8 | import hudson.plugins.redmine.util.Constants;
|
8 | 9 | import hudson.security.AbstractPasswordBasedSecurityRealm;
|
9 | 10 | import hudson.security.GroupDetails;
|
10 | 11 | import hudson.security.SecurityRealm;
|
| 12 | +import hudson.util.Secret; |
11 | 13 |
|
12 | 14 | import java.util.HashSet;
|
13 | 15 | import java.util.Set;
|
@@ -47,7 +49,7 @@ public class RedmineSecurityRealm extends AbstractPasswordBasedSecurityRealm {
|
47 | 49 | private final String dbUserName;
|
48 | 50 |
|
49 | 51 | /** Database Password */
|
50 |
| - private final String dbPassword; |
| 52 | + private final Secret dbPassword; |
51 | 53 |
|
52 | 54 | /** Redmine Version */
|
53 | 55 | private final String version;
|
@@ -92,7 +94,7 @@ public RedmineSecurityRealm(String dbms, String dbServer, String databaseName, S
|
92 | 94 | this.port = port;
|
93 | 95 |
|
94 | 96 | this.dbUserName = dbUserName;
|
95 |
| - this.dbPassword = dbPassword; |
| 97 | + this.dbPassword = Secret.fromString(Util.fixEmptyAndTrim(dbPassword)); |
96 | 98 | this.version = StringUtils.isBlank(version) ? Constants.VERSION_1_2_0 : version;
|
97 | 99 |
|
98 | 100 | this.loginTable = StringUtils.isBlank(loginTable) ? Constants.DEFAULT_LOGIN_TABLE : loginTable;
|
@@ -152,7 +154,7 @@ protected UserDetails authenticate(String username, String password) throws Auth
|
152 | 154 | LOGGER.info("DB Port : " + this.port);
|
153 | 155 | LOGGER.info("Database Name : " + this.databaseName);
|
154 | 156 |
|
155 |
| - dao.open(this.dbServer, this.port, this.databaseName, this.dbUserName, this.dbPassword); |
| 157 | + dao.open(this.dbServer, this.port, this.databaseName, this.dbUserName, this.dbPassword.getPlainText()); |
156 | 158 |
|
157 | 159 | if (!dao.isTable(this.loginTable))
|
158 | 160 | throw new RedmineAuthenticationException("RedmineSecurity: Invalid Login Table");
|
@@ -200,7 +202,7 @@ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundEx
|
200 | 202 | try {
|
201 | 203 | dao = createAuthDao(this.dbms);
|
202 | 204 |
|
203 |
| - dao.open(this.dbServer, this.port, this.databaseName, this.dbUserName, this.dbPassword); |
| 205 | + dao.open(this.dbServer, this.port, this.databaseName, this.dbUserName, this.dbPassword.getPlainText()); |
204 | 206 |
|
205 | 207 | if (!dao.isTable(this.loginTable))
|
206 | 208 | throw new RedmineAuthenticationException("RedmineSecurity: Invalid Login Table");
|
@@ -301,7 +303,7 @@ public String getDbUserName() {
|
301 | 303 | *
|
302 | 304 | * @return
|
303 | 305 | */
|
304 |
| - public String getDbPassword() { |
| 306 | + public Secret getDbPassword() { |
305 | 307 | return dbPassword;
|
306 | 308 | }
|
307 | 309 |
|
|
0 commit comments