m2u-upass-core / src / my / com / upass / services / DisableTacService.java @ 5:f608e6319b70
History | View | Annotate | Download (2.02 KB)
1 |
/**
|
---|---|
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 |
|
12 |
package my.com.upass.services; |
13 |
|
14 |
import java.util.Map; |
15 |
|
16 |
import my.com.upass.ConfigBean; |
17 |
import my.com.upass.Constants; |
18 |
import my.com.upass.UPassControllerV2; |
19 |
import my.com.upass.dao.DAOFactoryProvider; |
20 |
import my.com.upass.dao.UserTacDAO; |
21 |
import my.com.upass.factory.UPassFactory; |
22 |
import my.com.upass.pojo.TacBean; |
23 |
import my.com.upass.tac.TacController; |
24 |
|
25 |
/**
|
26 |
* PROGRAMMER: Danniell
|
27 |
* CHANGE-NO:
|
28 |
* TASK-NO:
|
29 |
* DATE CREATED: Dec 28, 2011
|
30 |
* TAG AS:
|
31 |
* REASON(S):
|
32 |
* MODIFICATION:
|
33 |
*/
|
34 |
|
35 |
/**
|
36 |
* <Class description>
|
37 |
*/
|
38 |
public class DisableTacService { |
39 |
|
40 |
private UPassControllerV2 upc;
|
41 |
|
42 |
public DisableTacService(UPassControllerV2 upc) {
|
43 |
this.upc = upc;
|
44 |
} |
45 |
|
46 |
public int disableTAC(String userAlias) { |
47 |
|
48 |
int rc = Constants.ERR_SYSTEM_NOT_READY;
|
49 |
|
50 |
if (rc != Constants.ERR_SUCCESS) {
|
51 |
return rc;
|
52 |
} |
53 |
try {
|
54 |
UserTacDAO tacDao = DAOFactoryProvider.getDAOFactory().getUserTacDAO(); |
55 |
final Map<Integer, ConfigBean> configsMap = upc.getConfigurationsMap(); |
56 |
for (Integer appId : configsMap.keySet()) { |
57 |
|
58 |
TacBean tb = tacDao.getTacFromStore(userAlias, appId); |
59 |
if (tb == null) { |
60 |
return Constants.ERR_USERALIAS_NOT_FOUND;
|
61 |
} |
62 |
// reset TAC
|
63 |
final ConfigBean config = configsMap.get(appId);
|
64 |
TacController tc = UPassFactory.getTacController(tb, config); |
65 |
tc.DisableTAC(); |
66 |
tc.getUpdatedObject(); |
67 |
|
68 |
if (tacDao.updateTacToStore(tb)) {
|
69 |
rc = Constants.ERR_SUCCESS; |
70 |
|
71 |
} else {
|
72 |
rc = Constants.ERR_UNKNOWN; |
73 |
} |
74 |
} |
75 |
} catch (Exception e) { |
76 |
e.printStackTrace(); |
77 |
} |
78 |
return rc;
|
79 |
} |
80 |
} |