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