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