Statistics
| Branch: | Revision:

m2u-upass-core / src / my / com / upass / UPassControllerExt.java @ 36:d0e2afc0c6e6

History | View | Annotate | Download (2.33 KB)

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