m2u-upass-core / src / my / com / upass / services / ModifyUserService.java @ 18:78fbff99ec6c
History | View | Annotate | Download (2.35 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 my.com.upass.Constants; |
15 |
import my.com.upass.UPassControllerV2; |
16 |
import my.com.upass.dao.DAOFactoryProvider; |
17 |
import my.com.upass.dao.UserDAO; |
18 |
import my.com.upass.factory.UPassFactory; |
19 |
import my.com.upass.pojo.UserBean; |
20 |
import my.com.upass.spassword.PasswordController; |
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 ModifyUserService |
36 |
{ |
37 |
private UPassControllerV2 upc;
|
38 |
|
39 |
public ModifyUserService(UPassControllerV2 upc)
|
40 |
{ |
41 |
this.upc = upc;
|
42 |
} |
43 |
|
44 |
public int modifyUser (String userAlias, int userType, String userDesc, |
45 |
String userPassword, int userState) |
46 |
{ |
47 |
int rc = Constants.ERR_SYSTEM_NOT_READY;
|
48 |
|
49 |
if (userAlias == null) |
50 |
{ |
51 |
return Constants.ERR_INVALID_INPUT;
|
52 |
} |
53 |
|
54 |
UserDAO userDao; |
55 |
|
56 |
try
|
57 |
{ |
58 |
userDao = DAOFactoryProvider.getDAOFactory ().getUserDAO (); |
59 |
UserBean ub = userDao.getUserFromStore (userAlias); |
60 |
|
61 |
if (ub == null) |
62 |
{ |
63 |
return Constants.ERR_USERALIAS_NOT_FOUND;
|
64 |
} |
65 |
|
66 |
if (userPassword != null) |
67 |
{ |
68 |
// Generate new paswword
|
69 |
PasswordController pc = UPassFactory.getPasswordController (ub, |
70 |
upc.getConfigurationsMap ()); |
71 |
// rc = pc.GeneratePassword(userPassword, false); //disable
|
72 |
// password hist check 20081220
|
73 |
rc = pc.GeneratePassword (userPassword, true);
|
74 |
if (rc != Constants.ERR_SUCCESS)
|
75 |
{ |
76 |
return rc;
|
77 |
} |
78 |
ub = (UserBean) pc.getUpdatedObject (); |
79 |
} |
80 |
|
81 |
if (userDesc != null) |
82 |
{ |
83 |
ub.setDescription (userDesc); |
84 |
} |
85 |
|
86 |
ub.setUserType (userType); |
87 |
ub.setUstate (userState); |
88 |
|
89 |
if (userDao.updateUserToStore (ub))
|
90 |
{ |
91 |
rc = Constants.ERR_SUCCESS; |
92 |
} |
93 |
else
|
94 |
{ |
95 |
rc = Constants.ERR_UNKNOWN; |
96 |
} |
97 |
} |
98 |
catch (Exception e) |
99 |
{ |
100 |
e.printStackTrace (); |
101 |
} |
102 |
return rc;
|
103 |
} |
104 |
} |