m2u-upass-core / src / my / com / upass / services / VerifyTacService.java @ 74:214028f5d496
History | View | Annotate | Download (2.21 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 |
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 VerifyTacService { |
36 |
|
37 |
private UPassControllerV2 upc;
|
38 |
|
39 |
public VerifyTacService(UPassControllerV2 upc) {
|
40 |
this.upc = upc;
|
41 |
} |
42 |
|
43 |
public int verifyTAC(String userAlias, String inTac, int appId) { |
44 |
return verifyTAC(userAlias, inTac, null, null, appId); |
45 |
} |
46 |
|
47 |
public int verifyTAC(String userAlias, String inTac, String sessionID, int appId) { |
48 |
return verifyTAC(userAlias, inTac, sessionID, null, appId); |
49 |
} |
50 |
|
51 |
public int verifyTAC(String userAlias, String inTac, String sessionID, String nonce, int appId) { |
52 |
|
53 |
int rc = Constants.ERR_SYSTEM_NOT_READY;
|
54 |
|
55 |
try {
|
56 |
UserTacDAO tacDao = DAOFactoryProvider.getDAOFactory().getUserTacDAO(); |
57 |
TacBean tacBean = tacDao.getTacFromStore(userAlias, appId); |
58 |
|
59 |
if (tacBean == null) { |
60 |
return Constants.ERR_USERALIAS_NOT_FOUND;
|
61 |
} |
62 |
|
63 |
final ConfigBean config = (ConfigBean) upc.getConfigurationsMap().get(appId);
|
64 |
TacController tc = UPassFactory.getTacController(tacBean, config); |
65 |
rc = tc.VerifyTac(inTac, sessionID, nonce); |
66 |
|
67 |
tacBean = (TacBean) tc.getUpdatedObject(); |
68 |
|
69 |
// update database
|
70 |
boolean lrc = tacDao.updateTacToStore(tacBean);
|
71 |
|
72 |
if (!lrc) {
|
73 |
return Constants.ERR_UNKNOWN;
|
74 |
} |
75 |
} catch (Exception e) { |
76 |
e.printStackTrace(); |
77 |
} |
78 |
return rc;
|
79 |
} |
80 |
} |