Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
-
d5e63496
by Tony CHEMIT at 2018-03-23T17:41:36Z
7 changed files:
- t3-domain/src/main/java/fr/ird/t3/entities/user/UserDatabase.java
- t3-domain/src/main/java/fr/ird/t3/services/UserService.java
- t3-web/src/main/java/fr/ird/t3/web/actions/admin/AbstractUserDatabaseAction.java
- t3-web/src/main/resources/i18n/t3-web_en_GB.properties
- t3-web/src/main/resources/i18n/t3-web_fr_FR.properties
- t3-web/src/main/webapp/WEB-INF/jsp/admin/databaseConfigurationForm.jsp
- t3-web/src/main/webapp/WEB-INF/jsp/user/selectUserInputDatabase.jsp
Changes:
| ... | ... | @@ -10,12 +10,12 @@ package fr.ird.t3.entities.user; |
| 10 | 10 |
* it under the terms of the GNU Affero General Public License as published by
|
| 11 | 11 |
* the Free Software Foundation, either version 3 of the License, or
|
| 12 | 12 |
* (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU Affero General Public License
|
| 20 | 20 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 21 | 21 |
* #L%
|
| ... | ... | @@ -34,6 +34,8 @@ public class UserDatabase extends AbstractJavaBean implements Idable { |
| 34 | 34 |
|
| 35 | 35 |
protected String login;
|
| 36 | 36 |
|
| 37 |
+ protected String password;
|
|
| 38 |
+ |
|
| 37 | 39 |
protected String id;
|
| 38 | 40 |
|
| 39 | 41 |
public String getUrl() {
|
| ... | ... | @@ -67,4 +69,12 @@ public class UserDatabase extends AbstractJavaBean implements Idable { |
| 67 | 69 |
public void setId(String id) {
|
| 68 | 70 |
this.id = id;
|
| 69 | 71 |
}
|
| 72 |
+ |
|
| 73 |
+ public String getPassword() {
|
|
| 74 |
+ return password;
|
|
| 75 |
+ }
|
|
| 76 |
+ |
|
| 77 |
+ public void setPassword(String password) {
|
|
| 78 |
+ this.password = password;
|
|
| 79 |
+ }
|
|
| 70 | 80 |
}
|
| ... | ... | @@ -8,12 +8,12 @@ |
| 8 | 8 |
* it under the terms of the GNU Affero General Public License as published by
|
| 9 | 9 |
* the Free Software Foundation, either version 3 of the License, or
|
| 10 | 10 |
* (at your option) any later version.
|
| 11 |
- *
|
|
| 11 |
+ *
|
|
| 12 | 12 |
* This program is distributed in the hope that it will be useful,
|
| 13 | 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 | 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 | 15 |
* GNU General Public License for more details.
|
| 16 |
- *
|
|
| 16 |
+ *
|
|
| 17 | 17 |
* You should have received a copy of the GNU Affero General Public License
|
| 18 | 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 19 | 19 |
* #L%
|
| ... | ... | @@ -40,6 +40,10 @@ import java.util.UUID; |
| 40 | 40 |
*/
|
| 41 | 41 |
public class UserService extends T3ServiceSupport implements T3ServiceInjectable {
|
| 42 | 42 |
|
| 43 |
+ private static String encodePassword(String password) {
|
|
| 44 |
+ return StringUtil.encodeMD5(password);
|
|
| 45 |
+ }
|
|
| 46 |
+ |
|
| 43 | 47 |
public Optional<T3User> getUserByLogin(String login) {
|
| 44 | 48 |
return getT3Users().usersStream().whereLogin().isEquals(login).filter().findFirst();
|
| 45 | 49 |
}
|
| ... | ... | @@ -79,7 +83,6 @@ public class UserService extends T3ServiceSupport implements T3ServiceInjectable |
| 79 | 83 |
commit();
|
| 80 | 84 |
}
|
| 81 | 85 |
|
| 82 |
- |
|
| 83 | 86 |
public void deleteUser(String userId) {
|
| 84 | 87 |
T3User user = getUserById(userId);
|
| 85 | 88 |
getT3Users().getUsers().remove(user);
|
| ... | ... | @@ -93,6 +96,7 @@ public class UserService extends T3ServiceSupport implements T3ServiceInjectable |
| 93 | 96 |
.description(dbConfiguration.getDescription())
|
| 94 | 97 |
.login(dbConfiguration.getLogin())
|
| 95 | 98 |
.url(dbConfiguration.getUrl())
|
| 99 |
+ .password(dbConfiguration.getPassword())
|
|
| 96 | 100 |
.build();
|
| 97 | 101 |
user.getInputs().add(dbConfigurationToSave);
|
| 98 | 102 |
dbConfiguration.setId(dbConfigurationToSave.getId());
|
| ... | ... | @@ -101,7 +105,7 @@ public class UserService extends T3ServiceSupport implements T3ServiceInjectable |
| 101 | 105 |
|
| 102 | 106 |
public void updateUserInputDatabase(UserDatabase dbConfiguration) {
|
| 103 | 107 |
UserDatabase dbConfigurationToSave = getUserInputDatabase(dbConfiguration.getId());
|
| 104 |
- updateDatabaseConfiguration(dbConfiguration, dbConfigurationToSave);
|
|
| 108 |
+ dbConfiguration.copy(dbConfigurationToSave);
|
|
| 105 | 109 |
commit();
|
| 106 | 110 |
}
|
| 107 | 111 |
|
| ... | ... | @@ -119,6 +123,7 @@ public class UserService extends T3ServiceSupport implements T3ServiceInjectable |
| 119 | 123 |
.description(dbConfiguration.getDescription())
|
| 120 | 124 |
.login(dbConfiguration.getLogin())
|
| 121 | 125 |
.url(dbConfiguration.getUrl())
|
| 126 |
+ .password(dbConfiguration.getPassword())
|
|
| 122 | 127 |
.build();
|
| 123 | 128 |
user.getOutputs().add(dbConfigurationToSave);
|
| 124 | 129 |
dbConfiguration.setId(dbConfigurationToSave.getId());
|
| ... | ... | @@ -127,7 +132,7 @@ public class UserService extends T3ServiceSupport implements T3ServiceInjectable |
| 127 | 132 |
|
| 128 | 133 |
public void updateUserOutputDatabase(UserDatabase dbConfiguration) {
|
| 129 | 134 |
UserDatabase dbConfigurationToSave = getUserOutputDatabase(dbConfiguration.getId());
|
| 130 |
- updateDatabaseConfiguration(dbConfiguration, dbConfigurationToSave);
|
|
| 135 |
+ dbConfiguration.copy(dbConfigurationToSave);
|
|
| 131 | 136 |
commit();
|
| 132 | 137 |
}
|
| 133 | 138 |
|
| ... | ... | @@ -151,16 +156,6 @@ public class UserService extends T3ServiceSupport implements T3ServiceInjectable |
| 151 | 156 |
return s.equals(user.getPassword());
|
| 152 | 157 |
}
|
| 153 | 158 |
|
| 154 |
- private static String encodePassword(String password) {
|
|
| 155 |
- return StringUtil.encodeMD5(password);
|
|
| 156 |
- }
|
|
| 157 |
- |
|
| 158 |
- private void updateDatabaseConfiguration(UserDatabase dbConfiguration, UserDatabase dbConfigurationToSave) {
|
|
| 159 |
- dbConfigurationToSave.setDescription(dbConfiguration.getDescription());
|
|
| 160 |
- dbConfigurationToSave.setUrl(dbConfiguration.getUrl());
|
|
| 161 |
- dbConfigurationToSave.setLogin(dbConfiguration.getLogin());
|
|
| 162 |
- }
|
|
| 163 |
- |
|
| 164 | 159 |
private void commit() {
|
| 165 | 160 |
getT3Users().save();
|
| 166 | 161 |
}
|
| ... | ... | @@ -108,6 +108,7 @@ public abstract class AbstractUserDatabaseAction extends T3ActionSupport impleme |
| 108 | 108 |
String userId = getUser().getId();
|
| 109 | 109 |
String description = configuration.getDescription();
|
| 110 | 110 |
String login = configuration.getLogin();
|
| 111 |
+ String password = configuration.getPassword();
|
|
| 111 | 112 |
String url = configuration.getUrl();
|
| 112 | 113 |
String id = configuration.getId();
|
| 113 | 114 |
boolean noError = true;
|
| ... | ... | @@ -129,7 +130,11 @@ public abstract class AbstractUserDatabaseAction extends T3ActionSupport impleme |
| 129 | 130 |
addFieldError("databaseConfiguration.login", t("t3.error.required.login"));
|
| 130 | 131 |
noError = false;
|
| 131 | 132 |
}
|
| 132 |
- |
|
| 133 |
+ if (StringUtils.isEmpty(password)) {
|
|
| 134 |
+ // empty user password
|
|
| 135 |
+ addFieldError("databaseConfiguration.password", t("t3.error.required.password"));
|
|
| 136 |
+ noError = false;
|
|
| 137 |
+ }
|
|
| 133 | 138 |
if (noError) {
|
| 134 | 139 |
// check now the configuration does not already exist with same description for this user
|
| 135 | 140 |
T3User t3User = getUserService().getUserById(userId);
|
| ... | ... | @@ -169,6 +174,11 @@ public abstract class AbstractUserDatabaseAction extends T3ActionSupport impleme |
| 169 | 174 |
addFieldError("databaseConfiguration.login", t("t3.error.required.login"));
|
| 170 | 175 |
noError = false;
|
| 171 | 176 |
}
|
| 177 |
+ if (StringUtils.isEmpty(password)) {
|
|
| 178 |
+ // empty user password
|
|
| 179 |
+ addFieldError("databaseConfiguration.password", t("t3.error.required.password"));
|
|
| 180 |
+ noError = false;
|
|
| 181 |
+ }
|
|
| 172 | 182 |
if (noError) {
|
| 173 | 183 |
// check now the configuration does not already exist with same description for this user
|
| 174 | 184 |
T3User t3User = getUserService().getUserById(userId);
|
| 1 |
+t3.common.password=Password
|
|
| 1 | 2 |
t3.action.applyFilter=Apply
|
| 2 | 3 |
t3.action.back.to.configuration.step1=Back to step 1 of configuration
|
| 3 | 4 |
t3.action.back.to.configuration.step2=Back to step 2 of configuration
|
| ... | ... | @@ -9,6 +9,7 @@ t3.action.connectToDatabase=Se connecter à la base |
| 9 | 9 |
t3.action.create=Créer
|
| 10 | 10 |
t3.action.create.parametersProfile=Créer un profile de paramètre
|
| 11 | 11 |
t3.action.create.user=Créer un utilisateur
|
| 12 |
+t3.common.password=Mot de passe
|
|
| 12 | 13 |
t3.action.delete=Supprimer
|
| 13 | 14 |
t3.action.deleteComputedData=Suppression des données calculées
|
| 14 | 15 |
t3.action.deleteTrips=Suppression des marées
|
| ... | ... | @@ -37,16 +37,13 @@ |
| 37 | 37 |
</s:elseif>
|
| 38 | 38 |
|
| 39 | 39 |
<s:if test="databaseEditAction == 'create'">
|
| 40 |
- <s:set name="title"><s:text
|
|
| 41 |
- name="t3.label.admin.databaseconfiguration.create"/></s:set>
|
|
| 40 |
+ <s:set name="title"><s:text name="t3.label.admin.databaseconfiguration.create"/></s:set>
|
|
| 42 | 41 |
</s:if>
|
| 43 | 42 |
<s:elseif test="databaseEditAction =='edit'">
|
| 44 |
- <s:set name="title"><s:text
|
|
| 45 |
- name="t3.label.admin.databaseconfiguration.edit"/></s:set>
|
|
| 43 |
+ <s:set name="title"><s:text name="t3.label.admin.databaseconfiguration.edit"/></s:set>
|
|
| 46 | 44 |
</s:elseif>
|
| 47 | 45 |
<s:elseif test="databaseEditAction == 'delete'">
|
| 48 |
- <s:set name="title"><s:text
|
|
| 49 |
- name="t3.label.admin.databaseconfiguration.delete"/></s:set>
|
|
| 46 |
+ <s:set name="title"><s:text name="t3.label.admin.databaseconfiguration.delete"/></s:set>
|
|
| 50 | 47 |
</s:elseif>
|
| 51 | 48 |
|
| 52 | 49 |
<title><s:property value="#title"/></title>
|
| ... | ... | @@ -65,8 +62,12 @@ |
| 65 | 62 |
<s:hidden name="userEditAction" value="edit"/>
|
| 66 | 63 |
<s:hidden key="user.id" label=""/>
|
| 67 | 64 |
<s:textfield key="databaseConfiguration.url" label="%{getText('t3.common.url')}" size="40" requiredLabel="true"/>
|
| 68 |
- <s:textfield key="databaseConfiguration.description" label="%{getText('t3.common.description')}" size="40" requiredLabel="true"/>
|
|
| 69 |
- <s:textfield key="databaseConfiguration.login" label="%{getText('t3.common.login')}" size="40" requiredLabel="true"/>
|
|
| 65 |
+ <s:textfield key="databaseConfiguration.description" label="%{getText('t3.common.description')}" size="40"
|
|
| 66 |
+ requiredLabel="true"/>
|
|
| 67 |
+ <s:textfield key="databaseConfiguration.login" label="%{getText('t3.common.login')}" size="40"
|
|
| 68 |
+ requiredLabel="true"/>
|
|
| 69 |
+ <s:textfield key="databaseConfiguration.password" label="%{getText('t3.common.password')}" size="40"
|
|
| 70 |
+ requiredLabel="true"/>
|
|
| 70 | 71 |
</fieldset>
|
| 71 | 72 |
<br/>
|
| 72 | 73 |
<s:submit action="%{databaseAction}!doCreate" key="t3.action.create" align="right"/>
|
| ... | ... | @@ -86,8 +87,12 @@ |
| 86 | 87 |
<s:hidden key="user.id" label=""/>
|
| 87 | 88 |
<s:hidden name="databaseConfiguration.id" label=""/>
|
| 88 | 89 |
<s:textfield key="databaseConfiguration.url" label="%{getText('t3.common.url')}" size="40" requiredLabel="true"/>
|
| 89 |
- <s:textfield key="databaseConfiguration.description" label="%{getText('t3.common.description')}" size="40" requiredLabel="true"/>
|
|
| 90 |
- <s:textfield key="databaseConfiguration.login" label="%{getText('t3.common.login')}" size="40" requiredLabel="true"/>
|
|
| 90 |
+ <s:textfield key="databaseConfiguration.description" label="%{getText('t3.common.description')}" size="40"
|
|
| 91 |
+ requiredLabel="true"/>
|
|
| 92 |
+ <s:textfield key="databaseConfiguration.login" label="%{getText('t3.common.login')}" size="40"
|
|
| 93 |
+ requiredLabel="true"/>
|
|
| 94 |
+ <s:textfield key="databaseConfiguration.password" label="%{getText('t3.common.password')}" size="40"
|
|
| 95 |
+ requiredLabel="true"/>
|
|
| 91 | 96 |
</fieldset>
|
| 92 | 97 |
<br/>
|
| 93 | 98 |
<s:submit action="%{databaseAction}!doUpdate" key="t3.action.save" align="right"/>
|
| ... | ... | @@ -105,26 +110,18 @@ |
| 105 | 110 |
<s:hidden key="userEditAction" label="" value="edit"/>
|
| 106 | 111 |
<s:hidden key="user.id" label=""/>
|
| 107 | 112 |
<s:hidden name="databaseConfiguration.id" label=""/>
|
| 108 |
- <s:textfield key="databaseConfiguration.url"
|
|
| 109 |
- label="%{getText('t3.common.url')}"
|
|
| 110 |
- size="40" disabled="true"/>
|
|
| 111 |
- <s:textfield key="databaseConfiguration.description"
|
|
| 112 |
- label="%{getText('t3.common.description')}" size="40"
|
|
| 113 |
- disabled="true"/>
|
|
| 114 |
- <s:textfield key="databaseConfiguration.login"
|
|
| 115 |
- label="%{getText('t3.common.login')}"
|
|
| 116 |
- size="40" disabled="true"/>
|
|
| 113 |
+ <s:textfield key="databaseConfiguration.url" label="%{getText('t3.common.url')}" size="40" disabled="true"/>
|
|
| 114 |
+ <s:textfield key="databaseConfiguration.description" label="%{getText('t3.common.description')}" size="40" disabled="true"/>
|
|
| 115 |
+ <s:textfield key="databaseConfiguration.login" label="%{getText('t3.common.login')}" size="40" disabled="true"/>
|
|
| 117 | 116 |
</fieldset>
|
| 118 | 117 |
<br/>
|
| 119 |
- <s:submit action="%{databaseAction}!doDelete" key="t3.action.delete"
|
|
| 120 |
- align="right"/>
|
|
| 118 |
+ <s:submit action="%{databaseAction}!doDelete" key="t3.action.delete" align="right"/>
|
|
| 121 | 119 |
</s:form>
|
| 122 | 120 |
</s:elseif>
|
| 123 | 121 |
<s:form method="post" namespace="/user">
|
| 124 | 122 |
<s:hidden name="userEditAction" value="edit"/>
|
| 125 | 123 |
<s:hidden key="user.id" label=""/>
|
| 126 |
- <s:submit action="userForm!input" key="t3.label.admin.backToUser"
|
|
| 127 |
- align="right"/>
|
|
| 124 |
+ <s:submit action="userForm!input" key="t3.label.admin.backToUser" align="right"/>
|
|
| 128 | 125 |
</s:form>
|
| 129 | 126 |
|
| 130 | 127 |
|
| ... | ... | @@ -35,7 +35,7 @@ |
| 35 | 35 |
var database = data.database;
|
| 36 | 36 |
$('[name="database.url"]').attr('value', database.url ? database.url : '');
|
| 37 | 37 |
$('[name="database.login"]').attr('value', database.login ? database.login : '');
|
| 38 |
- $('[name="database.password"]').attr('value', "");
|
|
| 38 |
+ $('[name="database.password"]').attr('value', database.password ? database.password : '');
|
|
| 39 | 39 |
}
|
| 40 | 40 |
);
|
| 41 | 41 |
});
|