Statistics
| Branch: | Revision:

m2u-upass-core / src / my / com / upass / UPassControllerV2.java @ 31:41feb70979b9

History | View | Annotate | Download (40.5 KB)

1 0:02300db8682b hadi
/**
2
 * Copyright (M) 2010 Penril Datability (M) Sdn Bhd All rights reserved.
3
 *
4
 * This software is copyrighted. Under the copyright laws, this software
5
 * may not be copied, in whole or in part, without prior written consent
6
 * of Penril Datability (M) Sdn Bhd or its assignees. This software is
7
 * provided under the terms of a license between Penril Datability (M)
8
 * Sdn Bhd and the recipient, and its use is subject to the terms of that
9
 * license.
10
 */
11
package my.com.upass;
12
13
import java.text.ParseException;
14
import java.text.SimpleDateFormat;
15
import java.util.Date;
16
import java.util.HashMap;
17
18
import my.com.upass.factory.UPassFactory;
19
import my.com.upass.services.ActivateUserService;
20
import my.com.upass.services.AssignTokenService;
21
import my.com.upass.services.ChangeStaticPasswordService;
22
import my.com.upass.services.CheckPasswordReusedService;
23
import my.com.upass.services.DeleteTokenService;
24
import my.com.upass.services.DisableTacService;
25
import my.com.upass.services.DisableTokenService;
26
import my.com.upass.services.GenerateSecurityCodeService;
27
import my.com.upass.services.GenerateTacService;
28
import my.com.upass.services.LoadTokenService;
29
import my.com.upass.services.LockUserService;
30
import my.com.upass.services.QueryInfoService;
31
import my.com.upass.services.ResetTacService;
32
import my.com.upass.services.ResetTokenService;
33
import my.com.upass.services.SynchronizeTokenService;
34
import my.com.upass.services.VerifyPasswordComplexityService;
35
import my.com.upass.services.VerifySecurityCodeService;
36
import my.com.upass.services.VerifyTacService;
37
import my.com.upass.services.VerifyTokenService;
38
import my.com.upass.services.DeleteUserService;
39
40
41
/**
42
 * PROGRAMMER: Danniell
43
 * CHANGE-NO:
44
 * TASK-NO:
45
 * DATE CREATED: Oct 8, 2011
46
 * TAG AS:
47
 * REASON(S):
48
 * MODIFICATION:
49
 */
50
51
/**
52
 * Data Access Object version of UPASS Controller
53
 */
54
/**
55
 * @author Enson
56
 *
57
 */
