m2u-upass-core / src / my / com / upass / services / GenerateTacService.java @ 60:1cff9a56093f
History | View | Annotate | Download (2 KB)
1 | 0:02300db8682b | hadi | /**
|
---|---|---|---|
2 | * Copyright (c) 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.services; |
||
12 | |||
13 | import my.com.upass.ConfigBean; |
||
14 | import my.com.upass.Constants; |
||
15 | import my.com.upass.UPassControllerV2; |
||
16 | import my.com.upass.dao.DAOFactoryProvider; |
||
17 | import my.com.upass.dao.UserTacDAO; |
||
18 | import my.com.upass.factory.UPassFactory; |
||
19 | import my.com.upass.pojo.TacBean; |
||
20 | import my.com.upass.tac.TacController; |
||
21 | |||
22 | /**
|
||
23 | * PROGRAMMER: Danniell
|
||
24 | * CHANGE-NO:
|
||
25 | * TASK-NO:
|
||
26 | * DATE CREATED: Dec 28, 2011
|
||
27 | * TAG AS:
|
||
28 | * REASON(S):
|
||
29 | * MODIFICATION:
|
||
30 | */
|
||
31 | |||
32 | /**
|
||
33 | * <Class description>
|
||
34 | */
|
||
35 | public class GenerateTacService { |
||
36 | |||
37 | private UPassControllerV2 upc;
|
||
38 | |||
39 | public GenerateTacService(UPassControllerV2 upc) {
|
||
40 | this.upc = upc;
|
||
41 | } |
||
42 | |||
43 | public String generateTAC(String userAlias, String sessionID, String nonce, int appId) { |
||
44 | |||
45 | String tac = "***" + Constants.ERR_SYSTEM_NOT_READY; |
||
46 | |||
47 | try {
|
||
48 | UserTacDAO tacDao = DAOFactoryProvider.getDAOFactory().getUserTacDAO(); |
||
49 | TacBean tacBean = tacDao.getTacFromStore(userAlias, appId); |
||
50 | |||
51 | if (tacBean == null) { |
||
52 | return "***" + Constants.ERR_USERALIAS_NOT_FOUND; |
||
53 | } |
||
54 | 23:1281bdc0fb8f | mohd | final ConfigBean config = (ConfigBean) upc.getConfigurationsMap().get(appId);
|
55 | 0:02300db8682b | hadi | TacController tc = UPassFactory.getTacController(tacBean, config); |
56 | // leetk 20090603 tc.SetSessionID(sessionID);
|
||
57 | tac = tc.GenerateTac(sessionID, nonce); |
||
58 | tacBean = (TacBean) tc.getUpdatedObject(); |
||
59 | |||
60 | // update database
|
||
61 | boolean lrc = tacDao.updateTacToStore(tacBean);
|
||
62 | |||
63 | if (!lrc) {
|
||
64 | return "***" + Constants.ERR_USERALIAS_NOT_FOUND; |
||
65 | } |
||
66 | } catch (Exception e) { |
||
67 | e.printStackTrace(); |
||
68 | } |
||
69 | return tac;
|
||
70 | } |
||
71 | } |