Revision 68:e028f246e801
src/main/java/my/com/upass/dao/hibernate/UserDAOHibernate.java | ||
---|---|---|
34 | 34 |
import org.apache.log4j.Logger; |
35 | 35 |
import org.hibernate.Criteria; |
36 | 36 |
import org.hibernate.FetchMode; |
37 |
import org.hibernate.Hibernate; |
|
37 | 38 |
import org.hibernate.Query; |
38 | 39 |
import org.hibernate.Session; |
39 | 40 |
import org.hibernate.criterion.Example; |
... | ... | |
83 | 84 |
} |
84 | 85 |
profile = (MinimalUserBean) criteria.uniqueResult(); |
85 | 86 |
|
87 |
if (txSession == null) |
|
88 |
Hibernate.initialize(profile); |
|
89 |
|
|
86 | 90 |
} catch (Exception e) { |
87 | 91 |
logger.error(e, e); |
88 | 92 |
|
... | ... | |
248 | 252 |
|
249 | 253 |
profile = (MinimalUserBeanBackup) criteria.uniqueResult(); |
250 | 254 |
|
255 |
if (txSession == null) |
|
256 |
Hibernate.initialize(profile); |
|
257 |
|
|
251 | 258 |
} catch (Exception e) { |
252 | 259 |
logger.error(e, e); |
253 | 260 |
|
... | ... | |
260 | 267 |
|
261 | 268 |
public MinimalUserBean getTbAmUserByUserAlias(String userAlias, final Session txSession) throws Exception { |
262 | 269 |
|
263 |
MinimalUserBean TbAmUser;
|
|
270 |
MinimalUserBean minUser;
|
|
264 | 271 |
Session session = null; |
265 | 272 |
try { |
266 | 273 |
session = txSession != null ? txSession : getSession(); |
267 | 274 |
|
268 | 275 |
Criteria m_oCriteria = session.createCriteria(MinimalUserBean.class); |
269 | 276 |
m_oCriteria.add(Restrictions.eq("userAlias", userAlias)); |
270 |
TbAmUser = (MinimalUserBean) m_oCriteria.uniqueResult(); |
|
277 |
minUser = (MinimalUserBean) m_oCriteria.uniqueResult(); |
|
278 |
|
|
279 |
if (txSession == null) |
|
280 |
Hibernate.initialize(minUser); |
|
271 | 281 |
|
272 | 282 |
} finally { |
273 | 283 |
if (txSession == null) |
274 | 284 |
closeSessionIfAny(session); |
275 | 285 |
} |
276 |
return TbAmUser;
|
|
286 |
return minUser;
|
|
277 | 287 |
} |
278 | 288 |
|
279 | 289 |
public MinimalUserBean getTbAmUserByUserId(Long tUserId, final Session txSession) throws Exception { |
280 |
MinimalUserBean TbAmUser;
|
|
290 |
MinimalUserBean minUser;
|
|
281 | 291 |
Session session = null; |
282 | 292 |
try { |
283 | 293 |
session = txSession != null ? txSession : getSession(); |
284 | 294 |
|
285 | 295 |
Criteria m_oCriteria = session.createCriteria(MinimalUserBean.class); |
286 | 296 |
m_oCriteria.add(Restrictions.eq("userID", tUserId)); |
287 |
TbAmUser = (MinimalUserBean) m_oCriteria.uniqueResult(); |
|
297 |
minUser = (MinimalUserBean) m_oCriteria.uniqueResult(); |
|
298 |
|
|
299 |
if (txSession == null) |
|
300 |
Hibernate.initialize(minUser); |
|
288 | 301 |
|
289 | 302 |
} finally { |
290 | 303 |
if (txSession == null) |
291 | 304 |
closeSessionIfAny(session); |
292 | 305 |
} |
293 |
return TbAmUser;
|
|
306 |
return minUser;
|
|
294 | 307 |
} |
295 | 308 |
|
296 | 309 |
public void deleteTbAmUser(Integer tUserId, final Session txSession) throws Exception { |
... | ... | |
334 | 347 |
"FROM UserAppAccess aa WHERE aa.user.userAlias = :userAlias"); |
335 | 348 |
accesses = query.setString("userAlias", username).list(); |
336 | 349 |
|
350 |
if (txSession == null) |
|
351 |
Hibernate.initialize(accesses); |
|
352 |
|
|
337 | 353 |
} finally { |
338 | 354 |
if (txSession == null) |
339 | 355 |
closeSessionIfAny(session); |
... | ... | |
341 | 357 |
return accesses; |
342 | 358 |
} |
343 | 359 |
|
344 |
|
|
345 | 360 |
/** |
346 | 361 |
* @see my.com.upass.dao.UserDAO#listAllClientApps(Session) |
347 | 362 |
*/ |
... | ... | |
384 | 399 |
.setString("userAlias", username) |
385 | 400 |
.setCharacter("accessType", accessType) |
386 | 401 |
.list(); |
402 |
|
|
403 |
if (txSession == null) |
|
404 |
Hibernate.initialize(accesses); |
|
387 | 405 |
|
388 | 406 |
} finally { |
389 | 407 |
if (txSession == null) |
... | ... | |
498 | 516 |
|
499 | 517 |
CollectionUtils.filter(profiles, PredicateUtils.notNullPredicate()); |
500 | 518 |
|
519 |
if (txSession == null) { |
|
520 |
ensureUserInitialized(profiles); |
|
521 |
} |
|
501 | 522 |
} finally { |
502 | 523 |
if (txSession == null) |
503 | 524 |
closeSessionIfAny(session); |
... | ... | |
534 | 555 |
} |
535 | 556 |
|
536 | 557 |
profiles.addAll(c.list()); |
558 |
if (txSession == null) |
|
559 |
ensureUserInitialized(profiles); |
|
537 | 560 |
} |
538 | 561 |
} finally { |
539 | 562 |
if (txSession == null) |
... | ... | |
596 | 619 |
} |
597 | 620 |
|
598 | 621 |
profiles.addAll(c.list()); |
622 |
if (txSession == null) |
|
623 |
ensureUserInitialized(profiles); |
|
599 | 624 |
} |
600 | 625 |
} finally { |
601 | 626 |
if (txSession == null) |
... | ... | |
683 | 708 |
} |
684 | 709 |
return isSuccessful; |
685 | 710 |
} |
711 |
|
|
712 |
// Helper methods |
|
713 |
|
|
714 |
private void ensureUserInitialized(List/* <UserProfile> */profiles) { |
|
715 |
for (Iterator iterator = profiles.iterator(); iterator.hasNext();) { |
|
716 |
UserProfile profile = (UserProfile) iterator.next(); |
|
717 |
Hibernate.initialize(profile.getMinUser()); |
|
718 |
} |
|
719 |
} |
|
720 |
|
|
686 | 721 |
} |
src/main/java/my/com/upass/maybank/CountResponse.java | ||
---|---|---|
1 |
package my.com.upass.maybank; |
|
2 |
|
|
3 |
|
|
4 |
public class CountResponse { |
|
5 |
|
|
6 |
private int code; |
|
7 |
private Integer count; |
|
8 |
|
|
9 |
// |
|
10 |
|
|
11 |
public int getCode() { |
|
12 |
return code; |
|
13 |
} |
|
14 |
|
|
15 |
public void setCode(int code) { |
|
16 |
this.code = code; |
|
17 |
} |
|
18 |
|
|
19 |
public Integer getCount() { |
|
20 |
return count; |
|
21 |
} |
|
22 |
|
|
23 |
public void setCount(Integer count) { |
|
24 |
this.count = count; |
|
25 |
} |
|
26 |
|
|
27 |
} |
src/main/java/my/com/upass/maybank/MinimalMaybankFacade.java | ||
---|---|---|
1 | 1 |
package my.com.upass.maybank; |
2 | 2 |
|
3 |
import java.util.Map; |
|
4 |
|
|
3 | 5 |
public interface MinimalMaybankFacade { |
4 | 6 |
|
5 | 7 |
int authenticateUser( |
src/main/java/my/com/upass/maybank/MinimalMaybankFacadeImpl.java | ||
---|---|---|
88 | 88 |
} |
89 | 89 |
|
90 | 90 |
public Response lookupUsername_internal( |
91 |
String appAccessId, String hashedSecretKey, |
|
92 |
String username) { |
|
91 |
String appAccessId, String hashedSecretKey, String username) { |
|
93 | 92 |
|
94 | 93 |
Response res = new Response(); |
95 | 94 |
Session session = null; |
... | ... | |
175 | 174 |
return 0; |
176 | 175 |
} |
177 | 176 |
|
177 |
public CountResponse getFailedLoginsCount(String appAccessId, String hashedSecretKey, String username) { |
|
178 |
CountResponse res = new CountResponse(); |
|
179 |
try { |
|
180 |
UserProfile profile = minUpcV2.findProfile(appAccessId, hashedSecretKey, username, null); |
|
181 |
if (profile != null) { |
|
182 |
final int errorCount = profile.getMinUser().getPerrorCount(); |
|
183 |
res.setCount(new Integer(errorCount)); |
|
184 |
res.setCode(MinimalConstants.ERR_SUCCESS); |
|
185 |
|
|
186 |
} else |
|
187 |
res.setCode(MinimalConstants.ERR_USERALIAS_NOT_FOUND); |
|
188 |
|
|
189 |
} catch (UPassException e) { |
|
190 |
LOGGER.info(e, e); |
|
191 |
res.setCode(e.getErrorCode()); |
|
192 |
|
|
193 |
} catch (Exception e) { |
|
194 |
LOGGER.error(e, e); |
|
195 |
res.setCode(MinimalConstants.ERR_UNKNOWN); |
|
196 |
} |
|
197 |
return res; |
|
198 |
} |
|
199 |
|
|
178 | 200 |
// protected methods |
179 | 201 |
|
180 | 202 |
protected int newUser( |
... | ... | |
243 | 265 |
int rc = minUpcV2.updateProfileShallowly( |
244 | 266 |
appAccessId, hashedSecretKey, m2uUser, session); |
245 | 267 |
|
246 |
if (rc == MinimalConstants.ERR_SUCCESS){ |
|
247 |
if(minUpcV2.isInMigrationPeriod()){
|
|
268 |
if (rc == MinimalConstants.ERR_SUCCESS) {
|
|
269 |
if (minUpcV2.isInMigrationPeriod()) {
|
|
248 | 270 |
Map attrMap = new HashMap(); |
249 | 271 |
if (pan1 != null) |
250 | 272 |
attrMap.put(MaybankLdapConstant.ATTR_PAN_1, pan1); |
251 | 273 |
|
252 | 274 |
if (pan2 != null) |
253 | 275 |
attrMap.put(MaybankLdapConstant.ATTR_PAN_2, pan2); |
254 |
|
|
255 |
if(!attrMap.isEmpty()) |
|
276 |
|
|
277 |
if (!attrMap.isEmpty())
|
|
256 | 278 |
MinimalUPassControllerV2.getMaybankLdapDAO().updateUser(username, attrMap); |
257 | 279 |
} |
280 |
session.getTransaction().commit(); |
|
258 | 281 |
|
259 |
session.getTransaction().commit(); |
|
260 |
}else{ |
|
282 |
} else { |
|
261 | 283 |
LOGGER.warn("Unable to update user profile."); |
262 | 284 |
GenericDAOHibernate.rollbackTransactionIfAny(session); |
263 | 285 |
} |
264 |
|
|
265 | 286 |
return rc; |
266 | 287 |
|
267 | 288 |
} else { |
src/main/java/my/com/upass/maybank/entities/TicketingUser.java | ||
---|---|---|
58 | 58 |
return minUser; |
59 | 59 |
} |
60 | 60 |
|
61 |
public void setMinUser(MinimalUserBean maybankUser) {
|
|
62 |
this.minUser = maybankUser;
|
|
63 |
if (maybankUser != null)
|
|
61 |
public void setMinUser(MinimalUserBean minkUser) {
|
|
62 |
this.minUser = minkUser;
|
|
63 |
if (minkUser != null)
|
|
64 | 64 |
this.userId = new Long(minUser.getUserID()); |
65 | 65 |
} |
66 | 66 |
|
Also available in: Unified diff