m2u-upass-core / src / my / com / upass / services / DisableTokenService.java @ 74:214028f5d496
History | View | Annotate | Download (1.99 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 | |||
12 | package my.com.upass.services; |
||
13 | |||
14 | import my.com.upass.Constants; |
||
15 | import my.com.upass.dao.DAOFactoryProvider; |
||
16 | import my.com.upass.dao.UserTokenDAO; |
||
17 | import my.com.upass.factory.UPassFactory; |
||
18 | import my.com.upass.pojo.UserTokenBean; |
||
19 | |||
20 | /**
|
||
21 | * PROGRAMMER: Danniell
|
||
22 | * CHANGE-NO:
|
||
23 | * TASK-NO:
|
||
24 | * DATE CREATED: Dec 28, 2011
|
||
25 | * TAG AS:
|
||
26 | * REASON(S):
|
||
27 | * MODIFICATION:
|
||
28 | */
|
||
29 | |||
30 | /**
|
||
31 | * <Class description>
|
||
32 | */
|
||
33 | public class DisableTokenService |
||
34 | { |
||
35 | public int disableToken (String userAlias, boolean ldisable) |
||
36 | { |
||
37 | try
|
||
38 | { |
||
39 | UserTokenDAO tokenDao = DAOFactoryProvider.getDAOFactory () |
||
40 | .getUserTokenDAO (UPassFactory.getTokenMode ()); |
||
41 | UserTokenBean tb = tokenDao.getTokenFromStoreByUserAlias (userAlias); |
||
42 | |||
43 | // check state vs operations
|
||
44 | boolean validState = true; |
||
45 | if (ldisable & tb.getVstate () != Constants.TKN_STATE_ASSIGNED)
|
||
46 | { |
||
47 | validState = false;
|
||
48 | } |
||
49 | |||
50 | if (!ldisable & tb.getVstate () != Constants.TKN_STATE_DISABLE)
|
||
51 | { |
||
52 | validState = false;
|
||
53 | } |
||
54 | |||
55 | if (!validState)
|
||
56 | { |
||
57 | return Constants.ERR_INVALID_STATE;
|
||
58 | } |
||
59 | |||
60 | // assign state according to Enable|Disable
|
||
61 | int TargetTokenAssignmentState = (ldisable) ? Constants.TKN_STATE_DISABLE
|
||
62 | : Constants.TKN_STATE_ASSIGNED; |
||
63 | tb.setVstate (TargetTokenAssignmentState); |
||
64 | tb.setVdateLastUsed (null);
|
||
65 | |||
66 | // update database
|
||
67 | boolean lrc = tokenDao.updateTokenToStore (tb);
|
||
68 | |||
69 | if (!lrc)
|
||
70 | { |
||
71 | return Constants.ERR_UNKNOWN;
|
||
72 | } |
||
73 | } |
||
74 | catch (Exception e) |
||
75 | { |
||
76 | e.printStackTrace (); |
||
77 | } |
||
78 | return Constants.ERR_SUCCESS;
|
||
79 | } |
||
80 | } |