Revision 84:7652f2ee0d40

View differences:

src/main/java/my/com/upass/MinimalUPassControllerV2.java
1 1
package my.com.upass;
2 2

  
3
import java.util.ArrayList;
4
import java.util.Collections;
3 5
import java.util.Date;
4 6
import java.util.HashMap;
5 7
import java.util.Iterator;
......
34 36
import my.com.upass.spring.ldap.MaybankLdapConstant;
35 37
import my.com.upass.spring.ldap.MaybankLdapDAO;
36 38

  
39
import org.apache.commons.lang.StringUtils;
37 40
import org.apache.log4j.Logger;
38 41
import org.hibernate.Session;
39 42
import org.springframework.beans.factory.BeanFactory;
......
61 64
	private static final Object CONFIG_LOCK = new Object();
62 65
	private static MaybankLdapDAO maybankLdapDAO;
63 66

  
67
	public static List ACCESSIBLE_APPS_FOR_CCPP_ADMIN = Collections.unmodifiableList(createCcppAccessibleAppsList());
68

  
69
	//
70

  
64 71
	public MinimalUPassControllerV2() {
65 72

  
66 73
		final String migratioinPeriodProp = Config.getInstance()
......
476 483
			if (profile instanceof M2uUser) {
477 484
				objectClasses = new String[] { MaybankLdapConstant.OBJECT_CLASS_M2U };
478 485

  
479
				if (!isEmptyString(((M2uUser) profile).getPan1()))
486
				if (!StringUtils.isEmpty(((M2uUser) profile).getPan1()))
480 487
					attrMap.put(MaybankLdapConstant.ATTR_PAN_1, ((M2uUser) profile).getPan1());
481
				if (!isEmptyString(((M2uUser) profile).getPan2()))
488
				if (!StringUtils.isEmpty(((M2uUser) profile).getPan2()))
482 489
					attrMap.put(MaybankLdapConstant.ATTR_PAN_2, ((M2uUser) profile).getPan2());
483 490

  
484 491
			} else if (profile instanceof Im2uUser) {
......
486 493
						MaybankLdapConstant.OBJECT_CLASS_M2U,
487 494
						MaybankLdapConstant.OBJECT_CLASS_IM2U };
488 495

  
489
				if (!isEmptyString(((Im2uUser) profile).getWsFlag()))
496
				if (!StringUtils.isEmpty(((Im2uUser) profile).getWsFlag()))
490 497
					attrMap.put(MaybankLdapConstant.ATTR_WS_FLAG, ((Im2uUser) profile).getWsFlag());
491
				if (!isEmptyString(((Im2uUser) profile).getWsIdentCode()))
498
				if (!StringUtils.isEmpty(((Im2uUser) profile).getWsIdentCode()))
492 499
					attrMap.put(MaybankLdapConstant.ATTR_WS_IDENTCODE, ((Im2uUser) profile).getWsIdentCode());
493
				if (!isEmptyString(((Im2uUser) profile).getWsMySgId()))
500
				if (!StringUtils.isEmpty(((Im2uUser) profile).getWsMySgId()))
494 501
					attrMap.put(MaybankLdapConstant.ATTR_WS_MYSGID, ((Im2uUser) profile).getWsMySgId());
495 502
				if (((Im2uUser) profile).getWsRegTimeStamp() != null)
496 503
					attrMap.put(MaybankLdapConstant.ATTR_WS_REGTIMESTAMP,
497 504
							Im2uUser.DATE_FORMAT.format(((Im2uUser) profile).getWsRegTimeStamp()));
498 505
				if (((Im2uUser) profile).getM2uUser() != null) {
499
					if (!isEmptyString(((Im2uUser) profile).getM2uUser().getPan1()))
506
					if (!StringUtils.isEmpty(((Im2uUser) profile).getM2uUser().getPan1()))
500 507
						attrMap.put(MaybankLdapConstant.ATTR_PAN_1, ((Im2uUser) profile).getM2uUser().getPan1());
501
					if (!isEmptyString(((Im2uUser) profile).getM2uUser().getPan2()))
508
					if (!StringUtils.isEmpty(((Im2uUser) profile).getM2uUser().getPan2()))
502 509
						attrMap.put(MaybankLdapConstant.ATTR_PAN_2, ((Im2uUser) profile).getM2uUser().getPan2());
503 510
				}
504 511

  
......
507 514
						MaybankLdapConstant.OBJECT_CLASS_ONLINE_TICKETING,
508 515
						"person", "organizationalPerson",
509 516
						"inetOrgPerson" };
