m2u-upass-core / src / my / com / upass / UPassControllerExt.java @ 8:1982e43e6686
History | View | Annotate | Download (2.28 KB)
1 |
package my.com.upass; |
---|---|
2 |
|
3 |
import java.util.Date; |
4 |
|
5 |
import my.com.upass.db.DBOperations; |
6 |
import my.com.upass.pojo.UserBean; |
7 |
|
8 |
/**
|
9 |
* PROGRAMMER: Danniell
|
10 |
* CHANGE-NO:
|
11 |
* TASK-NO:
|
12 |
* DATE CREATED: Aug 23, 2011
|
13 |
* TAG AS:
|
14 |
* REASON(S):
|
15 |
* MODIFICATION:
|
16 |
*/
|
17 |
|
18 |
/**
|
19 |
* Extends the UPassController itself
|
20 |
*/
|
21 |
public class UPassControllerExt extends UPassController |
22 |
{ |
23 |
public UPassControllerExt()
|
24 |
{ |
25 |
super ();
|
26 |
} |
27 |
|
28 |
/**
|
29 |
* This method to change online users state to ACTIVE status with RESET error counter to 0
|
30 |
* @param adminUserAlias
|
31 |
* @param adminUserPassword
|
32 |
* @param userAlias
|
33 |
* @return ERR_code defined in the Constants.<br/>
|
34 |
* ERR_SUCCESS<br/>
|
35 |
* ERR_SYSTEM_NOT_READY<br/>
|
36 |
* ERR_USERALIAS_NOT_FOUND <br/>
|
37 |
* ERR_INVALID_STATE - admin not active or temporary suspended.<br/>
|
38 |
* ERR_APP_SERV_NOT_PERMITTED - for operation not allowed for the user type.<br/>
|
39 |
* ERR_EXCEED_MAX_TRIES<br/>
|
40 |
* ERR_INVALID_CREDENTIAL<br/>
|
41 |
* ERR_USERALIAS_NOT_FOUND<br/>
|
42 |
* ERR_UNKNOWN <br/>
|
43 |
*/
|
44 |
@Override
|
45 |
public int UA_ActivateUser (String adminUserAlias, |
46 |
String adminUserPassword, String userAlias) |
47 |
{ |
48 |
int rc = ua_ActivateUser (adminUserAlias, adminUserPassword, userAlias);
|
49 |
logger.info (adminUserAlias + " " + userAlias + " Return=" + rc); |
50 |
return rc;
|
51 |
} |
52 |
|
53 |
private int ua_ActivateUser (String adminUserAlias, |
54 |
String adminUserPassword, String userAlias) |
55 |
{ |
56 |
int rc = verifyStaticPassword (adminUserAlias, adminUserPassword, true, |
57 |
Constants.UTYPE_STATE_ADMIN); |
58 |
|
59 |
if (rc != Constants.ERR_SUCCESS)
|
60 |
{ |
61 |
return rc;
|
62 |
} |
63 |
return activateUser (userAlias);
|
64 |
} |
65 |
|
66 |
private int activateUser (String userAlias) |
67 |
{ |
68 |
int rc;
|
69 |
|
70 |
if (userAlias == null) |
71 |
{ |
72 |
return Constants.ERR_INVALID_INPUT;
|
73 |
} |
74 |
|
75 |
DBOperations dbo = new DBOperations ();
|
76 |
UserBean ub = new UserBean ();
|
77 |
ub = dbo.getUserFromStore (userAlias); |
78 |
|
79 |
if (ub == null) |
80 |
{ |
81 |
dbo.close (); |
82 |
return Constants.ERR_USERALIAS_NOT_FOUND;
|
83 |
} |
84 |
|
85 |
ub.setUstate (Constants.UID_STATE_ACTIVE); |
86 |
ub.setUdateLastActivated (new Date ()); |
87 |
|
88 |
if(ub.getPerrorCount () > _MAX_ERROR)
|
89 |
{ |
90 |
ub.setPerrorCount (0);
|
91 |
} |
92 |
|
93 |
if (dbo.updateUserToStore (ub))
|
94 |
{ |
95 |
rc = Constants.ERR_SUCCESS; |
96 |
} |
97 |
else
|
98 |
{ |
99 |
rc = Constants.ERR_UNKNOWN; |
100 |
} |
101 |
dbo.close (); |
102 |
return rc;
|
103 |
} |
104 |
} |