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