Skip to content

Commit fabc56f

Browse files
author
Christoph Jahn
committed
Use wm.server.access:userUpdate to perform password update
1 parent 90aa5ae commit fabc56f

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

WxPassword/code/source/com/softwareag/wx/is/password/PasswordSetter.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
import java.io.IOException;
55
import java.security.SecureRandom;
66

7+
import com.wm.app.b2b.server.Service;
8+
import com.wm.app.b2b.server.ServiceException;
79
import com.wm.app.b2b.server.User;
810
import com.wm.app.b2b.server.UserManager;
11+
import com.wm.data.IData;
12+
import com.wm.data.IDataFactory;
13+
import com.wm.lang.ns.NSName;
914
import com.wm.util.Files;
1015

1116
/**
@@ -50,10 +55,11 @@ public PasswordSetter(File workDir, String userName) {
5055
* Perform the password update, if needed
5156
*
5257
* @throws IOException
58+
* @throws ServiceException
5359
*/
54-
public void execute() throws IOException {
60+
public void execute() throws IOException, ServiceException {
5561
if (isActionNeeded()) {
56-
User user = UserManager.getUser(userName);
62+
// Get password from envVar or random generator
5763
String password = getPassword();
5864

5965
// New random password is written before it gets applied to avoid loosing it by
@@ -63,8 +69,16 @@ public void execute() throws IOException {
6369
System.out.println("New password for user '" + userName + "' can be found at '"
6470
+ fileWithPlainTextPassword().getCanonicalPath() + "'");
6571
}
66-
user.setPassword(password);
67-
user.setPasswordUpdatedOn();
72+
73+
// Perform password update
74+
IData svcInput = IDataFactory.create(new Object[][] { { "username", userName }, { "password", password } });
75+
try {
76+
Service.doInvoke(NSName.create("wm.server.access:userUpdate"), svcInput);
77+
} catch (Exception e) {
78+
e.printStackTrace();
79+
throw new ServiceException(e);
80+
}
81+
6882
}
6983
}
7084

0 commit comments

Comments
 (0)