58 23:1281bdc0fb8f mohd
public class UPassControllerV2 extends MinimalUPassControllerV2
59 0:02300db8682b hadi
{
60
        private ChangeStaticPasswordService changeStaticPasswordService = new ChangeStaticPasswordService(this);
61
        private CheckPasswordReusedService checkPasswordReusedService = new CheckPasswordReusedService(this);
62
        private GenerateTacService generateTacService = new GenerateTacService(this);
63
        private VerifyTacService verifyTacService = new VerifyTacService(this);
64
        private ResetTacService resetTacService = new ResetTacService(this);
65
        private GenerateSecurityCodeService generateSecurityCodeService = new GenerateSecurityCodeService(this);
66
        private VerifySecurityCodeService verifySecurityCodeService = new VerifySecurityCodeService(this);
67
        private DisableTacService disableTacService = new DisableTacService(this);
68
        private ActivateUserService activateUserService = new ActivateUserService();
69
        private QueryInfoService queryInfoService = new QueryInfoService();
70
        private LockUserService lockUserService = new LockUserService();
71
        private VerifyTokenService verifyTokenService = new VerifyTokenService();
72
        private LoadTokenService loadTokenService = new LoadTokenService();
73
        private ResetTokenService resetTokenService = new ResetTokenService();
74
        private DeleteTokenService deleteTokenService = new DeleteTokenService();
75
        private AssignTokenService assignTokenService = new AssignTokenService();
76
        private DisableTokenService disableTokenService = new DisableTokenService();
77
        private SynchronizeTokenService synchronizeTokenService = new SynchronizeTokenService();
78
        private VerifyPasswordComplexityService verifyPasswordComplexityService = new VerifyPasswordComplexityService(this);
79
80 23:1281bdc0fb8f mohd
        private DeleteUserService DeleteUserService = new DeleteUserService();
81 0:02300db8682b hadi
82
        public UPassControllerV2()
83
        {
84
                initializeConfigurations();
85
        }
86
87
        // ////////////////////////////////////////////////////////////////////////////////////////
88
        // Static Password Methods
89
        // /////////////////////////////////////////////////////////////////////////////////////////
90
        /**
91
         * This method verify static password generated using SP_ChangeStaticPassword()
92
         * and also check for user dormant status
93
         *
94
         * @param userAlias
95
         * @param password
96
         * @return ERR_code defined in the Constants.<br/>
97
         *         ERR_SUCCESS<br/>
98
         *         ERR_SYSTEM_NOT_READY<br/>
99
         *         ERR_USERALIAS_NOT_FOUND <br/>
100
         *         ERR_INVALID_STATE - user not active or temporary suspended.<br/>
101
         *         ERR_APP_SERV_NOT_PERMITTED - for operation not allowed for the user type.<br/>
102
         *         ERR_EXCEED_MAX_TRIES - used ModifyUser to reset password.<br/>
103
         *         ERR_INVALID_CREDENTIAL<br/>
104
         *         ERR_PASSWD_EXPIRED - password is valid but expired, suggest to change new password.<br/>
105
         */
106
        public int SP_Login(String userAlias, String password)
107
        {
108
                int rc = verifyStaticPasswordService.login(userAlias, password, false, 0);
109
                logger.info("SP_Login - user alias: [" + userAlias + "] Return: " + rc);
110
                return rc;
111
        }
112
113
        /**
114
         * This method generate static password and to be using SP_VerifyStaticPassword()
115
         *
116
         * @param userAlias
117
         * @param newPassword
118
         * @param oldPassword
119
         * @return ERR_code defined in the Constants<br/>
120
         *         ERR_SUCCESS<br/>
121
         *         ERR_SYSTEM_NOT_READY<br/>
122
         *         ERR_USERALIAS_NOT_FOUND<br/>
123
         *         ERR_INVALID_STATE - user not active or temporary suspended.<br/>
124
         *         ERR_APP_SERV_NOT_PERMITTED - for operation not allowed for the user type.<br/>
125
         *         ERR_EXCEED_MAX_TRIES - used ModifyUser to reset password.<br/>
126
         *         ERR_INVALID_CREDENTIAL<br/>
127
         *         ERR_REUSED_PASSWD - reuse previous generated password.<br/>
128
         */
129
        public int SP_ChangeStaticPassword(String userAlias, String newPassword, String oldPassword)
130
        {
131
                int rc = changeStaticPasswordService.changeStaticPassword(userAlias, newPassword, oldPassword, true);
132
                logger.info("SP_ChangeStaticPassword - user alias: [" + userAlias + "] Return: " + rc);
133
                return rc;
134
        }
135
136
        public int SP_ForceChangeStaticPassword(String userAlias, String newPassword, String oldPassword)
137
        {
138
                int rc = changeStaticPasswordService.changeStaticPassword(userAlias, newPassword, oldPassword, false);
139
                logger.info("SP_ChangeStaticPassword - user alias: [" + userAlias + "] Return: " + rc);
140
                return rc;
141
        }
142
143
        public int UA_CheckPasswordReused(String userAlias, String password)
144
        {
145
                int rc = checkPasswordReusedService.CheckPasswordReused(userAlias, password);
146
                logger.info("UA_CheckPasswordReused - user alias: [" + userAlias + "] Return: " + rc);
147
                return rc;
148
        }
149
150
        // /////////////////////////////////////////////////////////////////////////////////////////
151
        // TAC Methods ...
152
        // /////////////////////////////////////////////////////////////////////////////////////////
153
154
        /**
155
         * This method to Generate 6-digit TAC.
156
         *
157
         * @param userAlias
158
         * @param appId
159
         *            TODO
160
         * @return 6-digit TAC or Error code with prefix *** <br/>
161
         *         ***98 ERR_SYSTEM_NOT_READY<br/>
162
         *         ***6 ERR_USERALIAS_NOT_FOUND<br/>
163
         *         ***12 ERR_TAC_ALREADY_EXIST - Repeated request within allowed period<br/>
164
         */
165
        public String GenerateTAC(String userAlias, int appId) {
166
167
                String tac = generateTacService.generateTAC(userAlias, null, null, appId);
168
                logger.info(userAlias + " Return=" + tac.substring(2));
169
                return tac;
170
        }
171
172
        /**
173
         * This method to Generate 6-digit TAC with SessionID verification.
174
         *
175
         * @param userAlias
176
         * @param sessionID
177
         *            16-Characters SessionID
178
         * @param appId
179
         *            TODO
180
         * @return 6-digit TAC or Error code with prefix *** <br/>
181
         *         ***98 ERR_SYSTEM_NOT_READY<br/>
182
         *         ***6 ERR_USERALIAS_NOT_FOUND<br/>
183
         *         ***12 ERR_TAC_ALREADY_EXIST - Repeated request within allowed period<br/>
184
         */
185
        public String GenerateTAC(String userAlias, String sessionID, int appId) {
186
187
                String tac = generateTacService.generateTAC(userAlias, sessionID, null, appId);
188
                logger.info(userAlias + " SessionID=" + sessionID + " Return=" + tac.substring(2));
189
                return tac;
190
        }
191
192
        /**
193
         * This method to Generate 6-digit TAC with SessionID verification.
194
         *
195
         * @param userAlias
196
         * @param sessionID
197
         *            16-Characters SessionID
198
         * @param nonce
199
         *            Additional nonce value
200
         * @param appId
201
         *            TODO
202
         * @return 6-digit TAC or Error code with prefix *** <br/>
203
         *         ***98 ERR_SYSTEM_NOT_READY<br/>
204
         *         ***6 ERR_USERALIAS_NOT_FOUND<br/>
205
         *         ***12 ERR_TAC_ALREADY_EXIST - Repeated request within allowed period<br/>
206
         */
207
        public String GenerateTAC(String userAlias, String sessionID, String nonce, int appId) {
208
209
                String tac = generateTacService.generateTAC(userAlias, sessionID, nonce, appId);
210
                logger.info(userAlias + " SessionID=" + sessionID + " Return=" + tac.substring(2));
211
                return tac;
212
        }
213
214
        /**
215
         * This method to verify 6-digit TAC generated by GenerateTAC()
216
         *
217
         * @param userAlias
218
         * @param inTac
219
         *            User inputs TAC
220
         * @param appId
221
         *            TODO
222
         * @return ERR_code defined in the Constants<br/>
223
         *         ERR_SUCCESS<br/>
224
         *         ERR_SYSTEM_NOT_READY<br/>
225
         *         ERR_USERALIAS_NOT_FOUND<br/>
226
         *         ERR_INVALID_STATE - Verify method call before generation; TAC disabled.<br/>
227
         *         ERR_EXCEED_MAX_TRIES<br/>
228
         *         ERR_INVALID_CREDENTIAL<br/>
229
         *         ERR_PASSWD_EXPIRED - TAC expired.<br/>
230
         */
231
        public int VerifyTAC(String userAlias, String inTac, int appId) {
232
233
                int rc = verifyTacService.verifyTAC(userAlias, inTac, null, appId);
234
                logger.info("VerifyTAC - user alias: [" + userAlias + "] Return: " + rc);
235
                return rc;
236
        }
237
238
        /**
239
         * This method to verify 6-digit TAC generated by GenerateTAC() with SessionID verification
240
         *
241
         * @param userAlias
242
         * @param inTac
243
         *            User inputs TAC
244
         * @param sessionID
245
         *            16-Characters SessionID
246
         * @param appId
247
         *            TODO
248
         * @return ERR_code defined in the Constants<br/>
249
         *         ERR_SUCCESS<br/>
250
         *         ERR_SYSTEM_NOT_READY<br/>
251
         *         ERR_USERALIAS_NOT_FOUND<br/>
252
         *         ERR_INVALID_STATE - Verify method call before generation; TAC disabled.<br/>
253
         *         ERR_EXCEED_MAX_TRIES<br/>
254
         *         ERR_INVALID_CREDENTIAL<br/>
255
         *         ERR_PASSWD_EXPIRED - TAC expired.<br/>
256
         *         ERR_INVALID_SESSION<br/>
257
         */
258
        public int VerifyTAC(String userAlias, String inTac, String sessionID, int appId) {
259
260
                return VerifyTAC(userAlias, inTac, sessionID, null, appId);
261
        }
262
263
        /**
264
         * This method to verify 6-digit TAC generated by GenerateTAC() with SessionID verification
265
         *
266
         * @param userAlias
267
         * @param inTac
268
         *            User inputs TAC
269
         * @param sessionID
270
         *            16-Characters SessionID
271
         * @param nonce
272
         *            Additional nonce value
273
         * @param appId
274
         *            TODO
275
         * @return ERR_code defined in the Constants<br/>
276
         *         ERR_SUCCESS<br/>
277
         *         ERR_SYSTEM_NOT_READY<br/>
278
         *         ERR_USERALIAS_NOT_FOUND<br/>
279
         *         ERR_INVALID_STATE - Verify method call before generation; TAC disabled.<br/>
280
         *         ERR_EXCEED_MAX_TRIES<br/>
281
         *         ERR_INVALID_CREDENTIAL<br/>
282
         *         ERR_PASSWD_EXPIRED - TAC expired.<br/>
283
         *         ERR_INVALID_SESSION<br/>
284
         */
285
        public int VerifyTAC(String userAlias, String inTac, String sessionID, String nonce, int appId) {
286
287
                int rc = verifyTacService.verifyTAC(userAlias, inTac, sessionID, nonce, appId);
288
                logger.info("VerifyTAC - user alias: [" + userAlias + "] SessID: [" + sessionID + "] Return: " + rc);
289
                return rc;
290
        }
291
292
        /**
293
         * This method is to reset Error Count to Zero and set state to PASSWD_STATUS_ENABLE
294
         *
295
         * @param adminUserAlias
296
         * @param adminUserPassword
297
         * @param userAlias
298
         * @return ERR_code defined in the Constants<br/>
299
         *         ERR_SUCCESS<br/>
300
         *         ERR_SYSTEM_NOT_READY<br/>
301
         *         ERR_USERALIAS_NOT_FOUND <br/>
302
         *         ERR_INVALID_STATE - admin not active or temporary suspended.<br/>
303
         *         ERR_APP_SERV_NOT_PERMITTED - for operation not allowed for the user type.<br/>
304
         *         ERR_EXCEED_MAX_TRIES<br/>
305
         *         ERR_INVALID_CREDENTIAL<br/>
306
         *         ERR_UNKNOWN<br/>
307
         */
308
        public int ResetTAC(String adminUserAlias, String adminUserPassword, String userAlias) {
309
310
                int rc = verifyStaticPasswordService.verifyStaticPassword(
311
                                adminUserAlias, adminUserPassword, true, Constants.UTYPE_STATE_ADMIN);
312
313
                if (rc != Constants.ERR_SUCCESS) {
314
                        return rc;
315
                }
316
                rc = resetTacService.resetTAC(userAlias);
317
                logger.info("ResetTAC - user alias: [" + userAlias + "] Return: " + rc);
318
                return rc;
319
        }
320
321
        /**
322
         * This method is to set state to PASSWD_STATUS_DISABLE
323
         *
324
         * @param adminUserAlias
325
         * @param adminUserPassword
326
         * @param userAlias
327
         * @return ERR_code defined in the Constants<br/>
328
         *         ERR_SUCCESS<br/>
329
         *         ERR_SYSTEM_NOT_READY<br/>
330
         *         ERR_USERALIAS_NOT_FOUND <br/>
331
         *         ERR_INVALID_STATE - admin not active or temporary suspended.<br/>
332
         *         ERR_APP_SERV_NOT_PERMITTED - for operation not allowed for the user type.<br/>
333
         *         ERR_EXCEED_MAX_TRIES<br/>
334
         *         ERR_INVALID_CREDENTIAL<br/>
335
         *         ERR_UNKNOWN<br/>
336
         */
337
        public int DisableTAC(String adminUserAlias, String adminUserPassword, String userAlias) {
338
339
                int rc = verifyStaticPasswordService.verifyStaticPassword(
340
                                adminUserAlias, adminUserPassword, true, Constants.UTYPE_STATE_ADMIN);
341
342
                if (rc != Constants.ERR_SUCCESS) {
343
                        return rc;
344
                }
345
                rc = disableTacService.disableTAC(userAlias);
346
                logger.info("DisableTAC - user alias: [" + userAlias + "] Return: " + rc);
347
                return rc;
348
        }
349
350
        // /////////////////////////////////////////////////////////////////////////////////////////
351
        // User Administration methods.
352
        // /////////////////////////////////////////////////////////////////////////////////////////
353
354
        /**
355
         * This method to modify admin users to the system
356
         *
357
         * @param rootAlias
358
         * @param rootPassword
359
         * @param adminUserAlias
360
         * @param adminDesc
361
         *            - can be null - Null denotes no description will be modified.
362
         * @param adminUserPassword
363
         *            - can be null - Null denotes no password will be modified.
364
         * @return ERR_code defined in the Constants.<br/>
365
         *         ERR_SUCCESS<br/>
366
         *         ERR_SYSTEM_NOT_READY<br/>
367
         *         ERR_USERALIAS_NOT_FOUND <br/>
368
         *         ERR_INVALID_STATE - root not active or temporary suspended.<br/>
369
         *         ERR_APP_SERV_NOT_PERMITTED - for operation not allowed for the user type.<br/>
370
         *         ERR_EXCEED_MAX_TRIES<br/>
371
         *         ERR_INVALID_CREDENTIAL<br/>
372
         *         ERR_INVALID_INPUT - internal error.<br/>
373
         *         ERR_USERALIAS_NOT_FOUND<br/>
374
         *         ERR_REUSED_PASSWD - the password entered was used previously.<br/>
375
         *         ERR_PASSWD_WEAK - the password entered is too weak.<br/>
376
         *         ERR_INVALID_USERALIAS - User alias does not match with defined pattern <br/>
377
         *         ERR_PASSWORD_SAMEAS_USERALIAS - password is same is user name error <br/>
378
         */
379
        public int AD_ModifyUser(String rootAlias, String rootPassword,
380
                        String adminUserAlias, String adminDesc, String adminUserPassword)
381
        {
382
                // check if password is similar to user alias
383
                if (rootAlias.equalsIgnoreCase(rootPassword)) {
384
                        return Constants.ERR_PASSWORD_SAMEAS_USERALIAS;
385
                }
386
387
                int rc = verifyStaticPasswordService.verifyStaticPassword(
388
                                rootAlias, rootPassword, true, Constants.UTYPE_STATE_ROOT);
389
390
                if (rc != Constants.ERR_SUCCESS)
391
                {
392
                        return rc;
393
                }
394
395
                rc = modifyUserService.modifyUser(adminUserAlias,
396
                                Constants.UTYPE_STATE_ADMIN, adminDesc, adminUserPassword,
397
                                Constants.UID_STATE_ACTIVE);
398
399
                logger.info("AD_ModifyUser - admin user alias: [" + adminUserAlias
400
                                + "] Return: " + rc);
401
402
                return rc;
403
        }
404
405
        /**
406
         * This method to change online users state to ACTIVE status.
407
         *
408
         * @param adminUserAlias
409
         * @param adminUserPassword
410
         * @param userAlias
411
         * @return ERR_code defined in the Constants.<br/>
412
         *         ERR_SUCCESS<br/>
413
         *         ERR_SYSTEM_NOT_READY<br/>
414
         *         ERR_USERALIAS_NOT_FOUND <br/>
415
         *         ERR_INVALID_STATE - admin not active or temporary suspended.<br/>
416
         *         ERR_APP_SERV_NOT_PERMITTED - for operation not allowed for the user type.<br/>
417
         *         ERR_EXCEED_MAX_TRIES<br/>
418
         *         ERR_INVALID_CREDENTIAL<br/>
419
         *         ERR_USERALIAS_NOT_FOUND<br/>
420
         *         ERR_UNKNOWN <br/>
421
         */
422
        public int UA_ActivateUser(String adminUserAlias, String adminUserPassword, String userAlias)
423
        {
424
                int rc = verifyStaticPasswordService.verifyStaticPassword(
425
                                adminUserAlias, adminUserPassword, true,
426
                                Constants.UTYPE_STATE_ADMIN);
427
428
                if (rc != Constants.ERR_SUCCESS)
429
                {
430
                        return rc;
431
                }
432
433
                rc = activateUserService.activateUser(userAlias);
434
435
                logger.info("UA_ActivateUser - user alias: [" + userAlias
436
                                + "] Return: " + rc);
437
438
                return rc;
439
        }
440
441
        /**
442
         * This method to change admin users state to ACTIVE status.
443
         *
444
         * @param rootAlias
445
         * @param rootPassword
446
         * @param adminUserAlias
447
         * @return ERR_code defined in the Constants.<br/>
448
         *         ERR_SUCCESS<br/>
449
         *         ERR_SYSTEM_NOT_READY<br/>
450
         *         ERR_USERALIAS_NOT_FOUND <br/>
451
         *         ERR_INVALID_STATE - root not active or temporary suspended.<br/>
452
         *         ERR_APP_SERV_NOT_PERMITTED - for operation not allowed for the user type.<br/>
453
         *         ERR_EXCEED_MAX_TRIES<br/>
454
         *         ERR_INVALID_CREDENTIAL<br/>
455
         *         ERR_USERALIAS_NOT_FOUND<br/>
456
         *         ERR_UNKNOWN<br/>
457
         */
458
        public int AD_ActivateUser(String rootAlias, String rootPassword,
459
                        String adminUserAlias)
460
        {
461
                int rc = verifyStaticPasswordService.verifyStaticPassword(
462
                                rootAlias, rootPassword, true, Constants.UTYPE_STATE_ROOT);
463
464
                if (rc != Constants.ERR_SUCCESS)
465
                {
466
                        return rc;
467
                }
468
469
                rc = activateUserService.activateUser(adminUserAlias);
470
471
                logger.info("AD_ActivateUser - admin user alias: [" + adminUserAlias
472
                                + "] Return: " + rc);
473
474
                return rc;
475
        }
476
477
        /**
478
         * This method is to check whether the user alias exist in the system.
479
         *
480
         * @param userAlias
481
         * @return ERR_code defined in the Constants.<br/>
482
         *         ERR_SUCCESS 0 - found<br/>
483
         *         ERR_USERALIAS_NOT_FOUND 6<br/>
484
         *         ERR_SYSTEM_NOT_READY 98<br/>
485
         */
486
        public int UA_IsUserExist(String userAlias)
487
        {
488
                return queryInfoService.checkUserExistence(userAlias);
489
        }
490
491
        /**
492
         * This method is to get user type. Valid return is [0-root user | 1-admin user | 2-Ordinary User]
493
         *
494
         * @param userAlias
495
         * @return <br/>
496
         *         UTYPE_STATE_ROOT = 0<br/>
497
         *         UTYPE_STATE_ADMIN = 1<br/>
498
         *         UTYPE_STATE_USER = 2<br/>
499
         *         ERR_USERALIAS_NOT_FOUND = 6<br/>
500
         *         ERR_SYSTEM_NOT_READY = 98<br/>
501
         */
502
503
        public int UA_GetUserType(String userAlias)
504
        {
505
                return queryInfoService.getUserType(userAlias);
506
        }
507
508
        /**
509
         * This method is to get attributes associated to user. Return type is HashMap<String,String>
510
         * The object keys is as below:<br/>
511
         * RC - Return Code [always present]<br/>
512
         * RT - Return Code in Text [always present]<br/>
513
         * <br/>
514
         * The following data present only with the return is ERR_SUCCESS<br/>
515
         * Type - User Type [0-Root User] [1-Admin User] [2-Ordinary User][9-SysControl]<br/>
516
         * State - User State [0-Active] [1-Temporary Locked] [2-Locked] [3-Inactive] [4-Deleted]<br/>
517
         * Description - User Description<br/>
518
         * UseCount - Number of time the record being access<br/>
519
         * DateCreated - Created date<br/>
520
         * DateLastUsed - Last access of the record<br/>
521
         * DateLastActivated - Last activation of the record<br/>
522
         * DateLastLocked - Last date the user being locked<br/>
523
         * DateLockedFrom - last date the user being locked from<br/>
524
         * DateLockedTo - last date the user being locked to<br/>
525
         *
526
         * @param userAlias
527
         * @return HashMap
528
         */
529
        public HashMap<String, String> UA_GetUserData(String userAlias)
530
        {
531
                return queryInfoService.getUserData(userAlias);
532
        }
533
534
        /**
535
         * This method is to get attributes associated to password. Return type is HashMap<String,String>
536
         * The object keys is as below:<br/>
537
         * RC - Return Code [always present]<br/>
538
         * RT - Return Code in Text [always present]<br/>
539
         * <br/>
540
         * The following data present only with the return is ERR_SUCCESS<br/>
541
         * State - Password State [0-Enable] [1-Disable] [2-OneTime Use]<br/>
542
         * ExpiryStatus - Expiry Status [0-Will Expired][1-Never Expired]
543
         * UseCount - Number of time the record being access<br/>
544
         * ErrorCount - Number of time the password verified error<br/>
545
         * DateCreated - Created date<br/>
546
         * DateFirstUsed - First access of the password<br/>
547
         * DateLastUsed - Last access of the password<br/>
548
         * DatePasswdExpired - Expiry date of the password<br/>
549
         *
550
         * @param userAlias
551
         * @return HashMap
552
         */
553
        public HashMap<String, String> QueryPassword(String userAlias)
554
        {
555
                return queryInfoService.queryPassword(userAlias);
556
        }
557
558
        /**
559
         * This method is to get attributes associated to TAC. Return type is HashMap<String,String>
560
         * The object keys is as below:<br/>
561
         * RC - Return Code [always present]<br/>
562
         * RT - Return Code in Text [always present]<br/>
563
         * <br/>
564
         * The following data present only with the return is ERR_SUCCESS<br/>
565
         * State - User State [0-Enable] [1-Disable]<br/>
566
         * UseCount - Number of time the record being access<br/>
567
         * ErrorCount - Number of time the TAC verified error<br/>
568
         * DateCreated - TAC Created date<br/>
569
         * DateFirstUsed - First access of the TAC<br/>
570
         * DateLastUsed - Last access of the TAC<br/>
571
         *
572
         * @param userAlias
573
         * @param appId TODO
574
         * @return HashMap
575
         */
576
        public HashMap<String, String> QueryTAC(String userAlias, int appId)
577
        {
578
                return queryInfoService.queryTAC(userAlias, appId);
579
        }
580
581
        /**
582
         * This method is to change online user state to LOCKED status.
583
         *
584
         * @param adminUserAlias
585
         * @param adminUserPassword
586
         * @param userAlias
587
         * @return ERR_code defined in the Constants.<br/>
588
         *         ERR_SUCCESS<br/>
589
         *         ERR_SYSTEM_NOT_READY<br/>
590
         *         ERR_USERALIAS_NOT_FOUND <br/>
591
         *         ERR_INVALID_STATE - admin not active or temporary suspended.<br/>
592
         *         ERR_APP_SERV_NOT_PERMITTED - for operation not allowed for the user type.<br/>
593
         *         ERR_EXCEED_MAX_TRIES<br/>
594
         *         ERR_INVALID_CREDENTIAL<br/>
595
         *         ERR_UNKNOWN<br/>
596
         */
597
        public int UA_LockUser(String adminUserAlias, String adminUserPassword,
598
                        String userAlias)
599
        {
600
                int rc = verifyStaticPasswordService.verifyStaticPassword(
601
                                adminUserAlias, adminUserPassword, true,
602
                                Constants.UTYPE_STATE_ADMIN);
603
604
                if (rc != Constants.ERR_SUCCESS)
605
                {
606
                        return rc;
607
                }
608
609
                rc = lockUserService.lockUser(userAlias);
610
611
                logger.info("UA_LockUser - user alias: [" + userAlias + "] Return:"
612
                                + rc);
613
614
                return rc;
615
        }
616
617
        /**
618
         * This method is to change admin user state to LOCKED status.
619
         *
620
         * @param rootAlias
621
         * @param rootPassword
622
         * @param adminUserAlias
623
         * @return ERR_code defined in the Constants.<br/>
624
         *         ERR_SUCCESS<br/>
625
         *         ERR_SYSTEM_NOT_READY<br/>
626
         *         ERR_USERALIAS_NOT_FOUND <br/>
627
         *         ERR_INVALID_STATE - root not active or temporary suspended.<br/>
628
         *         ERR_APP_SERV_NOT_PERMITTED - for operation not allowed for the user type.<br/>
629
         *         ERR_EXCEED_MAX_TRIES<br/>
630
         *         ERR_INVALID_CREDENTIAL<br/>
631
         *         ERR_UNKNOWN<br/>
632
         */
633
        public int AD_LockUser(String rootAlias, String rootPassword,
634
                        String adminUserAlias)
635
        {
636
                int rc = verifyStaticPasswordService.verifyStaticPassword(
637
                                rootAlias, rootPassword, true, Constants.UTYPE_STATE_ROOT);
638
639
                if (rc != Constants.ERR_SUCCESS)
640
                {
641
                        return rc;
642
                }
643
644
                rc = lockUserService.lockUser(adminUserAlias);
645
646
                logger.info("AD_LockUser - admin user alias: [" + adminUserAlias
647
                                + "] Return: " + rc);
648
649
                return rc;
650
        }
651
652
        /**
653
         * This method is to suspend online user from when for how many Minutes
654
         *
655
         * @param adminUserAlias
656
         * @param adminUserPassword
657
         * @param userAlias
658
         * @param fromDate
659
         *            - from when
660
         * @param nMinutes
661
         *            - Suspend for how many minutes
662
         * @return ERR_code defined in the Constants.<br/>
663
         *         ERR_SUCCESS<br/>
664
         *         ERR_SYSTEM_NOT_READY<br/>
665
         *         ERR_USERALIAS_NOT_FOUND <br/>
666
         *         ERR_INVALID_STATE - admin not active or temporary suspended.<br/>
667
         *         ERR_APP_SERV_NOT_PERMITTED - for operation not allowed for the user type.<br/>
668
         *         ERR_EXCEED_MAX_TRIES<br/>
669
         *         ERR_INVALID_CREDENTIAL<br/>
670
         *         ERR_UNKNOWN<br/>
671
         */
672
        public int UA_SuspendUser(String adminUserAlias, String adminUserPassword,
673
                        String userAlias, String strFromDate, int nMinutes)
674
        {
675
                Date fromDate = StringToDate(strFromDate);
676
                int rc = verifyStaticPasswordService.verifyStaticPassword(
677
                                adminUserAlias, adminUserPassword, true,
678
                                Constants.UTYPE_STATE_ADMIN);
679
680
                if (rc != Constants.ERR_SUCCESS)
681
                {
682
                        return rc;
683
                }
684
685
                rc = lockUserService.lockUser(userAlias,
686
                                Constants.UID_STATE_TMP_LOCKED, fromDate, nMinutes);
687
688
                logger.info("UA_SuspendUser - admin user alias: [" + adminUserAlias
689
                                + "] user alias: [" + userAlias + "] From: [" + fromDate
690
                                + " for " + nMinutes + "min] Return: " + rc);
691
692
                return rc;
693
        }
694
695
        /**
696
         * This method is to suspend admin user from when for how many Minutes
697
         *
698
         * @param rootAlias
699
         * @param rootPassword
700
         * @param adminUserAlias
701
         * @param fromDate
702
         *            - from when
703
         * @param nMinutes
704
         *            - Suspend for how many Minutes
705
         * @return ERR_code defined in the Constants.<br/>
706
         *         ERR_SUCCESS<br/>
707
         *         ERR_SYSTEM_NOT_READY<br/>
708
         *         ERR_USERALIAS_NOT_FOUND <br/>
709
         *         ERR_INVALID_STATE - root not active or temporary suspended.<br/>
710
         *         ERR_APP_SERV_NOT_PERMITTED - for operation not allowed for the user type.<br/>
711
         *         ERR_EXCEED_MAX_TRIES<br/>
712
         *         ERR_INVALID_CREDENTIAL<br/>
713
         *         ERR_UNKNOWN<br/>
714
         */
715
        public int AD_SuspendUser(String rootAlias, String rootPassword,
716
                        String adminUserAlias, String strFromDate, int nMinutes)
717
        {
718
                Date fromDate = StringToDate(strFromDate);
719
                int rc = verifyStaticPasswordService.verifyStaticPassword(
720
                                rootAlias, rootPassword, true, Constants.UTYPE_STATE_ROOT);
721
722
                if (rc != Constants.ERR_SUCCESS)
723
                {
724
                        return rc;
725
                }
726
727
                rc = lockUserService.lockUser(adminUserAlias,
728
                                Constants.UID_STATE_TMP_LOCKED, fromDate, nMinutes);
729
730
                logger.info("AD_SuspendUser - admin user alias: [" + adminUserAlias
731
                                + "] Return: " + rc);
732
733
                return rc;
734
        }
735
736
        /**
737
         * This method is to concate existing user alias to allow re use user after deleted.
738
         *
739
         * @param rootAlias
740
         * @param rootPassword
741
         * @param adminUserAlias
742
         * @param fromDate
743
         *            - from when
744
         * @param nMinutes
745
         *            - Suspend for how many Minutes
746
         * @return ERR_code defined in the Constants.<br/>
747
         *         ERR_SUCCESS<br/>
748
         *         ERR_SYSTEM_NOT_READY<br/>
749
         *         ERR_USERALIAS_NOT_FOUND <br/>
750
         *         ERR_INVALID_STATE - root not active or temporary suspended.<br/>
751
         *         ERR_APP_SERV_NOT_PERMITTED - for operation not allowed for the user type.<br/>
752
         *         ERR_EXCEED_MAX_TRIES<br/>
753
         *         ERR_INVALID_CREDENTIAL<br/>
754
         *         ERR_UNKNOWN<br/>
755
         */
756
        public int UA_DeleteUser(String adminUserAlias, String adminUserPassword, String userAlias)
757
        {
758
759
                int rc = verifyStaticPasswordService.verifyStaticPassword(
760
                                adminUserAlias, adminUserPassword, true,
761
                                Constants.UTYPE_STATE_ADMIN);
762
763
                if (rc != Constants.ERR_SUCCESS)
764
                {
765
                        return rc;
766
                }
767
768
                rc = DeleteUserService.deleteUser(userAlias);
769
770
                logger.info("AD_SuspendUser - admin user alias: [" + userAlias
771
                                + "] Return: " + rc);
772
773
                return rc;
774
        }
775
776
        // ///////////////////////////////////////////////////////////////////////////////
777
        // token area
778
        // ///////////////////////////////////////////////////////////////////////////////
779
780
        /**
781
         * This method is to verify token password
782
         *
783
         * @param userAlias
784
         * @param inPassword
785
         * @return ERR_code defined in the Constants<br/>
786
         *         ERR_SUCCESS<br/>
787
         *         ERR_SYSTEM_NOT_READY<br/>
788
         *         ERR_USERALIAS_NOT_FOUND<br/>
789
         *         ERR_INVALID_STATE<br/>
790
         *         ERR_EXCEED_MAX_TRIES<br/>
791
         *         ERR_INVALID_CREDENTIAL<br/>
792
         *         ERR_PASSWD_EXPIRED<br/>
793
         *         ERR_REUSED_PASSWD<br/>
794
         */
795
        public int VerifyToken(String userAlias, String inPassword)
796
        {
797
                int rc = verifyTokenService.verifyToken(userAlias, inPassword);
798
799
                logger.info("VerifyToken - user alias: [" + userAlias + "] Return: "
800
                                + rc);
801
802
                return rc;
803
        }
804
805
        /**
806
         * This method is to reset user token <br/>
807
         *
808
         * @param adminUserAlias
809
         * @param adminUserPassword
810
         * @param userAlias
811
         * @return ERR_code defined in the Constants<br/>
812
         *         ERR_SUCCESS<br/>
813
         *         ERR_SYSTEM_NOT_READY<br/>
814
         *         ERR_USERALIAS_NOT_FOUND<br/>
815
         *         ERR_INVALID_STATE<br/>
816
         *         ERR_EXCEED_MAX_TRIES<br/>
817
         *         ERR_INVALID_CREDENTIAL<br/>
818
         */
819
        public int ResetToken(String adminUserAlias, String adminUserPassword,
820
                        String userAlias)
821
        {
822
                int rc = verifyStaticPasswordService.verifyStaticPassword(
823
                                adminUserAlias, adminUserPassword, true,
824
                                Constants.UTYPE_STATE_ADMIN);
825
826
                if (rc != Constants.ERR_SUCCESS)
827
                {
828
                        return rc;
829
                }
830
831
                rc = resetTokenService.resetToken(userAlias);
832
                logger.info("ResetToken - user alias: [" + userAlias + "] Return: "
833
                                + rc);
834
                return rc;
835
        }
836
837
        /**
838
         * This method is to query token information, Return type is HashMap<String,String>
839
         * RC - Return Code [always present]<br/>
840
         * RT - Return Code in Text [always present]<br/>
841
         * <br/>
842
         * The following data present only with the return is ERR_SUCCESS<br/>
843
         * SerailNo - The serial number of token<br/>
844
         * State - Token State, [0-UNASSIGNED], [1-ASSIGNED], [2-DISABLE], [3-LOCKED], [4-DELETED]<br/>
845
         * UseCount - number of time of password authentication <br/>
846
         * ErrorCount - number of time error encountered of password authentication<br/>
847
         * DateAssigned - date of assignment to user<br/>
848
         * DateFirstUsed - date of 1st time use<br/>
849
         * DateLastUsed - date of last time used<br/>
850
         * BatchID - the ID used for loading the token into data store<br/>
851
         * <br/>
852
         *
853
         * Data retrieved from token BLOB<br/>
854
         * TOKEN_MODEL<br/>
855
         * USE_COUNT<br/>
856
         * ERROR_COUNT<br/>
857
         * LAST_TIME_USED<br/>
858
         * CODE_WORD<br/>
859
         * TRIPLE_DES<br/>
860
         * MAX_INPUT_FIELDS<br/>
861
         * RESPONSE_LENGTH<br/>
862
         * RESPONSE_TYPE<br/>
863
         * RESPONSE_CHECKSUM<br/>
864
         * TIME_STEP_USED<br/>
865
         *
866
         * @param userAlias
867
         * @return HashMap
868
         */
869
        public HashMap<String, String> QueryToken(String userAlias)
870
        {
871
                return queryInfoService.queryToken(userAlias);
872
        }
873
874
        public int DeleteTokenFromStore(String adminUserAlias,
875
                        String adminUserPassword, String serialNumber)
876
        {
877
                int rc = verifyStaticPasswordService.verifyStaticPassword(
878
                                adminUserAlias, adminUserPassword, true,
879
                                Constants.UTYPE_STATE_ADMIN);
880
881
                if (rc != Constants.ERR_SUCCESS)
882
                {
883
                        return rc;
884
                }
885
886
                rc = deleteTokenService.deleteTokenFromStore(serialNumber);
887
                logger.info("DeleteTokenFromStore - serial number: [" + serialNumber
888
                                + "] Return: " + rc);
889
                return rc;
890
        }
891
892
        /**
893
         * This method is to assign token to user<br/>
894
         *
895
         * @param serialNumber
896
         * @param userAlias
897
         * @return ERR_code defined in the Constants<br/>
898
         *         ERR_SUCCESS<br/>
899
         *         ERR_SYSTEM_NOT_READY<br/>
900
         *         ERR_USERALIAS_NOT_FOUND<br/>
901
         *         ERR_INVALID_STATE<br/>
902
         */
903
        public int AssignTokenToUser(String adminUserAlias,
904
                        String adminUserPassword, String serialNumber, String userAlias)
905
        {
906
                int rc = verifyStaticPasswordService.verifyStaticPassword(
907
                                adminUserAlias, adminUserPassword, true,
908
                                Constants.UTYPE_STATE_ADMIN);
909
910
                if (rc != Constants.ERR_SUCCESS)
911
                {
912
                        return rc;
913
                }
914
915
                rc = assignTokenService.assignToken(serialNumber, userAlias,
916
                                Constants.TKN_STATE_ASSIGNED);
917
918
                logger.info("AssignTokenToUser - serial number: [" + serialNumber
919
                                + "] user alias: [" + userAlias + "] Return: " + rc);
920
921
                return rc;
922
        }
923
924
        /**
925
         * This method is to return Token to store; Reset the Token.<br/>
926
         * The token is ready to re-assign to other user.<br/>
927
         *
928
         * @param adminUserAlias
929
         * @param adminUserPassword
930
         * @param userAlias
931
         * @return ERR_code defined in the Constants<br/>
932
         *         ERR_SUCCESS<br/>
933
         *         ERR_SYSTEM_NOT_READY<br/>
934
         *         ERR_USERALIAS_NOT_FOUND<br/>
935
         *         ERR_INVALID_STATE<br/>
936
         */
937
        public int UnassignTokenFromUser(String adminUserAlias,
938
                        String adminUserPassword, String userAlias)
939
        {
940
                int rc = verifyStaticPasswordService.verifyStaticPassword(
941
                                adminUserAlias, adminUserPassword, true,
942
                                Constants.UTYPE_STATE_ADMIN);
943
944
                if (rc != Constants.ERR_SUCCESS)
945
                {
946
                        return rc;
947
                }
948
949
                rc = assignTokenService.assignToken(null, userAlias,
950
                                Constants.TKN_STATE_UNASSIGNED);
951
952
                logger.info("UnassignTokenFromUser - user alias: [" + userAlias
953
                                + "] Return: " + rc);
954
955
                return rc;
956
        }
957
958
        /**
959
         * This method is to disable the token<br/>
960
         *
961
         * @param adminUserAlias
962
         * @param adminUserPassword
963
         * @param userAlias
964
         * @return ERR_code defined in the Constants<br/>
965
         *         ERR_SUCCESS<br/>
966
         *         ERR_SYSTEM_NOT_READY<br/>
967
         *         ERR_USERALIAS_NOT_FOUND<br/>
968
         *         ERR_INVALID_STATE<br/>
969
         */
970
        public int DisableToken(String adminUserAlias, String adminUserPassword,
971
                        String userAlias)
972
        {
973
                int rc = verifyStaticPasswordService.verifyStaticPassword(
974
                                adminUserAlias, adminUserPassword, true,
975
                                Constants.UTYPE_STATE_ADMIN);
976
977
                if (rc != Constants.ERR_SUCCESS)
978
                {
979
                        return rc;
980
                }
981
982
                rc = disableTokenService.disableToken(userAlias, true);
983
984
                logger.info("DisableToken - user alias: [" + userAlias + "] Return: "
985
                                + rc);
986
987
                return rc;
988
        }
989
990
        /**
991
         * This method is to enable to token<br/>
992
         *
993
         * @param adminUserAlias
994
         * @param adminUserPassword
995
         * @param userAlias
996
         * @return ERR_code defined in the Constants<br/>
997
         *         ERR_SUCCESS<br/>
998
         *         ERR_SYSTEM_NOT_READY<br/>
999
         *         ERR_USERALIAS_NOT_FOUND<br/>
1000
         *         ERR_INVALID_STATE<br/>
1001
         */
1002
        public int EnableToken(String adminUserAlias, String adminUserPassword,
1003
                        String userAlias)
1004
        {
1005
                int rc = verifyStaticPasswordService.verifyStaticPassword(
1006
                                adminUserAlias, adminUserPassword, true,
1007
                                Constants.UTYPE_STATE_ADMIN);
1008
1009
                if (rc != Constants.ERR_SUCCESS)
1010
                {
1011
                        return rc;
1012
                }
1013
1014
                rc = disableTokenService.disableToken(userAlias, false);
1015
1016
                logger.info("EnableToken - user alias: [" + userAlias + "] Return: "
1017
                                + rc);
1018
1019
                return rc;
1020
        }
1021
1022
        /**
1023
         * This method is to load token from DPX or PSKC file to UPass data store
1024
         * Refer to System Console for additional information.
1025
         *
1026
         * @param adminUserAlias
1027
         * @param adminUserPassword
1028
         * @param requiredField1
1029
         *            = fileName
1030
         * @param requiredField2
1031
         *            = importKey/ passsphrase / fileName
1032
         * @param requiredField3
1033
         *            = batchId/ null
1034
         * @return rc (response code)
1035
         * @throws Exception
1036
         */
1037
        public int LoadToken(String adminUserAlias, String adminUserPassword,
1038
                        String requiredField1, String requiredField2, String requiredField3) throws Exception
1039
        {
1040
                int rc = Constants.ERR_SYSTEM_NOT_READY;
1041
1042
                rc = LoadTokenWithStats(adminUserAlias, adminUserPassword,
1043
                                requiredField1, requiredField2, requiredField3).getResponseCode();
1044
1045
                return rc;
1046
        }
1047
1048
        /**
1049
         * This method override the existing LoadToken to generate load token statistic
1050
         *
1051
         * @param adminUserAlias
1052
         * @param adminUserPassword
1053
         * @param requiredField1
1054
         *            = fileName
1055
         * @param requiredField2
1056
         *            = importKey/ passsphrase / fileName
1057
         * @param requiredField3
1058
         *            = batchId/ null
1059
         * @return LoadTokenBean
1060
         * @throws Exception
1061
         */
1062
        public LoadTokenBean LoadTokenWithStats(String adminUserAlias, String adminUserPassword,
1063
                        String requiredField1, String requiredField2, String requiredField3) throws Exception {
1064
                LoadTokenBean loadTokenBean = new LoadTokenBean();
1065
1066
                // verify supervisor password
1067
                int rc = verifyStaticPasswordService.verifyStaticPassword(
1068
                                adminUserAlias, adminUserPassword, true,
1069
                                Constants.UTYPE_STATE_ADMIN);
1070
1071
                rc = 0;
1072
1073
                if (rc != Constants.ERR_SUCCESS) {
1074
                        loadTokenBean.setResponseCode(rc);
1075
1076
                } else {
1077
                        loadTokenBean = loadTokenService.loadToken(requiredField1, requiredField2, requiredField3,
1078
                                        UPassFactory.getTokenMode());
1079
                }
1080
1081
                return loadTokenBean;
1082
        }
1083
1084
        /**
1085
         * This method override the existing LoadToken to generate load token statistic
1086
         *
1087
         * @param adminUserAlias
1088
         * @param adminUserPassword
1089
         * @param requiredField1
1090
         *            = userAlias
1091
         * @param requiredField2
1092
         *            = Otp 1
1093
         * @param requiredField3
1094
         *            = Otp 2
1095
         * @return LoadTokenBean
1096
         * @throws Exception
1097
         */
1098
        public int SynchronizeToken(String adminUserAlias, String adminUserPassword,
1099
                        String userAlias, String otp1, String otp2) {
1100
1101
                // verify supervisor password
1102
                int rc = verifyStaticPasswordService.verifyStaticPassword(
1103
                                adminUserAlias, adminUserPassword, true,
1104
                                Constants.UTYPE_STATE_ADMIN);
1105
1106
                if (rc != Constants.ERR_SUCCESS)
1107
                {
1108
                        return rc;
1109
                }
1110
1111
                rc = synchronizeTokenService.syncToken(userAlias, otp1, otp2);
1112
1113
                logger.info("SyncToken - useralias: [" + userAlias
1114
                                + "] first OTP: [" + otp1 + "] Second OTP: [" + otp2 + "] Return: " + rc);
1115
                return rc;
1116
1117
        }
1118
1119
        /**
1120
         * This method is to get Specified token vendor name in Token Controller
1121
         *
1122
         * @return token Vendor name
1123
         */
1124
        public String getTokenVendor() {
1125
1126
                return queryInfoService.getTokenVendor();
1127
1128
        }
1129
1130
        // ///////////////////////////////////////////////////////////////////////////////
1131
        // token area end
1132
        // ///////////////////////////////////////////////////////////////////////////////
1133
1134
        private Date StringToDate(String dateString)
1135
        {
1136
                String DATE_FORMAT = "yyyyMMddHHmmss";
1137
                SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT);
1138
                Date parsedDate = new Date();
1139
1140
                try
1141
                {
1142
                        parsedDate = format.parse(dateString);
1143
                } catch (ParseException pe)
1144
                {
1145
                        logger.info("ERROR: Cannot parse date in String " + dateString);
1146
                }
1147
1148
                return parsedDate;
1149
        }