510
				if (!isEmptyString(((TicketingUser) profile).getPayeeCode())) {
517
				if (!StringUtils.isEmpty(((TicketingUser) profile).getPayeeCode())) {
511 518
					attrMap.put(MaybankLdapConstant.ATTR_PAYEE_CODE, ((TicketingUser) profile).getPayeeCode());
512 519
					attrMap.put("cn", username);
513 520
					attrMap.put("sn", username);
......
520 527
						MaybankLdapConstant.OBJECT_CLASS_ONLINE_STOCK1,
521 528
						MaybankLdapConstant.OBJECT_CLASS_ONLINE_STOCK2 };
522 529

  
523
				if (!isEmptyString(((StockUser) profile).getIdNo())) {
530
				if (!StringUtils.isEmpty(((StockUser) profile).getIdNo())) {
524 531
					attrMap.put(MaybankLdapConstant.ATTR_IDNO, ((StockUser) profile).getIdNo());
525 532
					attrMap.put(MaybankLdapConstant.ATTR_CUST_TYPE, "0");
526 533
				}
527 534

  
528 535
				if (((StockUser) profile).getM2uUser() != null) {
529
					if (!isEmptyString(((StockUser) profile).getM2uUser().getPan1()))
536
					if (!StringUtils.isEmpty(((StockUser) profile).getM2uUser().getPan1()))
530 537
						attrMap.put(MaybankLdapConstant.ATTR_PAN_1, ((StockUser) profile).getM2uUser().getPan1());
531
					if (!isEmptyString(((StockUser) profile).getM2uUser().getPan2()))
538
					if (!StringUtils.isEmpty(((StockUser) profile).getM2uUser().getPan2()))
532 539
						attrMap.put(MaybankLdapConstant.ATTR_PAN_2, ((StockUser) profile).getM2uUser().getPan2());
533 540
				}
534 541

  
535 542
			} else if (profile instanceof IbccUser) {
536 543
				objectClasses = new String[] { MaybankLdapConstant.OBJECT_CLASS_CCPP };
537
				if (!isEmptyString(((IbccUser) profile).getPanCc()))
544
				if (!StringUtils.isEmpty(((IbccUser) profile).getPanCc()))
538 545
					attrMap.put(MaybankLdapConstant.ATTR_PANCC, ((IbccUser) profile).getPanCc());
539 546
			}
540 547

  
......
783 790
				} else if (!invokerAppId.equals(targetAppId)) {
784 791

  
785 792
					if (!invokerAppId.equals(ClientApp.APP_ID_CCPP)
786
							|| !invokerAppId.equals(ClientApp.APP_ID_ONLINE_TICKETING))
793
							|| !(ACCESSIBLE_APPS_FOR_CCPP_ADMIN.contains(targetAppId)))
787 794

  
788 795
						throw new UPassException(MinimalConstants.ERR_APP_SERV_NOT_PERMITTED);
789 796
				}
......
905 912
		}
906 913
	}
907 914

  
908
	private boolean isEmptyString(String value) {
909
		if (value == null)
910
			return true;
915
	private static List createCcppAccessibleAppsList() {
916
		ArrayList accessibleAppIds = new ArrayList(3);
917
		accessibleAppIds.add(ClientApp.APP_ID_CCPP);
918
		accessibleAppIds.add(ClientApp.APP_ID_M2U);
919
		accessibleAppIds.add(ClientApp.APP_ID_ONLINE_TICKETING);
920
		return accessibleAppIds;
921
	}
911 922

  
912
		if ("".equals(value))
913
			return true;
914

  
915
		return false;
916
	}
917 923
}

Also available in: Unified diff