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