1150
1151
        // ///////////////////////////////////////////////////////////////////////////////
1152
        // Security code area
1153
        // ///////////////////////////////////////////////////////////////////////////////
1154
1155
        public String GenerateSecurityCode(String identifier)
1156
        {
1157
                String sRc = generateSecurityCodeService
1158
                                .generateSecurityCode(identifier);
1159
1160
                logger.info(identifier + " Return=" + sRc.substring(2));
1161
1162
                return sRc;
1163
        }
1164
1165
        public int VerifySecurityCode(String identifier, String securityCode)
1166
        {
1167
                int rc = verifySecurityCodeService.verifySecurityCode(
1168
                                identifier, securityCode);
1169
1170
                logger.info("VerifySecurityCode - identifier: [" + identifier
1171
                                + "] Return: " + rc);
1172
1173
                return rc;
1174
        }
1175
1176
        public int VerifyPasswordComplexity(String password, int applicationId) {
1177
                int rc = verifyPasswordComplexityService.verifyPasswordComplexity(password, applicationId);
1178
1179
                logger.info("VerifyPasswordComplexity: - password[" + password
1180
                                + "] Return: " + rc);
1181
1182
                return rc;
1183
        }
1184 23:1281bdc0fb8f mohd
1185
        /**
1186
         * This method to add admin users to the system
1187
         *
1188
         * @param rootAlias
1189
         * @param rootPassword
1190
         * @param adminUserAlias
1191
         * @param adminDesc
1192
         * @param adminUserPassword
1193
         * @return ERR_code defined in the MinimalConstants<br/>
1194
         *         ERR_SUCCESS<br/>
1195
         *         ERR_SYSTEM_NOT_READY<br/>
1196
         *         ERR_USERALIAS_NOT_FOUND <br/>
1197
         *         ERR_INVALID_STATE - root not active or temporary suspended.<br/>
1198
         *         ERR_APP_SERV_NOT_PERMITTED - for operation not allowed for the user type.<br/>
1199
         *         ERR_EXCEED_MAX_TRIES<br/>
1200
         *         ERR_INVALID_CREDENTIAL<br/>
1201
         *         ERR_INVALID_INPUT - internal error.<br/>
1202
         *         ERR_ALREADY_EXIST<br/>
1203
         *         ERR_INVALID_USERALIAS - User alias does not match with defined pattern <br/>
1204
         *         ERR_PASSWORD_SAMEAS_USERALIAS - password is same is user name error <br/>
1205
         */
1206
        public int AD_AddUser(String rootAlias, String rootPassword, String adminUserAlias,
1207
                        String adminDesc, String adminUserPassword) {
1208
                                // check if password is similar to user alias
1209
                                if (rootAlias.equalsIgnoreCase(rootPassword)) {
1210
                                        return MinimalConstants.ERR_PASSWORD_SAMEAS_USERALIAS;
1211
                                }
1212
1213
                                int rc = verifyStaticPasswordService.verifyStaticPassword(
1214
                                                rootAlias, rootPassword, true, MinimalConstants.UTYPE_STATE_ROOT);
1215
1216
                                if (rc != MinimalConstants.ERR_SUCCESS)
1217
                                {
1218
                                        return rc;
1219
                                }
1220
1221
                                rc = createUserService.addUser(adminUserAlias,
1222
                                                MinimalConstants.UTYPE_STATE_ADMIN, adminDesc, adminUserPassword,
1223
                                                MinimalConstants.UID_STATE_ACTIVE, MinimalConstants.SYSTEM_ID);
1224
1225
                                logger.info("AD_AddUser - admin user alias: [" + adminUserAlias
1226
                                                + "] Return: " + rc);
1227
1228
                                return rc;
1229
                        }
1230 0:02300db8682b hadi
}