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