Revision 24:89b0b238f5aa
src/main/java/my/com/upass/MinimalUPassControllerV2.java | ||
---|---|---|
8 | 8 |
|
9 | 9 |
import my.com.upass.dao.ConfigurationDAO; |
10 | 10 |
import my.com.upass.dao.MinimalDAOFactory; |
11 |
import my.com.upass.maybank.entities.M2uUser;
|
|
11 |
import my.com.upass.pojo.AppAccessBean;
|
|
12 | 12 |
import my.com.upass.pojo.ConfigurationBean; |
13 |
import my.com.upass.pojo.MinimalUserBean; |
|
14 |
import my.com.upass.pojo.UserAppAccess; |
|
15 |
import my.com.upass.services.AppAccessMgtService; |
|
16 |
import my.com.upass.services.AppAccessMgtService.MultipleAppAccessesFound; |
|
13 | 17 |
import my.com.upass.services.CreateUserService; |
14 | 18 |
import my.com.upass.services.ModifyUserService; |
15 | 19 |
import my.com.upass.services.VerifyStaticPasswordService; |
20 |
import net.penril.generic.hibernate.HibernateUtils; |
|
16 | 21 |
|
17 | 22 |
import org.apache.commons.lang.NotImplementedException; |
18 | 23 |
import org.apache.log4j.Logger; |
24 |
import org.hibernate.Session; |
|
25 |
import org.hibernate.criterion.Restrictions; |
|
19 | 26 |
|
20 | 27 |
public class MinimalUPassControllerV2 { |
21 | 28 |
|
... | ... | |
25 | 32 |
protected VerifyStaticPasswordService verifyStaticPasswordService = new VerifyStaticPasswordService(this); |
26 | 33 |
protected CreateUserService createUserService = new CreateUserService(this); |
27 | 34 |
protected ModifyUserService modifyUserService = new ModifyUserService(this); |
35 |
protected AppAccessMgtService appAccessMgtService = new AppAccessMgtService(); |
|
28 | 36 |
|
29 | 37 |
protected void initializeConfigurations() { |
30 | 38 |
try |
... | ... | |
136 | 144 |
return rc; |
137 | 145 |
} |
138 | 146 |
|
147 |
public int addUser(String appAccessId, String hashedSecretKey, MinimalUserBean user) { |
|
148 |
|
|
149 |
final String userAlias = user.getUserAlias(); |
|
150 |
final String doubleHashedPassword = user.getPcipherText(); |
|
151 |
|
|
152 |
// check if password is similar to user alias |
|
153 |
if (userAlias.equalsIgnoreCase(doubleHashedPassword)) { |
|
154 |
return MinimalConstants.ERR_PASSWORD_SAMEAS_USERALIAS; |
|
155 |
} |
|
156 |
int rc = verifyStaticPasswordService.verifyStaticPassword( |
|
157 |
appAccessId, hashedSecretKey, true, MinimalConstants.UTYPE_STATE_USER); |
|
158 |
|
|
159 |
if (rc != MinimalConstants.ERR_SUCCESS) { |
|
160 |
return rc; |
|
161 |
} |
|
162 |
|
|
163 |
Integer appId = null; |
|
164 |
try { |
|
165 |
appId = appAccessMgtService.getAppIdForAdmin(appAccessId); |
|
166 |
|
|
167 |
if (appId == null) |
|
168 |
rc = MinimalConstants.ERR_APP_SERV_NOT_PERMITTED; |
|
169 |
|
|
170 |
else { |
|
171 |
user.setUserType(MinimalConstants.UTYPE_STATE_USER); |
|
172 |
user.setPstate(MinimalConstants.UID_STATE_ACTIVE); |
|
173 |
rc = createUserService.addUser(user, appId.intValue()); |
|
174 |
} |
|
175 |
|
|
176 |
} catch (MultipleAppAccessesFound e) { |
|
177 |
rc = MinimalConstants.ERR_APP_SERV_NOT_PERMITTED; |
|
178 |
e.printStackTrace(); |
|
179 |
} |
|
180 |
logger.info("UA_AddUser - user alias: [" + userAlias + "] Return: " + rc); |
|
181 |
return rc; |
|
182 |
} |
|
183 |
|
|
139 | 184 |
/** |
140 | 185 |
* This method verify static password generated using SP_ChangeStaticPassword(). |
141 | 186 |
* |
... | ... | |
207 | 252 |
|
208 | 253 |
return rc; |
209 | 254 |
} |
210 |
|
|
211 |
public int addUser(String appAccessId, String hashedSecretKey, M2uUser user) { |
|
212 |
// TODO Auto-generated method stub |
|
213 |
throw new NotImplementedException(); |
|
214 |
} |
|
215 |
|
|
216 | 255 |
} |
src/main/java/my/com/upass/dao/UserDAO.java | ||
---|---|---|
10 | 10 |
*/ |
11 | 11 |
|
12 | 12 |
package my.com.upass.dao; |
13 |
|
|
13 | 14 |
import java.util.List; |
14 | 15 |
|
15 | 16 |
import my.com.upass.pojo.MinimalUserBean; |
16 | 17 |
import my.com.upass.pojo.MinimalUserBeanBackup; |
18 |
import my.com.upass.pojo.UserAppAccess; |
|
17 | 19 |
import net.penril.generic.hibernate.GenericDAO; |
18 | 20 |
|
19 | 21 |
/** |
... | ... | |
29 | 31 |
/** |
30 | 32 |
* Represents the UPASS User Data Access Object |
31 | 33 |
*/ |
32 |
public interface UserDAO extends GenericDAO |
|
33 |
{ |
|
34 |
public MinimalUserBean getUserFromStore(String userAlias, int sqlMode); |
|
35 |
|
|
36 |
public MinimalUserBean getUserFromStore(String userAlias); |
|
37 |
|
|
38 |
public boolean updateUserToStore(MinimalUserBean MinimalUserBean); |
|
39 |
|
|
40 |
public boolean insertUserToStore(MinimalUserBean MinimalUserBean); |
|
41 |
|
|
42 |
public boolean deleteUser(MinimalUserBean MinimalUserBean); |
|
43 |
|
|
44 |
public boolean insertUserToBackupStore(MinimalUserBeanBackup MinimalUserBean); |
|
45 |
|
|
46 |
public MinimalUserBeanBackup getUserBackupFromStore(String userAlias); |
|
47 |
|
|
48 |
MinimalUserBean getTbAmUserByUserAlias (String userAlias) throws Exception; |
|
49 |
|
|
50 |
MinimalUserBean getTbAmUserByUserId (Long tUserId) throws Exception; |
|
51 |
|
|
52 |
void deleteTbAmUser (Integer tUserId) throws Exception; |
|
53 |
|
|
54 |
public List getAllUser () throws Exception; |
|
34 |
public interface UserDAO extends GenericDAO { |
|
35 |
|
|
36 |
MinimalUserBean getUserFromStore(String userAlias, int sqlMode); |
|
37 |
|
|
38 |
MinimalUserBean getUserFromStore(String userAlias); |
|
39 |
|
|
40 |
boolean updateUserToStore(MinimalUserBean MinimalUserBean); |
|
41 |
|
|
42 |
boolean insertUserToStore(MinimalUserBean MinimalUserBean); |
|
43 |
|
|
44 |
boolean deleteUser(MinimalUserBean MinimalUserBean); |
|
45 |
|
|
46 |
boolean insertUserToBackupStore(MinimalUserBeanBackup MinimalUserBean); |
|
47 |
|
|
48 |
MinimalUserBeanBackup getUserBackupFromStore(String userAlias); |
|
49 |
|
|
50 |
MinimalUserBean getTbAmUserByUserAlias(String userAlias) throws Exception; |
|
51 |
|
|
52 |
MinimalUserBean getTbAmUserByUserId(Long tUserId) throws Exception; |
|
53 |
|
|
54 |
void deleteTbAmUser(Integer tUserId) throws Exception; |
|
55 |
|
|
56 |
/** |
|
57 |
* @param appAccessId |
|
58 |
* @return a list of {@link UserAppAccess} objects |
|
59 |
* @throws Exception |
|
60 |
*/ |
|
61 |
List listUserAppAccesses(String appAccessId) throws Exception; |
|
62 |
|
|
63 |
/** |
|
64 |
* @param appAccessId |
|
65 |
* @param accessType |
|
66 |
* @return a list of {@link UserAppAccess} objects |
|
67 |
* @throws Exception |
|
68 |
*/ |
|
69 |
List listUserAppAccesses(String appAccessId, char accessType) throws Exception; |
|
55 | 70 |
} |
src/main/java/my/com/upass/dao/hibernate/UserDAOHibernate.java | ||
---|---|---|
17 | 17 |
import my.com.upass.dao.UserDAO; |
18 | 18 |
import my.com.upass.pojo.MinimalUserBean; |
19 | 19 |
import my.com.upass.pojo.MinimalUserBeanBackup; |
20 |
import my.com.upass.pojo.UserAppAccess; |
|
20 | 21 |
import net.penril.generic.hibernate.GenericDAOHibernate; |
22 |
import net.penril.generic.hibernate.HibernateUtils; |
|
21 | 23 |
|
22 | 24 |
import org.apache.log4j.Logger; |
23 | 25 |
import org.hibernate.Criteria; |
24 | 26 |
import org.hibernate.FetchMode; |
25 | 27 |
import org.hibernate.HibernateException; |
28 |
import org.hibernate.Query; |
|
26 | 29 |
import org.hibernate.Session; |
27 | 30 |
import org.hibernate.criterion.Restrictions; |
28 | 31 |
|
... | ... | |
32 | 35 |
* REASON(S): MODIFICATION: |
33 | 36 |
*/ |
34 | 37 |
|
35 |
public class UserDAOHibernate extends GenericDAOHibernate |
|
36 |
implements UserDAO |
|
37 |
{ |
|
38 |
private static Logger logger = Logger.getLogger (UserDAOHibernate.class); |
|
38 |
public class UserDAOHibernate |
|
39 |
extends GenericDAOHibernate |
|
40 |
implements UserDAO { |
|
41 |
|
|
42 |
private static Logger logger = Logger.getLogger(UserDAOHibernate.class); |
|
43 |
|
|
44 |
// |
|
45 |
|
|
46 |
public Class getEntityClass() { |
|
47 |
return MinimalUserBean.class; |
|
48 |
} |
|
39 | 49 |
|
40 | 50 |
/** |
41 | 51 |
* @see my.com.upass.dao.UserDAO#getUserFromStore(java.lang.String, int) |
42 | 52 |
*/ |
43 |
public MinimalUserBean getUserFromStore (String userAlias, int sqlMode)
|
|
44 |
{ |
|
53 |
public MinimalUserBean getUserFromStore(String userAlias, int sqlMode) {
|
|
54 |
|
|
45 | 55 |
MinimalUserBean profile = null; |
46 | 56 |
Criteria criteria; |
47 | 57 |
Session session = null; |
58 |
try { |
|
59 |
session = getSession(); |
|
60 |
criteria = session.createCriteria(MinimalUserBean.class); |
|
61 |
criteria.add(Restrictions.eq("userAlias", userAlias)); |
|
48 | 62 |
|
49 |
try |
|
50 |
{ |
|
51 |
session = getSession (); |
|
52 |
criteria = session.createCriteria (MinimalUserBean.class); |
|
53 |
criteria.add (Restrictions.eq ("userAlias", userAlias)); |
|
63 |
switch (sqlMode) { |
|
54 | 64 |
|
55 |
switch (sqlMode) |
|
56 |
{ |
|
57 |
case MinimalConstants.MODE_QTACBEAN: |
|
58 |
criteria.setFetchMode ("tacBean", FetchMode.JOIN); |
|
59 |
break; |
|
60 |
case MinimalConstants.MODE_QVASCOBEAN: |
|
61 |
criteria.setFetchMode ("upassUserTokens", FetchMode.JOIN); |
|
62 |
break; |
|
63 |
default: |
|
64 |
break; |
|
65 |
case MinimalConstants.MODE_QTACBEAN: |
|
66 |
criteria.setFetchMode("tacBean", FetchMode.JOIN); |
|
67 |
break; |
|
68 |
case MinimalConstants.MODE_QVASCOBEAN: |
|
69 |
criteria.setFetchMode("upassUserTokens", FetchMode.JOIN); |
|
70 |
break; |
|
71 |
default: |
|
72 |
break; |
|
65 | 73 |
} |
74 |
profile = (MinimalUserBean) criteria.uniqueResult(); |
|
66 | 75 |
|
67 |
profile = (MinimalUserBean) criteria.uniqueResult (); |
|
68 |
} |
|
69 |
catch (Exception e) |
|
70 |
{ |
|
71 |
logger.error (e, e); |
|
72 |
} |
|
73 |
finally |
|
74 |
{ |
|
75 |
if (session != null && session.isConnected ()) |
|
76 |
{ |
|
77 |
session.close (); |
|
76 |
} catch (Exception e) { |
|
77 |
logger.error(e, e); |
|
78 |
|
|
79 |
} finally { |
|
80 |
if (session != null && session.isConnected()) { |
|
81 |
session.close(); |
|
78 | 82 |
} |
79 | 83 |
} |
80 |
|
|
81 | 84 |
return profile; |
82 | 85 |
} |
83 | 86 |
|
84 | 87 |
/** |
85 | 88 |
* @see my.com.upass.dao.UserDAO#getUserFromStore(java.lang.String) |
86 | 89 |
*/ |
87 |
public MinimalUserBean getUserFromStore (String userAlias) |
|
88 |
{ |
|
89 |
return getUserFromStore (userAlias, MinimalConstants.MODE_QUSERBEAN); |
|
90 |
public MinimalUserBean getUserFromStore(String userAlias) { |
|
91 |
return getUserFromStore(userAlias, MinimalConstants.MODE_QUSERBEAN); |
|
90 | 92 |
} |
91 | 93 |
|
92 | 94 |
/** |
93 | 95 |
* @see my.com.upass.dao.UserDAO#updateUserToStore(my.com.upass.pojo.MinimalUserBean) |
94 | 96 |
*/ |
95 |
public boolean updateUserToStore (MinimalUserBean userBean) |
|
96 |
{ |
|
97 |
public boolean updateUserToStore(MinimalUserBean userBean) { |
|
97 | 98 |
boolean isUpdated = false; |
98 | 99 |
Session session = null; |
100 |
try { |
|
101 |
session = getSession(); |
|
102 |
session.beginTransaction(); |
|
103 |
session.update(userBean); |
|
104 |
session.getTransaction().commit(); |
|
105 |
isUpdated = true; |
|
99 | 106 |
|
100 |
try |
|
101 |
{ |
|
102 |
session = getSession (); |
|
103 |
session.beginTransaction (); |
|
104 |
session.update (userBean); |
|
105 |
session.getTransaction ().commit (); |
|
106 |
isUpdated = true; |
|
107 |
} |
|
108 |
catch (Exception e) |
|
109 |
{ |
|
110 |
logger.error (e, e); |
|
111 |
if (e instanceof HibernateException) |
|
112 |
{ |
|
113 |
if (session != null) |
|
114 |
{ |
|
115 |
session.getTransaction ().rollback (); |
|
107 |
} catch (Exception e) { |
|
108 |
logger.error(e, e); |
|
109 |
if (e instanceof HibernateException) { |
|
110 |
if (session != null) { |
|
111 |
session.getTransaction().rollback(); |
|
116 | 112 |
} |
117 | 113 |
} |
118 |
} |
|
119 |
finally |
|
120 |
{ |
|
121 |
if (session != null && session.isConnected ()) |
|
122 |
{ |
|
123 |
session.close (); |
|
114 |
} finally { |
|
115 |
if (session != null && session.isConnected()) { |
|
116 |
session.close(); |
|
124 | 117 |
} |
125 | 118 |
} |
126 | 119 |
return isUpdated; |
... | ... | |
129 | 122 |
/** |
130 | 123 |
* @see my.com.upass.dao.UserDAO#insertUserToStore(my.com.upass.pojo.MinimalUserBean) |
131 | 124 |
*/ |
132 |
public boolean insertUserToStore (MinimalUserBean userBean) |
|
133 |
{ |
|
125 |
public boolean insertUserToStore(MinimalUserBean userBean) { |
|
134 | 126 |
boolean isCreated = false; |
135 | 127 |
Session session = null; |
128 |
try { |
|
129 |
session = getSession(); |
|
130 |
session.beginTransaction(); |
|
131 |
session.save(userBean); |
|
132 |
session.getTransaction().commit(); |
|
133 |
isCreated = true; |
|
136 | 134 |
|
137 |
try |
|
138 |
{ |
|
139 |
session = getSession (); |
|
140 |
session.beginTransaction (); |
|
141 |
session.save (userBean); |
|
142 |
session.getTransaction ().commit (); |
|
143 |
isCreated = true; |
|
144 |
} |
|
145 |
catch (Exception e) |
|
146 |
{ |
|
147 |
if (e instanceof HibernateException) |
|
148 |
{ |
|
149 |
if (session != null) |
|
150 |
{ |
|
151 |
session.getTransaction ().rollback (); |
|
135 |
} catch (Exception e) { |
|
136 |
if (e instanceof HibernateException) { |
|
137 |
if (session != null) { |
|
138 |
session.getTransaction().rollback(); |
|
152 | 139 |
} |
153 | 140 |
} |
154 |
logger.error (e, e); |
|
155 |
} |
|
156 |
finally |
|
157 |
{ |
|
158 |
if (session != null && session.isConnected ()) |
|
159 |
{ |
|
160 |
session.close (); |
|
141 |
logger.error(e, e); |
|
142 |
|
|
143 |
} finally { |
|
144 |
if (session != null && session.isConnected()) { |
|
145 |
session.close(); |
|
161 | 146 |
} |
162 | 147 |
} |
163 | 148 |
return isCreated; |
... | ... | |
166 | 151 |
/** |
167 | 152 |
* @see my.com.upass.dao.UserDAO#updateUserToStore(my.com.upass.pojo.MinimalUserBean) |
168 | 153 |
*/ |
169 |
public boolean deleteUser (MinimalUserBean userBean) |
|
170 |
{ |
|
154 |
public boolean deleteUser(MinimalUserBean userBean) { |
|
171 | 155 |
boolean isUpdated = false; |
172 | 156 |
Session session = null; |
157 |
try { |
|
158 |
session = getSession(); |
|
159 |
session.beginTransaction(); |
|
160 |
session.delete(userBean); |
|
161 |
session.getTransaction().commit(); |
|
162 |
isUpdated = true; |
|
173 | 163 |
|
174 |
try |
|
175 |
{ |
|
176 |
session = getSession (); |
|
177 |
session.beginTransaction (); |
|
178 |
session.delete (userBean); |
|
179 |
session.getTransaction ().commit (); |
|
180 |
isUpdated = true; |
|
181 |
} |
|
182 |
catch (Exception e) |
|
183 |
{ |
|
184 |
if (e instanceof HibernateException) |
|
185 |
{ |
|
186 |
if (session != null) |
|
187 |
{ |
|
188 |
session.getTransaction ().rollback (); |
|
164 |
} catch (Exception e) { |
|
165 |
if (e instanceof HibernateException) { |
|
166 |
if (session != null) { |
|
167 |
session.getTransaction().rollback(); |
|
189 | 168 |
} |
190 | 169 |
} |
191 |
logger.error (e, e); |
|
192 |
} |
|
193 |
finally |
|
194 |
{ |
|
195 |
if (session != null && session.isConnected ()) |
|
196 |
{ |
|
197 |
session.close (); |
|
170 |
logger.error(e, e); |
|
171 |
|
|
172 |
} finally { |
|
173 |
if (session != null && session.isConnected()) { |
|
174 |
session.close(); |
|
198 | 175 |
} |
199 | 176 |
} |
200 | 177 |
return isUpdated; |
... | ... | |
203 | 180 |
/** |
204 | 181 |
* @see my.com.upass.dao.UserDAO#insertUserToStore(my.com.upass.pojo.MinimalUserBean) |
205 | 182 |
*/ |
206 |
public boolean insertUserToBackupStore (MinimalUserBeanBackup userBean) |
|
207 |
{ |
|
183 |
public boolean insertUserToBackupStore(MinimalUserBeanBackup userBean) { |
|
208 | 184 |
boolean isCreated = false; |
209 | 185 |
Session session = null; |
186 |
try { |
|
187 |
session = getSession(); |
|
188 |
session.beginTransaction(); |
|
189 |
session.save(userBean); |
|
190 |
session.getTransaction().commit(); |
|
191 |
isCreated = true; |
|
210 | 192 |
|
211 |
try |
|
212 |
{ |
|
213 |
session = getSession (); |
|
214 |
session.beginTransaction (); |
|
215 |
session.save (userBean); |
|
216 |
session.getTransaction ().commit (); |
|
217 |
isCreated = true; |
|
218 |
} |
|
219 |
catch (Exception e) |
|
220 |
{ |
|
221 |
if (e instanceof HibernateException) |
|
222 |
{ |
|
223 |
if (session != null) |
|
224 |
{ |
|
225 |
session.getTransaction ().rollback (); |
|
193 |
} catch (Exception e) { |
|
194 |
if (e instanceof HibernateException) { |
|
195 |
if (session != null) { |
|
196 |
session.getTransaction().rollback(); |
|
226 | 197 |
} |
227 | 198 |
} |
228 |
logger.error (e, e); |
|
229 |
} |
|
230 |
finally |
|
231 |
{ |
|
232 |
if (session != null && session.isConnected ()) |
|
233 |
{ |
|
234 |
session.close (); |
|
199 |
logger.error(e, e); |
|
200 |
|
|
201 |
} finally { |
|
202 |
if (session != null && session.isConnected()) { |
|
203 |
session.close(); |
|
235 | 204 |
} |
236 | 205 |
} |
237 | 206 |
return isCreated; |
238 | 207 |
} |
239 | 208 |
|
240 |
public MinimalUserBeanBackup getUserBackupFromStore (String userAlias)
|
|
241 |
{ |
|
209 |
public MinimalUserBeanBackup getUserBackupFromStore(String userAlias) {
|
|
210 |
|
|
242 | 211 |
MinimalUserBeanBackup profile = null; |
243 | 212 |
Criteria criteria; |
244 | 213 |
Session session = null; |
214 |
try { |
|
215 |
session = getSession(); |
|
216 |
criteria = session.createCriteria(MinimalUserBeanBackup.class); |
|
217 |
criteria.add(Restrictions.eq("userAlias", userAlias)); |
|
245 | 218 |
|
246 |
try |
|
247 |
{ |
|
248 |
session = getSession (); |
|
249 |
criteria = session.createCriteria (MinimalUserBeanBackup.class); |
|
250 |
criteria.add (Restrictions.eq ("userAlias", userAlias)); |
|
219 |
profile = (MinimalUserBeanBackup) criteria.uniqueResult(); |
|
251 | 220 |
|
252 |
profile = (MinimalUserBeanBackup) criteria.uniqueResult (); |
|
253 |
} |
|
254 |
catch (Exception e) |
|
255 |
{ |
|
256 |
logger.error (e, e); |
|
257 |
} |
|
258 |
finally |
|
259 |
{ |
|
260 |
if (session != null && session.isConnected ()) |
|
261 |
{ |
|
262 |
session.close (); |
|
221 |
} catch (Exception e) { |
|
222 |
logger.error(e, e); |
|
223 |
|
|
224 |
} finally { |
|
225 |
if (session != null && session.isConnected()) { |
|
226 |
session.close(); |
|
263 | 227 |
} |
264 | 228 |
} |
265 |
|
|
266 | 229 |
return profile; |
267 | 230 |
} |
268 | 231 |
|
269 |
public MinimalUserBean getTbAmUserByUserAlias (String userAlias) throws Exception
|
|
270 |
{ |
|
232 |
public MinimalUserBean getTbAmUserByUserAlias(String userAlias) throws Exception {
|
|
233 |
|
|
271 | 234 |
MinimalUserBean TbAmUser; |
272 |
try |
|
273 |
{ |
|
274 |
getSession ().beginTransaction (); |
|
235 |
try { |
|
236 |
getSession().beginTransaction(); |
|
275 | 237 |
|
276 |
Criteria m_oCriteria = getSession () |
|
277 |
.createCriteria (MinimalUserBean.class); |
|
278 |
m_oCriteria.add (Restrictions.eq ("userAlias", userAlias)); |
|
279 |
TbAmUser = (MinimalUserBean) m_oCriteria.uniqueResult (); |
|
238 |
Criteria m_oCriteria = getSession().createCriteria(MinimalUserBean.class); |
|
239 |
m_oCriteria.add(Restrictions.eq("userAlias", userAlias)); |
|
240 |
TbAmUser = (MinimalUserBean) m_oCriteria.uniqueResult(); |
|
280 | 241 |
|
281 |
getSession ().getTransaction ().commit (); |
|
282 |
} |
|
283 |
catch (Exception e) |
|
284 |
{ |
|
285 |
if (e instanceof HibernateException) |
|
286 |
{ |
|
287 |
getSession ().getTransaction ().rollback (); |
|
242 |
getSession().getTransaction().commit(); |
|
243 |
|
|
244 |
} catch (Exception e) { |
|
245 |
if (e instanceof HibernateException) { |
|
246 |
getSession().getTransaction().rollback(); |
|
288 | 247 |
} |
289 | 248 |
throw e; |
290 |
} |
|
291 |
finally |
|
292 |
{ |
|
293 |
getSession ().close (); |
|
249 |
|
|
250 |
} finally { |
|
251 |
getSession().close(); |
|
294 | 252 |
} |
295 | 253 |
return TbAmUser; |
296 | 254 |
} |
297 | 255 |
|
298 |
public MinimalUserBean getTbAmUserByUserId (Long tUserId) throws Exception |
|
299 |
{ |
|
256 |
public MinimalUserBean getTbAmUserByUserId(Long tUserId) throws Exception { |
|
300 | 257 |
MinimalUserBean TbAmUser; |
301 |
try |
|
302 |
{ |
|
303 |
getSession ().beginTransaction (); |
|
258 |
try { |
|
259 |
getSession().beginTransaction(); |
|
304 | 260 |
|
305 |
Criteria m_oCriteria = getSession () |
|
306 |
.createCriteria (MinimalUserBean.class); |
|
307 |
m_oCriteria |
|
308 |
.add (Restrictions.eq ("userID", tUserId)); |
|
309 |
TbAmUser = (MinimalUserBean) m_oCriteria.uniqueResult (); |
|
261 |
Criteria m_oCriteria = getSession().createCriteria(MinimalUserBean.class); |
|
262 |
m_oCriteria.add(Restrictions.eq("userID", tUserId)); |
|
263 |
TbAmUser = (MinimalUserBean) m_oCriteria.uniqueResult(); |
|
310 | 264 |
|
311 |
getSession ().getTransaction ().commit (); |
|
312 |
} |
|
313 |
catch (Exception e) |
|
314 |
{ |
|
315 |
if (e instanceof HibernateException) |
|
316 |
{ |
|
317 |
getSession ().getTransaction ().rollback (); |
|
265 |
getSession().getTransaction().commit(); |
|
266 |
|
|
267 |
} catch (Exception e) { |
|
268 |
if (e instanceof HibernateException) { |
|
269 |
getSession().getTransaction().rollback(); |
|
318 | 270 |
} |
319 | 271 |
throw e; |
320 |
} |
|
321 |
finally |
|
322 |
{ |
|
323 |
getSession ().close (); |
|
272 |
|
|
273 |
} finally { |
|
274 |
getSession().close(); |
|
324 | 275 |
} |
325 | 276 |
return TbAmUser; |
326 | 277 |
} |
327 | 278 |
|
328 |
public void deleteTbAmUser (Integer tUserId) throws Exception |
|
329 |
{ |
|
279 |
public void deleteTbAmUser(Integer tUserId) throws Exception { |
|
330 | 280 |
// ID ID = tUserId; |
331 |
Long ID = Long.valueOf (String.valueOf (tUserId));
|
|
281 |
Long ID = Long.valueOf(String.valueOf(tUserId));
|
|
332 | 282 |
MinimalUserBean tbAmUser; |
333 |
try |
|
334 |
{ |
|
335 |
getSession ().beginTransaction (); |
|
336 |
Criteria m_oCriteria = getSession () |
|
337 |
.createCriteria (MinimalUserBean.class); |
|
338 |
m_oCriteria.add (Restrictions.eq ("userId", ID)); |
|
339 |
tbAmUser = (MinimalUserBean) m_oCriteria.uniqueResult (); |
|
283 |
try { |
|
284 |
getSession().beginTransaction(); |
|
285 |
Criteria m_oCriteria = getSession() |
|
286 |
.createCriteria(MinimalUserBean.class); |
|
287 |
m_oCriteria.add(Restrictions.eq("userId", ID)); |
|
288 |
tbAmUser = (MinimalUserBean) m_oCriteria.uniqueResult(); |
|
340 | 289 |
|
341 |
makeTransient (tbAmUser); |
|
342 |
getSession ().getTransaction ().commit (); |
|
343 |
getSession ().close (); |
|
344 |
} |
|
345 |
catch (Exception e) |
|
346 |
{ |
|
347 |
getSession ().getTransaction ().rollback (); |
|
290 |
makeTransient(tbAmUser); |
|
291 |
getSession().getTransaction().commit(); |
|
292 |
getSession().close(); |
|
293 |
|
|
294 |
} catch (Exception e) { |
|
295 |
getSession().getTransaction().rollback(); |
|
348 | 296 |
throw e; |
349 |
} |
|
350 |
finally |
|
351 |
{ |
|
352 |
getSession ().close (); |
|
297 |
|
|
298 |
} finally { |
|
299 |
getSession().close(); |
|
353 | 300 |
} |
354 | 301 |
} |
355 |
|
|
356 |
public List getAllUser () |
|
357 |
{ |
|
358 |
List profile = null; |
|
359 |
Criteria criteria; |
|
302 |
|
|
303 |
public List listUserAppAccesses(String appAccessId) throws Exception { |
|
304 |
List accesses = null; |
|
360 | 305 |
Session session = null; |
306 |
try { |
|
307 |
session = getSession(); |
|
308 |
Query query = session.createQuery( |
|
309 |
"FROM UserAppAccess aa WHERE aa.user.userAlias = :userAlias"); |
|
310 |
accesses = query.setString("userAlias", appAccessId).list(); |
|
361 | 311 |
|
362 |
try |
|
363 |
{ |
|
364 |
session = getSession (); |
|
365 |
criteria = session.createCriteria (MinimalUserBean.class); |
|
366 |
|
|
367 |
profile = criteria.list(); |
|
368 |
|
|
312 |
} finally { |
|
313 |
if (session != null) |
|
314 |
session.close(); |
|
369 | 315 |
} |
370 |
catch (Exception e) |
|
371 |
{ |
|
372 |
logger.error (e, e); |
|
373 |
} |
|
374 |
finally |
|
375 |
{ |
|
376 |
if (session != null && session.isConnected ()) |
|
377 |
{ |
|
378 |
session.close (); |
|
379 |
} |
|
380 |
} |
|
381 |
|
|
382 |
return profile; |
|
316 |
return accesses; |
|
383 | 317 |
} |
384 | 318 |
|
385 |
public Class getEntityClass() { |
|
386 |
return MinimalUserBean.class; |
|
319 |
/** |
|
320 |
* |
|
321 |
* @param appAccessId |
|
322 |
* @param type |
|
323 |
* One of the following values: <br> |
|
324 |
* {@link UserAppAccess#TYPE_ADMIN} <br> |
|
325 |
* {@link UserAppAccess#TYPE_USER} |
|
326 |
*/ |
|
327 |
public List listUserAppAccesses(String appAccessId, char accessType) throws Exception { |
|
328 |
List accesses = null; |
|
329 |
Session session = null; |
|
330 |
try { |
|
331 |
session = getSession(); |
|
332 |
Query query = session.createQuery( |
|
333 |
"FROM UserAppAccess aa " |
|
334 |
+ "WHERE aa.user.userAlias = :userAlias " |
|
335 |
+ "AND aa.accessType = :type"); |
|
336 |
|
|
337 |
accesses = query |
|
338 |
.setString("userAlias", appAccessId) |
|
339 |
.setCharacter("accessType", accessType) |
|
340 |
.list(); |
|
341 |
|
|
342 |
} finally { |
|
343 |
if (session != null) |
|
344 |
session.close(); |
|
345 |
} |
|
346 |
return accesses; |
|
387 | 347 |
} |
388 |
|
|
389 | 348 |
} |
src/main/java/my/com/upass/maybank/MinimalMaybankFacadeImpl.java | ||
---|---|---|
26 | 26 |
String appAccessId, String hashedSecretKey, |
27 | 27 |
String username, String hashedPassword, String pan1, String pan2) { |
28 | 28 |
|
29 |
M2uUser user = new M2uUser(); |
|
30 |
user.setUsername(username); |
|
31 |
user.setHashedPassword(hashedPassword); |
|
32 |
user.setPan1(pan1); |
|
33 |
user.setPan2(pan2); |
|
34 |
return minUpcV2.addUser(appAccessId, hashedSecretKey, user); |
|
29 |
M2uUser m2uUser = new M2uUser(); |
|
30 |
m2uUser.getMaybankUser().setUsername(username); |
|
31 |
m2uUser.getMaybankUser().setHashedPassword(hashedPassword); |
|
32 |
m2uUser.setPan1(pan1); |
|
33 |
m2uUser.setPan2(pan2); |
|
34 |
final int rc = minUpcV2.addUser(appAccessId, hashedSecretKey, m2uUser.getMaybankUser()); |
|
35 |
// TODO: update user profile data as well |
|
36 |
return rc; |
|
35 | 37 |
} |
36 | 38 |
|
37 | 39 |
public int newPublicUser( |
src/main/java/my/com/upass/maybank/entities/IbccAdminUser.java | ||
---|---|---|
1 | 1 |
package my.com.upass.maybank.entities; |
2 | 2 |
|
3 |
public class IbccAdminUser extends MaybankUser { |
|
3 |
import java.io.Serializable; |
|
4 |
|
|
5 |
public class IbccAdminUser implements Serializable { |
|
6 |
|
|
7 |
private static final long serialVersionUID = 1L; |
|
8 |
|
|
9 |
private MaybankUser maybankUser; |
|
10 |
|
|
11 |
// |
|
12 |
|
|
13 |
public MaybankUser getMaybankUser() { |
|
14 |
return maybankUser; |
|
15 |
} |
|
16 |
|
|
17 |
public void setMaybankUser(MaybankUser maybankUser) { |
|
18 |
this.maybankUser = maybankUser; |
|
19 |
} |
|
4 | 20 |
} |
src/main/java/my/com/upass/maybank/entities/IbccPublicUser.java | ||
---|---|---|
1 | 1 |
package my.com.upass.maybank.entities; |
2 | 2 |
|
3 |
public class IbccPublicUser extends MaybankUser {
|
|
3 |
import java.io.Serializable;
|
|
4 | 4 |
|
5 |
public class IbccPublicUser implements Serializable { |
|
6 |
|
|
7 |
private static final long serialVersionUID = 1L; |
|
8 |
|
|
9 |
private MaybankUser maybankUser; |
|
5 | 10 |
private String panCc; |
6 |
|
|
11 |
|
|
7 | 12 |
// |
8 | 13 |
|
9 | 14 |
public String getPanCc() { |
... | ... | |
13 | 18 |
public void setPanCc(String panCc) { |
14 | 19 |
this.panCc = panCc; |
15 | 20 |
} |
21 |
|
|
22 |
public MaybankUser getMaybankUser() { |
|
23 |
return maybankUser; |
|
24 |
} |
|
25 |
|
|
26 |
public void setMaybankUser(MaybankUser maybankUser) { |
|
27 |
this.maybankUser = maybankUser; |
|
28 |
} |
|
16 | 29 |
} |
src/main/java/my/com/upass/maybank/entities/Im2uUser.java | ||
---|---|---|
1 | 1 |
package my.com.upass.maybank.entities; |
2 | 2 |
|
3 |
public class Im2uUser extends MaybankUser {
|
|
3 |
import java.io.Serializable;
|
|
4 | 4 |
|
5 |
public class Im2uUser implements Serializable { |
|
6 |
|
|
7 |
private static final long serialVersionUID = 1L; |
|
8 |
|
|
9 |
private MaybankUser maybankUser; |
|
5 | 10 |
private String wsFlag; |
6 | 11 |
private String wsIdentCode; |
7 | 12 |
private String wsMySgId; |
... | ... | |
40 | 45 |
public void setWsRegTimeStamp(String wsRegTimeStamp) { |
41 | 46 |
this.wsRegTimeStamp = wsRegTimeStamp; |
42 | 47 |
} |
48 |
|
|
49 |
public MaybankUser getMaybankUser() { |
|
50 |
return maybankUser; |
|
51 |
} |
|
52 |
|
|
53 |
public void setMaybankUser(MaybankUser maybankUser) { |
|
54 |
this.maybankUser = maybankUser; |
|
55 |
} |
|
43 | 56 |
} |
src/main/java/my/com/upass/maybank/entities/M2uUser.java | ||
---|---|---|
1 | 1 |
package my.com.upass.maybank.entities; |
2 | 2 |
|
3 |
public class M2uUser extends MaybankUser {
|
|
3 |
import java.io.Serializable;
|
|
4 | 4 |
|
5 |
public class M2uUser implements Serializable { |
|
6 |
|
|
7 |
private static final long serialVersionUID = 1L; |
|
8 |
|
|
9 |
private MaybankUser maybankUser; |
|
5 | 10 |
private String pan1; |
6 | 11 |
private String pan2; |
7 | 12 |
|
... | ... | |
23 | 28 |
this.pan2 = pan2; |
24 | 29 |
} |
25 | 30 |
|
31 |
public MaybankUser getMaybankUser() { |
|
32 |
return maybankUser; |
|
33 |
} |
|
34 |
|
|
35 |
public void setMaybankUser(MaybankUser maybankUser) { |
|
36 |
this.maybankUser = maybankUser; |
|
37 |
} |
|
38 |
|
|
26 | 39 |
} |
src/main/java/my/com/upass/maybank/entities/MaybankUser.java | ||
---|---|---|
4 | 4 |
|
5 | 5 |
public class MaybankUser extends MinimalUserBean { |
6 | 6 |
|
7 |
private static final long serialVersionUID = 1L; |
|
8 |
|
|
9 |
// |
|
10 |
|
|
7 | 11 |
public String getUsername() { |
8 | 12 |
return getUserAlias(); |
9 | 13 |
} |
src/main/java/my/com/upass/maybank/entities/StockUser.java | ||
---|---|---|
1 | 1 |
package my.com.upass.maybank.entities; |
2 | 2 |
|
3 |
public class StockUser extends M2uUser {
|
|
3 |
import java.io.Serializable;
|
|
4 | 4 |
|
5 |
public class StockUser implements Serializable { |
|
6 |
|
|
7 |
private static final long serialVersionUID = 1L; |
|
8 |
|
|
9 |
private M2uUser m2uUser; |
|
5 | 10 |
private String palAccountNo; |
6 | 11 |
private String stAccountNo; |
7 | 12 |
private String idNo; |
... | ... | |
49 | 54 |
public void setCustType(String custType) { |
50 | 55 |
this.custType = custType; |
51 | 56 |
} |
57 |
|
|
58 |
public M2uUser getM2uUser() { |
|
59 |
return m2uUser; |
|
60 |
} |
|
61 |
|
|
62 |
public void setM2uUser(M2uUser m2uUser) { |
|
63 |
this.m2uUser = m2uUser; |
|
64 |
} |
|
52 | 65 |
} |
src/main/java/my/com/upass/maybank/entities/TicketingUser.java | ||
---|---|---|
1 | 1 |
package my.com.upass.maybank.entities; |
2 | 2 |
|
3 |
public class TicketingUser extends MaybankUser {
|
|
3 |
import java.io.Serializable;
|
|
4 | 4 |
|
5 |
public class TicketingUser implements Serializable { |
|
6 |
|
|
7 |
private static final long serialVersionUID = 1L; |
|
8 |
|
|
9 |
private MaybankUser maybankUser; |
|
5 | 10 |
private String fullName; |
6 | 11 |
private String firstName; |
7 | 12 |
private String lastName; |
... | ... | |
40 | 45 |
public void setPayeeCode(String payeeCode) { |
41 | 46 |
this.payeeCode = payeeCode; |
42 | 47 |
} |
48 |
|
|
49 |
public MaybankUser getMaybankUser() { |
|
50 |
return maybankUser; |
|
51 |
} |
|
52 |
|
|
53 |
public void setMaybankUser(MaybankUser maybankUser) { |
|
54 |
this.maybankUser = maybankUser; |
|
55 |
} |
|
43 | 56 |
} |
src/main/java/my/com/upass/pojo/UserAppAccess.java | ||
---|---|---|
3 | 3 |
import java.util.Date; |
4 | 4 |
|
5 | 5 |
public class UserAppAccess { |
6 |
|
|
6 |
|
|
7 | 7 |
public static final char TYPE_ADMIN = 'A'; |
8 | 8 |
public static final char TYPE_USER = 'U'; |
9 |
|
|
10 |
// |
|
11 |
|
|
12 |
private long userId; |
|
13 |
private long appId; |
|
14 |
|
|
15 |
/** |
|
16 |
* Either {@link #TYPE_ADMIN} or {@link #TYPE_USER} |
|
17 |
*/ |
|
18 |
private char userType; |
|
19 |
private Date registerationTime; |
|
20 | 9 |
|
21 | 10 |
// |
22 | 11 |
|
23 |
public long getUserId() { |
|
12 |
private int userId; |
|
13 |
private int appId; |
|
14 |
|
|
15 |
/** |
|
16 |
* Either {@link #TYPE_ADMIN} or {@link #TYPE_USER} |
|
17 |
*/ |
|
18 |
private char accessType; |
|
19 |
private Date registerationTime; |
|
20 |
|
|
21 |
private MinimalUserBean user; |
|
22 |
private ClientApp app; |
|
23 |
|
|
24 |
// |
|
25 |
|
|
26 |
public int getUserId() { |
|
24 | 27 |
return userId; |
25 | 28 |
} |
26 | 29 |
|
27 |
public void setUserId(long userId) {
|
|
30 |
public void setUserId(int userId) {
|
|
28 | 31 |
this.userId = userId; |
29 | 32 |
} |
30 | 33 |
|
31 |
public long getAppId() {
|
|
34 |
public int getAppId() {
|
|
32 | 35 |
return appId; |
33 | 36 |
} |
34 | 37 |
|
35 |
public void setAppId(long appId) {
|
|
38 |
public void setAppId(int appId) {
|
|
36 | 39 |
this.appId = appId; |
37 | 40 |
} |
38 | 41 |
|
39 |
public char getUserType() {
|
|
40 |
return userType;
|
|
42 |
public char getAccessType() {
|
|
43 |
return accessType;
|
|
41 | 44 |
} |
42 | 45 |
|
43 |
public void setUserType(char userType) {
|
|
44 |
this.userType = userType;
|
|
46 |
public void setAccessType(char userType) {
|
|
47 |
this.accessType = userType;
|
|
45 | 48 |
} |
46 | 49 |
|
47 | 50 |
public Date getRegisterationTime() { |
... | ... | |
51 | 54 |
public void setRegisterationTime(Date registerationTs) { |
52 | 55 |
this.registerationTime = registerationTs; |
53 | 56 |
} |
57 |
|
|
58 |
public MinimalUserBean getUser() { |
|
59 |
return user; |
|
60 |
} |
|
61 |
|
|
62 |
public void setUser(MinimalUserBean user) { |
|
63 |
this.user = user; |
|
64 |
} |
|
65 |
|
|
66 |
public ClientApp getApp() { |
|
67 |
return app; |
|
68 |
} |
|
69 |
|
|
70 |
public void setApp(ClientApp app) { |
|
71 |
this.app = app; |
|
72 |
} |
|
54 | 73 |
} |
src/main/java/my/com/upass/services/AppAccessMgtService.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (c) 2013 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 java.util.List; |
|
15 |
|
|
16 |
import my.com.upass.MinimalConstants; |
|
17 |
import my.com.upass.MinimalUPassControllerV2; |
|
18 |
import my.com.upass.dao.MinimalDAOFactory; |
|
19 |
import my.com.upass.dao.UserDAO; |
|
20 |
import my.com.upass.pojo.UserAppAccess; |
|
21 |
|
|
22 |
/** |
|
23 |
* PROGRAMMER: Hadi |
|
24 |
* CHANGE-NO: |
|
25 |
* TASK-NO: |
|
26 |
* DATE CREATED: Aug 27, 2013 |
|
27 |
* TAG AS: |
|
28 |
* REASON(S): |
|
29 |
* MODIFICATION: |
|
30 |
*/ |
|
31 |
|
|
32 |
public class AppAccessMgtService { |
|
33 |
|
|
34 |
public Integer getAppIdForAdmin(String appAccessId) throws MultipleAppAccessesFound { |
|
35 |
|
|
36 |
Integer appId = null; |
|
37 |
UserDAO userDao; |
|
38 |
try { |
|
39 |
userDao = MinimalDAOFactory.minimalInstance().getUserDAO(); |
|
40 |
List accessList = userDao.listUserAppAccesses(appAccessId, UserAppAccess.TYPE_ADMIN); |
|
41 |
|
|
42 |
if (accessList.size() > 1) |
|
43 |
throw new MultipleAppAccessesFound(); |
|
44 |
|
|
45 |
if (accessList.size() == 1) { |
|
46 |
final UserAppAccess appAccess = (UserAppAccess) accessList.get(0); |
|
47 |
appId = new Integer(appAccess.getAppId()); |
|
48 |
} |
|
49 |
} catch (Exception e) { |
|
50 |
e.printStackTrace(); |
|
51 |
} |
|
52 |
return appId; |
|
53 |
} |
|
54 |
|
|
55 |
// |
|
56 |
|
|
57 |
public class MultipleAppAccessesFound extends Exception { |
|
58 |
|
|
59 |
} |
|
60 |
} |
src/main/java/my/com/upass/services/CreateUserService.java | ||
---|---|---|
34 | 34 |
/** |
35 | 35 |
* <Class description> |
36 | 36 |
*/ |
37 |
public class CreateUserService |
|
38 |
{ |
|
37 |
public class CreateUserService {
|
|
38 |
|
|
39 | 39 |
private MinimalUPassControllerV2 upc; |
40 |
|
|
41 |
public CreateUserService(MinimalUPassControllerV2 upc) |
|
42 |
{ |
|
40 |
|
|
41 |
public CreateUserService(MinimalUPassControllerV2 upc) { |
|
43 | 42 |
this.upc = upc; |
44 | 43 |
} |
45 |
|
|
46 |
public int addUser (String userAlias, int userType, String userDesc, |
|
47 |
String userPassword, int userState, int applicationId) |
|
48 |
{ |
|
44 |
|
|
45 |
public int addUser( |
|
46 |
String userAlias, int userType, String userDesc, |
|
47 |
String userPassword, int userState, int applicationId) { |
|
48 |
|
|
49 | 49 |
int rc = MinimalConstants.ERR_SYSTEM_NOT_READY; |
50 | 50 |
|
51 |
if (userAlias == null || userPassword == null) |
|
52 |
{ |
|
51 |
if (userAlias == null || userPassword == null) { |
|
53 | 52 |
return MinimalConstants.ERR_INVALID_INPUT; |
54 | 53 |
} |
54 |
UserDAO userDao; |
|
55 |
try { |
|
56 |
userDao = MinimalDAOFactory.minimalInstance().getUserDAO(); |
|
55 | 57 |
|
56 |
UserDAO userDao;
|
|
58 |
MinimalUserBean ub = userDao.getUserFromStore(userAlias);
|
|
57 | 59 |
|
58 |
try |
|
59 |
{ |
|
60 |
userDao = MinimalDAOFactory.minimalInstance().getUserDAO (); |
|
61 |
|
|
62 |
MinimalUserBean ub = userDao.getUserFromStore (userAlias); |
|
63 |
|
|
64 |
if(ub == null) |
|
65 |
{ |
|
66 |
long nextVal = userDao.getNextSequenceNumber ("SEQ_USER_ID_SEQ_VALUE_SEQ"); |
|
67 |
|
|
68 |
ub = new MinimalUserBean (); |
|
69 |
ub.setUserID (nextVal); |
|
70 |
ub.setUserAlias (userAlias); |
|
71 |
ub.setDescription (userDesc); |
|
72 |
ub.setUserType (userType); |
|
73 |
ub.setUstate (userState); |
|
74 |
ub.setUdateCreated (new Date()); |
|
75 |
ub.setPdateCreated (new Date()); |
|
60 |
if (ub == null) { |
|
61 |
long nextVal = userDao.getNextSequenceNumber("SEQ_USER_ID_SEQ_VALUE_SEQ"); |
|
62 |
|
|
63 |
ub = new MinimalUserBean(); |
|
64 |
ub.setUserID(nextVal); |
|
65 |
ub.setUserAlias(userAlias); |
|
66 |
ub.setDescription(userDesc); |
|
67 |
ub.setUserType(userType); |
|
68 |
ub.setUstate(userState); |
|
69 |
ub.setUdateCreated(new Date()); |
|
70 |
ub.setPdateCreated(new Date()); |
|
76 | 71 |
ub.setApplicationId(new Integer(applicationId)); |
77 |
|
|
78 |
PasswordController pc = MinimalUPassFactory.getPasswordController (ub, |
|
79 |
upc.getConfigurationsMap ()); |
|
80 |
rc = pc.VerifyUserAlias (userAlias); |
|
81 |
|
|
82 |
if(rc != MinimalConstants.ERR_SUCCESS) |
|
83 |
{ |
|
72 |
|
|
73 |
PasswordController pc = MinimalUPassFactory.getPasswordController(ub, |
|
74 |
upc.getConfigurationsMap()); |
|
75 |
rc = pc.VerifyUserAlias(userAlias); |
|
76 |
|
|
77 |
if (rc != MinimalConstants.ERR_SUCCESS) { |
|
84 | 78 |
return rc; |
85 | 79 |
} |
86 |
|
|
87 |
rc = pc.GeneratePassword (userPassword, true); |
|
88 |
|
|
89 |
if(rc != MinimalConstants.ERR_SUCCESS) |
|
90 |
{ |
|
80 |
|
|
81 |
rc = pc.GeneratePassword(userPassword, true); |
|
82 |
|
|
83 |
if (rc != MinimalConstants.ERR_SUCCESS) { |
|
91 | 84 |
return rc; |
92 | 85 |
} |
93 |
|
|
94 |
ub = (MinimalUserBean) pc.getUpdatedObject (); |
|
86 |
ub = (MinimalUserBean) pc.getUpdatedObject(); |
|
95 | 87 |
|
96 |
// UserMasterBean master = new UserMasterBean (); |
|
97 |
// master.setUserAlias (ub.getUserAlias ()); |
|
98 |
// master.setUserID (ub.getUserID ()); |
|
99 |
// ub.setUpassUserMaster (master); |
|
100 |
// TacBean tac = new TacBean (); |
|
101 |
// tac.setUserID (ub.getUserID ()); |
|
102 |
// tac.setUpassUser (ub); |
|
103 |
// ub.setTacbean (tac); |
|
104 |
|
|
105 |
if (userDao.insertUserToStore (ub)) |
|
106 |
{ |
|
88 |
// UserMasterBean master = new UserMasterBean (); |
|
89 |
// master.setUserAlias (ub.getUserAlias ()); |
|
90 |
// master.setUserID (ub.getUserID ()); |
|
91 |
// ub.setUpassUserMaster (master); |
|
92 |
// TacBean tac = new TacBean (); |
|
93 |
// tac.setUserID (ub.getUserID ()); |
|
94 |
// tac.setUpassUser (ub); |
|
95 |
// ub.setTacbean (tac); |
|
96 |
|
|
97 |
if (userDao.insertUserToStore(ub)) { |
|
107 | 98 |
rc = MinimalConstants.ERR_SUCCESS; |
108 |
} |
|
109 |
else |
|
110 |
{ |
|
99 |
|
|
100 |
} else { |
|
111 | 101 |
rc = MinimalConstants.ERR_SYSTEM_NOT_READY; |
112 | 102 |
} |
113 |
} |
|
114 |
else |
|
115 |
{ |
|
103 |
} else { |
|
116 | 104 |
rc = MinimalConstants.ERR_ALREADY_EXIST; |
117 | 105 |
} |
118 |
} |
|
119 |
catch (Exception e) |
|
120 |
{ |
|
121 |
e.printStackTrace (); |
|
106 |
} catch (Exception e) { |
|
107 |
e.printStackTrace(); |
|
122 | 108 |
} |
123 | 109 |
return rc; |
124 | 110 |
} |
111 |
|
|
112 |
public int addUser(MinimalUserBean user, int appId) { |
|
113 |
return addUser(user.getUserAlias(), user.getUserType(), user.getDescription(), |
|
114 |
user.getPcipherText(), user.getPstate(), appId); |
|
115 |
} |
|
125 | 116 |
} |
src/main/java/my/com/upass/services/ModifyUserService.java | ||
---|---|---|
1 | 1 |
/** |
2 |
* Copyright (c) 2010 Penril Datability (M) Sdn Bhd All rights reserved.
|
|
2 |
* Copyright (c) 2013 Penril Datability (M) Sdn Bhd All rights reserved.
|
|
3 | 3 |
* |
4 | 4 |
* This software is copyrighted. Under the copyright laws, this software |
5 | 5 |
* may not be copied, in whole or in part, without prior written consent |
... | ... | |
32 | 32 |
/** |
33 | 33 |
* <Class description> |
34 | 34 |
*/ |
35 |
public class ModifyUserService |
|
36 |
{ |
|
35 |
public class ModifyUserService {
|
|
36 |
|
|
37 | 37 |
private MinimalUPassControllerV2 upc; |
38 |
|
|
39 |
public ModifyUserService(MinimalUPassControllerV2 upc) |
|
40 |
{ |
|
38 |
|
|
39 |
public ModifyUserService(MinimalUPassControllerV2 upc) { |
|
41 | 40 |
this.upc = upc; |
42 | 41 |
} |
43 |
|
|
44 |
public int modifyUser (String userAlias, int userType, String userDesc, |
|
45 |
String userPassword, int userState) |
|
46 |
{ |
|
42 |
|
|
43 |
public int modifyUser( |
|
44 |
String userAlias, int userType, String userDesc, |
|
45 |
String userPassword, int userState) { |
|
46 |
|
|
47 | 47 |
int rc = MinimalConstants.ERR_SYSTEM_NOT_READY; |
48 | 48 |
|
49 |
if (userAlias == null) |
|
50 |
{ |
|
49 |
if (userAlias == null) { |
|
51 | 50 |
return MinimalConstants.ERR_INVALID_INPUT; |
52 | 51 |
} |
53 | 52 |
|
54 | 53 |
UserDAO userDao; |
55 |
|
|
56 |
try |
|
57 |
{ |
|
58 |
userDao = MinimalDAOFactory.minimalInstance().getUserDAO (); |
|
59 |
MinimalUserBean ub = userDao.getUserFromStore (userAlias); |
|
60 | 54 |
|
61 |
if (ub == null) |
|
62 |
{ |
|
55 |
try { |
|
56 |
userDao = MinimalDAOFactory.minimalInstance().getUserDAO(); |
|
57 |
MinimalUserBean ub = userDao.getUserFromStore(userAlias); |
|
58 |
|
|
59 |
if (ub == null) { |
|
63 | 60 |
return MinimalConstants.ERR_USERALIAS_NOT_FOUND; |
64 | 61 |
} |
65 | 62 |
|
66 |
if (userPassword != null) |
|
67 |
{ |
|
63 |
if (userPassword != null) { |
|
68 | 64 |
// Generate new paswword |
69 |
PasswordController pc = MinimalUPassFactory.getPasswordController (ub,
|
|
70 |
upc.getConfigurationsMap ());
|
|
65 |
PasswordController pc = MinimalUPassFactory.getPasswordController(ub, |
|
66 |
upc.getConfigurationsMap()); |
|
71 | 67 |
// rc = pc.GeneratePassword(userPassword, false); //disable |
72 | 68 |
// password hist check 20081220 |
73 |
rc = pc.GeneratePassword (userPassword, true);
|
|
74 |
if (rc != MinimalConstants.ERR_SUCCESS) |
|
75 |
{ |
|
69 |
rc = pc.GeneratePassword(userPassword, true); |
|
70 |
|
|
71 |
if (rc != MinimalConstants.ERR_SUCCESS) {
|
|
76 | 72 |
return rc; |
77 | 73 |
} |
78 |
ub = (MinimalUserBean) pc.getUpdatedObject ();
|
|
74 |
ub = (MinimalUserBean) pc.getUpdatedObject(); |
|
79 | 75 |
} |
80 | 76 |
|
81 |
if (userDesc != null) |
|
82 |
{ |
|
83 |
ub.setDescription (userDesc); |
|
77 |
if (userDesc != null) { |
|
78 |
ub.setDescription(userDesc); |
|
84 | 79 |
} |
85 | 80 |
|
86 |
ub.setUserType (userType);
|
|
87 |
ub.setUstate (userState);
|
|
81 |
ub.setUserType(userType); |
|
82 |
ub.setUstate(userState); |
|
88 | 83 |
|
89 |
if (userDao.updateUserToStore (ub)) |
|
90 |
{ |
|
84 |
if (userDao.updateUserToStore(ub)) { |
|
91 | 85 |
rc = MinimalConstants.ERR_SUCCESS; |
92 |
} |
|
93 |
else |
|
94 |
{ |
|
86 |
|
|
87 |
} else { |
|
95 | 88 |
rc = MinimalConstants.ERR_UNKNOWN; |
96 | 89 |
} |
97 |
} |
|
98 |
catch (Exception e) |
|
99 |
{ |
|
100 |
e.printStackTrace (); |
|
90 |
} catch (Exception e) { |
|
91 |
e.printStackTrace(); |
|
101 | 92 |
} |
102 | 93 |
return rc; |
103 | 94 |
} |
src/main/java/my/com/upass/services/VerifyStaticPasswordService.java | ||
---|---|---|
37 | 37 |
/** |
38 | 38 |
* <Class description> |
39 | 39 |
*/ |
40 |
public class VerifyStaticPasswordService |
|
41 |
{ |
|
40 |
public class VerifyStaticPasswordService {
|
|
41 |
|
|
42 | 42 |
private MinimalUPassControllerV2 upc; |
43 |
|
|
44 |
public VerifyStaticPasswordService(MinimalUPassControllerV2 upc) |
|
45 |
{ |
|
43 |
|
|
44 |
public VerifyStaticPasswordService(MinimalUPassControllerV2 upc) { |
|
46 | 45 |
this.upc = upc; |
47 | 46 |
} |
48 |
|
|
47 |
|
|
49 | 48 |
/** |
50 | 49 |
* Verify password validity only |
50 |
* |
|
51 | 51 |
* @param userAlias |
52 | 52 |
* @param password |
53 | 53 |
* @param chkUserType |
54 | 54 |
* @param userType |
55 | 55 |
* @return |
56 | 56 |
*/ |
57 |
public int verifyStaticPassword (String userAlias, String password, |
|
58 |
boolean chkUserType, int userType) |
|
59 |
{ |
|
57 |
public int verifyStaticPassword( |
|
58 |
String userAlias, String password, |
|
59 |
boolean chkUserType, int userType) { |
|
60 |
|
|
60 | 61 |
return verifyUserCredetial(userAlias, password, chkUserType, userType, false); |
61 | 62 |
} |
62 |
|
|
63 |
|
|
63 | 64 |
/** |
64 | 65 |
* Verify user dormant period and password validity |
66 |
* |
|
65 | 67 |
* @param userAlias |
66 | 68 |
* @param password |
67 | 69 |
* @param chkUserType |
68 | 70 |
* @param userType |
69 | 71 |
* @return |
70 | 72 |
*/ |
71 |
public int login(String userAlias, String password, |
|
73 |
public int login( |
|
74 |
String userAlias, String password, |
|
72 | 75 |
boolean chkUserType, int userType) { |
76 |
|
|
73 | 77 |
return verifyUserCredetial(userAlias, password, chkUserType, userType, true); |
74 | 78 |
} |
75 |
|
|
79 |
|
|
76 | 80 |
/** |
77 | 81 |
* This method will do dormant verification before verify password. |
78 | 82 |
* The logic is duplicated from verifyStaticPassword. |
83 |
* |
|
79 | 84 |
* @param userAlias |
80 | 85 |
* @param password |
81 | 86 |
* @param chkUserType |
82 | 87 |
* @param userType |
83 | 88 |
* @return |
84 | 89 |
*/ |
85 |
public int verifyUserCredetial(String userAlias, String password, |
|
90 |
public int verifyUserCredetial( |
|
91 |
String userAlias, String password, |
|
86 | 92 |
boolean chkUserType, int userType, boolean dormantCheck) { |
87 |
|
|
93 |
|
|
88 | 94 |
int rc = MinimalConstants.ERR_SYSTEM_NOT_READY; |
89 | 95 |
|
90 |
if (userAlias == null || password == null) |
|
91 |
{ |
|
96 |
if (userAlias == null || password == null) { |
|
92 | 97 |
return MinimalConstants.ERR_INVALID_INPUT; |
93 | 98 |
} |
94 | 99 |
|
95 |
try |
|
96 |
{ |
|
97 |
UserDAO userDao = MinimalDAOFactory.minimalInstance().getUserDAO (); |
|
98 |
MinimalUserBean userBean = userDao.getUserFromStore (userAlias); |
|
100 |
try { |
|
101 |
UserDAO userDao = MinimalDAOFactory.minimalInstance().getUserDAO(); |
|
102 |
MinimalUserBean userBean = userDao.getUserFromStore(userAlias); |
|
99 | 103 |
|
100 |
if (userBean == null) |
|
101 |
{ |
|
104 |
if (userBean == null) { |
|
102 | 105 |
return MinimalConstants.ERR_USERALIAS_NOT_FOUND; |
103 | 106 |
} |
104 | 107 |
|
105 | 108 |
// verify user state, must be active (not inactive|locked|deleted) |
106 |
switch (userBean.getUstate ()) |
|
107 |
{ |
|
108 |
case (MinimalConstants.UID_STATE_ACTIVE): |
|
109 |
break; |
|
110 |
case (MinimalConstants.UID_STATE_TMP_LOCKED): |
|
111 |
Date now = new Date (); |
|
112 |
if (userBean.getUdateLockedTo ().after (now)) |
|
113 |
{ |
|
114 |
return MinimalConstants.ERR_INVALID_STATE; |
|
115 |
} |
|
116 |
break; |
|
117 |
default: |
|
109 |
switch (userBean.getUstate()) { |
|
110 |
|
|
111 |
case (MinimalConstants.UID_STATE_ACTIVE): |
|
112 |
break; |
|
113 |
case (MinimalConstants.UID_STATE_TMP_LOCKED): |
|
114 |
Date now = new Date(); |
|
115 |
if (userBean.getUdateLockedTo().after(now)) { |
|
118 | 116 |
return MinimalConstants.ERR_INVALID_STATE; |
117 |
} |
|
118 |
break; |
|
119 |
default: |
Also available in: Unified diff