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