44import java .io .IOException ;
55import java .security .SecureRandom ;
66
7+ import com .wm .app .b2b .server .Service ;
8+ import com .wm .app .b2b .server .ServiceException ;
79import com .wm .app .b2b .server .User ;
810import 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 ;
914import 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