Kaynağa Gözat

update readme add license howto

arkha 1 yıl önce
ebeveyn
işleme
236dbf3474

+ 17 - 0
MWUI/dev/config/server.xml

@@ -7,8 +7,25 @@
         <feature>jdbc-4.2</feature>
         <feature>jdbc-4.2</feature>
         <feature>servlet-4.0</feature>
         <feature>servlet-4.0</feature>
         <feature>jndi-1.0</feature>
         <feature>jndi-1.0</feature>
+        <feature>appSecurity-3.0</feature>
     </featureManager>
     </featureManager>
 
 
+    <basicRegistry>
+        <user name="wpsadmindev" password="wpsadmindev" />
+        <group name="MWSecurity_">
+            <member name="wpsadmindev" />
+        </group>
+    </basicRegistry>
+
+    <ldapRegistry id="LDAP" ldapType="OpenLDAP" host="localhost" port="389"
+        baseDN="dc=btn,dc=co,dc=id" bindDN="cn=admin,dc=btn,dc=co,dc=id"
+        bindPassword="adminpassword"
+        ignoreCase="true" sslEnabled="false">
+        <ldapSearchFilter objectClass="person" idAttribute="cn" />
+    </ldapRegistry>
+
+    <logging traceSpecification="com.ibm.ws.security.*=all" />
+
     <variable name="http.port" defaultValue="9080" />
     <variable name="http.port" defaultValue="9080" />
     <variable name="https.port" defaultValue="9443" />
     <variable name="https.port" defaultValue="9443" />
     <variable name="serverdb.name" defaultValue="10.10.10.36" />
     <variable name="serverdb.name" defaultValue="10.10.10.36" />

+ 60 - 54
MWUI/src/main/java/id/co/hanoman/shared/Util.java

@@ -201,7 +201,7 @@ public class Util {
 		try {
 		try {
 			// long sessionTimeout = 300000;
 			// long sessionTimeout = 300000;
 			long sessionTimeout = 50000;
 			long sessionTimeout = 50000;
-			//log.info("masuk sini ga yahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
+			// log.info("masuk sini ga yahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
 			for (Iterator iterator = Collections.list(request.getSession().getAttributeNames()).iterator(); iterator.hasNext();) {
 			for (Iterator iterator = Collections.list(request.getSession().getAttributeNames()).iterator(); iterator.hasNext();) {
 				String s = (String) iterator.next();
 				String s = (String) iterator.next();
 				if (s.equals("org.apache.struts.action.LOCALE") || s.equals("myMenu") || s.equals("login.user")) {
 				if (s.equals("org.apache.struts.action.LOCALE") || s.equals("myMenu") || s.equals("login.user")) {
@@ -234,7 +234,8 @@ public class Util {
 	public static void clearSession(HttpServletRequest request, PersistanceServiceInterface psi) {
 	public static void clearSession(HttpServletRequest request, PersistanceServiceInterface psi) {
 		try {
 		try {
 			// String sysParam_filterStr = "code=" +Constant.SESSION_TIMEOUT;
 			// String sysParam_filterStr = "code=" +Constant.SESSION_TIMEOUT;
-			// SysParam sysParam = (SysParam) psi.queryUnique("FROM SysParam WHERE code = :code ", sysParam_filterStr);
+			// SysParam sysParam = (SysParam) psi.queryUnique("FROM SysParam WHERE code =
+			// :code ", sysParam_filterStr);
 			long sessionTimeout = 300000;
 			long sessionTimeout = 300000;
 			// if (sysParam == null) {
 			// if (sysParam == null) {
 			// log.warn("Sys Param " +Constant.SESSION_TIMEOUT+ " not exist");
 			// log.warn("Sys Param " +Constant.SESSION_TIMEOUT+ " not exist");
@@ -243,7 +244,7 @@ public class Util {
 			// }
 			// }
 			for (Iterator iterator = Collections.list(request.getSession().getAttributeNames()).iterator(); iterator.hasNext();) {
 			for (Iterator iterator = Collections.list(request.getSession().getAttributeNames()).iterator(); iterator.hasNext();) {
 				String s = (String) iterator.next();
 				String s = (String) iterator.next();
-				if (s.equals("org.apache.struts.action.LOCALE") || s.equals("myMenu") || s.equals("login.user") || s.indexOf("session.") > -1 ) {
+				if (s.equals("org.apache.struts.action.LOCALE") || s.equals("myMenu") || s.equals("login.user") || s.indexOf("session.") > -1) {
 				} else {
 				} else {
 					if (s.indexOf('_') != -1) {
 					if (s.indexOf('_') != -1) {
 						try {
 						try {
@@ -349,12 +350,11 @@ public class Util {
 		Properties props = getProperties(ctx);
 		Properties props = getProperties(ctx);
 		return props.getProperty("wpsPort");
 		return props.getProperty("wpsPort");
 	}
 	}
-	
-	
+
 	public ArrayList objRoller(String callerPrincipal) {
 	public ArrayList objRoller(String callerPrincipal) {
 		ArrayList rs = new ArrayList();
 		ArrayList rs = new ArrayList();
 		try {
 		try {
-			
+
 			String dbCode = "LDAP_LIVE";
 			String dbCode = "LDAP_LIVE";
 			PersistanceServiceInterface psiConfig = ServiceUtil.getDaoClient(null);
 			PersistanceServiceInterface psiConfig = ServiceUtil.getDaoClient(null);
 			Dbconn dbconn = (Dbconn) psiConfig.queryById(Constant.MWCONFIG_DS, "Dbconn", dbCode, null);
 			Dbconn dbconn = (Dbconn) psiConfig.queryById(Constant.MWCONFIG_DS, "Dbconn", dbCode, null);
@@ -362,38 +362,38 @@ public class Util {
 			String base = dbconn.getDriver();
 			String base = dbconn.getDriver();
 			String userBind = dbconn.getUsername();
 			String userBind = dbconn.getUsername();
 			String passBind = dbconn.getPassword();
 			String passBind = dbconn.getPassword();
-			System.out.println("url : "+url);
-			System.out.println("base : "+base);
-			System.out.println("userBind : "+userBind);
-			System.out.println("passBind : "+passBind);
-			
-			
+			System.out.println("url : " + url);
+			System.out.println("base : " + base);
+			System.out.println("userBind : " + userBind);
+			System.out.println("passBind : " + passBind);
+
 			Hashtable env = new Hashtable();
 			Hashtable env = new Hashtable();
 			String pn = "cn=wpsadmindev,ou=middleware,dc=btn,dc=co,dc=id";
 			String pn = "cn=wpsadmindev,ou=middleware,dc=btn,dc=co,dc=id";
-			env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");			
-			//env.put(Context.PROVIDER_URL, "ldap://172.15.30.73:389");				        	
-			env.put(Context.PROVIDER_URL, "ldap://172.18.2.21:389"); //live
+			env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
+			// env.put(Context.PROVIDER_URL, "ldap://172.15.30.73:389");
+			// env.put(Context.PROVIDER_URL, "ldap://172.18.2.21:389"); //live
+			env.put(Context.PROVIDER_URL, "ldap://localhost:389"); // local
 			env.put(Context.SECURITY_AUTHENTICATION, "simple");
 			env.put(Context.SECURITY_AUTHENTICATION, "simple");
 			env.put(Context.SECURITY_PRINCIPAL, pn);
 			env.put(Context.SECURITY_PRINCIPAL, pn);
 			env.put(Context.SECURITY_CREDENTIALS, "wpsadmindev");
 			env.put(Context.SECURITY_CREDENTIALS, "wpsadmindev");
 			InitialDirContext ctx = null;
 			InitialDirContext ctx = null;
 			try {
 			try {
 				ctx = new InitialDirContext(env);
 				ctx = new InitialDirContext(env);
-			}catch (Exception e) {
+			} catch (Exception e) {
 				e.printStackTrace();
 				e.printStackTrace();
 			}
 			}
-			
-			if(ctx!=null) {
+
+			if (ctx != null) {
 				SearchControls ctrls = new SearchControls();
 				SearchControls ctrls = new SearchControls();
 				ctrls.setSearchScope(SearchControls.SUBTREE_SCOPE);
 				ctrls.setSearchScope(SearchControls.SUBTREE_SCOPE);
-				//wpsadmindev
-				//wpsbinddev
-				NamingEnumeration<javax.naming.directory.SearchResult> results = ctx.search("dc=btn,dc=co,dc=id", "(&(sAMAccountName="+callerPrincipal+")(objectClass=user))", ctrls);
+				// wpsadmindev
+				// wpsbinddev
+				NamingEnumeration<javax.naming.directory.SearchResult> results = ctx.search("dc=btn,dc=co,dc=id", "(&(sAMAccountName=" + callerPrincipal + ")(objectClass=user))", ctrls);
 				SearchResult result = results.next();
 				SearchResult result = results.next();
 				System.out.println("distinguisedName: " + result.getNameInNamespace());
 				System.out.println("distinguisedName: " + result.getNameInNamespace());
 				Attribute memberOf = result.getAttributes().get("memberOf");
 				Attribute memberOf = result.getAttributes().get("memberOf");
-				if(memberOf!=null) {
-					for(int idx=0; idx<memberOf.size(); idx++) {
+				if (memberOf != null) {
+					for (int idx = 0; idx < memberOf.size(); idx++) {
 						String strGroupIdCallerSubjectItem = memberOf.get(idx).toString();
 						String strGroupIdCallerSubjectItem = memberOf.get(idx).toString();
 						strGroupIdCallerSubjectItem = strGroupIdCallerSubjectItem.substring(strGroupIdCallerSubjectItem.toLowerCase().indexOf("cn=") + 3);
 						strGroupIdCallerSubjectItem = strGroupIdCallerSubjectItem.substring(strGroupIdCallerSubjectItem.toLowerCase().indexOf("cn=") + 3);
 						strGroupIdCallerSubjectItem = strGroupIdCallerSubjectItem.substring(0, strGroupIdCallerSubjectItem.indexOf(','));
 						strGroupIdCallerSubjectItem = strGroupIdCallerSubjectItem.substring(0, strGroupIdCallerSubjectItem.indexOf(','));
@@ -403,12 +403,12 @@ public class Util {
 				}
 				}
 				ctx.close();
 				ctx.close();
 			}
 			}
-		}catch (Exception e) {
+		} catch (Exception e) {
 			e.printStackTrace();
 			e.printStackTrace();
 		}
 		}
 		return rs;
 		return rs;
 	}
 	}
-	
+
 	public static void updateMenu(PersistanceServiceInterface psiConfig, HttpServletRequest request, String callerPrincipal, List objRoleCaller) {
 	public static void updateMenu(PersistanceServiceInterface psiConfig, HttpServletRequest request, String callerPrincipal, List objRoleCaller) {
 		try {
 		try {
 			List<Privilege> privilegeList = new ArrayList<Privilege>();
 			List<Privilege> privilegeList = new ArrayList<Privilege>();
@@ -430,26 +430,29 @@ public class Util {
 							String filterStr = "$INCLUDE=privileges/*";
 							String filterStr = "$INCLUDE=privileges/*";
 							id.co.hanoman.service.List roleIdList = psiConfig.query(Constant.MWAPP_CONFIG_DS, "FROM Role role WHERE 1=1 " + filterRole + " AND role.id in (" + id + ")" + "ORDER BY " + orderRole, filterStr, 0, 0);
 							id.co.hanoman.service.List roleIdList = psiConfig.query(Constant.MWAPP_CONFIG_DS, "FROM Role role WHERE 1=1 " + filterRole + " AND role.id in (" + id + ")" + "ORDER BY " + orderRole, filterStr, 0, 0);
 							Object[] roleIdItems = roleIdList.getItems();
 							Object[] roleIdItems = roleIdList.getItems();
-							//System.out.println("ROLE LIST roleItems.length >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  "+roleItems.length);
-							
+							// System.out.println("ROLE LIST roleItems.length
+							// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+roleItems.length);
+
 							// new Role
 							// new Role
 							if (roleIdItems != null) {
 							if (roleIdItems != null) {
 								for (Object objectRoleIdItem : roleIdItems) {
 								for (Object objectRoleIdItem : roleIdItems) {
 									Role role = (Role) objectRoleIdItem;
 									Role role = (Role) objectRoleIdItem;
-									//System.out.println("ROLE LIST role.getName() >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  "+role.getName());
+									// System.out.println("ROLE LIST role.getName()
+									// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+role.getName());
 									if ("ACTIVE".equals(role.getStatus())) {
 									if ("ACTIVE".equals(role.getStatus())) {
 										Collection<Privilege> privileges = role.getPrivileges();
 										Collection<Privilege> privileges = role.getPrivileges();
-										//System.out.println("ROLE LIST role.privileges() >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  "+privileges);
+										// System.out.println("ROLE LIST role.privileges()
+										// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+privileges);
 										if (privileges != null) {
 										if (privileges != null) {
 											Iterator itrPrivileges = privileges.iterator();
 											Iterator itrPrivileges = privileges.iterator();
-											while(itrPrivileges.hasNext()) {
-												Privilege privilege = (Privilege)itrPrivileges.next();
+											while (itrPrivileges.hasNext()) {
+												Privilege privilege = (Privilege) itrPrivileges.next();
 												if (privilege.getType().equalsIgnoreCase("PRIV_TYPE_MENU")) {
 												if (privilege.getType().equalsIgnoreCase("PRIV_TYPE_MENU")) {
-													//System.out.println("ROLE LIST role.privileges().add >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  "+privilege.getName());
-													privilegeList.add(privilege);													
+													// System.out.println("ROLE LIST role.privileges().add
+													// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+privilege.getName());
+													privilegeList.add(privilege);
 												}
 												}
 
 
-
 											}
 											}
 										}
 										}
 									}
 									}
@@ -472,8 +475,9 @@ public class Util {
 					for (int i = 0; i < privilegeList.size(); i++) {
 					for (int i = 0; i < privilegeList.size(); i++) {
 						if (privilegeList.get(i).getParent() == null && "ACTIVE".equals(privilegeList.get(i).getStatus())) {
 						if (privilegeList.get(i).getParent() == null && "ACTIVE".equals(privilegeList.get(i).getStatus())) {
 							if (!sb.toString().contains("'" + privilegeList.get(i).getName() + "'")) {
 							if (!sb.toString().contains("'" + privilegeList.get(i).getName() + "'")) {
-								// sb.append("['"+ privilegeList.get(i).getName()+"','"+privilegeList.get(i).getPath()+"',0,0");
-//								sb.append("[null,'" + privilegeList.get(i).getName() + "',null,null");
+								// sb.append("['"+
+								// privilegeList.get(i).getName()+"','"+privilegeList.get(i).getPath()+"',0,0");
+								// sb.append("[null,'" + privilegeList.get(i).getName() + "',null,null");
 								sb.append("[null,'" + privilegeList.get(i).getName() + "','" + privilegeList.get(i).getPath() + "&ts=trxZ\'" + ",null,null");
 								sb.append("[null,'" + privilegeList.get(i).getName() + "','" + privilegeList.get(i).getPath() + "&ts=trxZ\'" + ",null,null");
 								getChilds(sb, privilegeList, privilegeList.get(i), false);
 								getChilds(sb, privilegeList, privilegeList.get(i), false);
 								sb.append("],");
 								sb.append("],");
@@ -550,14 +554,14 @@ public class Util {
 							if ("ACTIVE".equals(role.getStatus())) {
 							if ("ACTIVE".equals(role.getStatus())) {
 								Collection<Privilege> privileges = role.getPrivileges();
 								Collection<Privilege> privileges = role.getPrivileges();
 								if (privileges != null) {
 								if (privileges != null) {
-									
+
 									Iterator itrPrivileges = privileges.iterator();
 									Iterator itrPrivileges = privileges.iterator();
-									while(itrPrivileges.hasNext()) {
-										Privilege privilege = (Privilege)itrPrivileges.next();
+									while (itrPrivileges.hasNext()) {
+										Privilege privilege = (Privilege) itrPrivileges.next();
 										if (privilege.getType().equalsIgnoreCase("PRIV_TYPE_MENU"))
 										if (privilege.getType().equalsIgnoreCase("PRIV_TYPE_MENU"))
 											privilegeList.add(privilege);
 											privilegeList.add(privilege);
 									}
 									}
-									
+
 								}
 								}
 							}
 							}
 						}
 						}
@@ -567,7 +571,9 @@ public class Util {
 			}
 			}
 
 
 			/*
 			/*
-			 * Collections.sort(privilegeList,new Comparator() { public int compare(Object o1, Object o2) { Privilege p1 = (Privilege)o1; Privilege p2 = (Privilege)o2; return p1.getPriority().compareTo(p2.getPriority()); } });
+			 * Collections.sort(privilegeList,new Comparator() { public int compare(Object
+			 * o1, Object o2) { Privilege p1 = (Privilege)o1; Privilege p2 = (Privilege)o2;
+			 * return p1.getPriority().compareTo(p2.getPriority()); } });
 			 */
 			 */
 
 
 			StringBuffer sb = new StringBuffer();
 			StringBuffer sb = new StringBuffer();
@@ -718,13 +724,13 @@ public class Util {
 			logActivity.setType(type);
 			logActivity.setType(type);
 			logActivity.setDesc(desc);
 			logActivity.setDesc(desc);
 			logActivity.setFromApp(fromApp);
 			logActivity.setFromApp(fromApp);
-			String callerPrincipal = (String)request.getSession().getAttribute("login.user");
-			if(callerPrincipal!=null) {
-				logActivity.setUser(callerPrincipal);	
-			}else {
+			String callerPrincipal = (String) request.getSession().getAttribute("login.user");
+			if (callerPrincipal != null) {
+				logActivity.setUser(callerPrincipal);
+			} else {
 				logActivity.setUser("SYSREKON");
 				logActivity.setUser("SYSREKON");
-			}			
-			
+			}
+
 			ChangeLogServiceInterface clsi = ServiceUtil.getChangeLogClient(ctx);
 			ChangeLogServiceInterface clsi = ServiceUtil.getChangeLogClient(ctx);
 			clsi.insert(Constant.MWLOG_DS, logActivity, old, New);
 			clsi.insert(Constant.MWLOG_DS, logActivity, old, New);
 
 
@@ -732,26 +738,26 @@ public class Util {
 			e.printStackTrace();
 			e.printStackTrace();
 		}
 		}
 	}
 	}
-	
+
 	public Collection arrayToCollection(Object[] obj) {
 	public Collection arrayToCollection(Object[] obj) {
 		Collection a = new ArrayList();
 		Collection a = new ArrayList();
-		for(int i = 0; i < obj.length;i++) {
+		for (int i = 0; i < obj.length; i++) {
 			a.add(obj[i]);
 			a.add(obj[i]);
 		}
 		}
 		return a;
 		return a;
 	}
 	}
-	
+
 	public Object[] collectionToArray(Collection obj) {
 	public Object[] collectionToArray(Collection obj) {
 		Object[] o = null;
 		Object[] o = null;
-		if(obj!=null) {
+		if (obj != null) {
 			o = new Object[obj.size()];
 			o = new Object[obj.size()];
 			Iterator itr = obj.iterator();
 			Iterator itr = obj.iterator();
 			int i = 0;
 			int i = 0;
-			while(itr.hasNext()) {
-				Object object = (Object)itr.next();
+			while (itr.hasNext()) {
+				Object object = (Object) itr.next();
 				o[i] = object;
 				o[i] = object;
 				i++;
 				i++;
-			}			
+			}
 		}
 		}
 		return o;
 		return o;
 	}
 	}

+ 5 - 1
README.md

@@ -3,6 +3,7 @@
 This guide provides the steps to manually install the required JAR files into your local Maven repository using the `mvn install:install-file` command.
 This guide provides the steps to manually install the required JAR files into your local Maven repository using the `mvn install:install-file` command.
 
 
 ## Prerequisites
 ## Prerequisites
+
 1. Ensure that you have Apache Maven installed and properly configured in your system.
 1. Ensure that you have Apache Maven installed and properly configured in your system.
 2. Verify that the JAR files listed below are available in the specified paths.
 2. Verify that the JAR files listed below are available in the specified paths.
 
 
@@ -18,4 +19,7 @@ mvn install:install-file -Dfile=./SharedLib/hanoman-util-1.0.jar -DgroupId=id.co
 mvn install:install-file -Dfile=./SharedLib/hcx.jar -DgroupId=id.co.hanoman -DartifactId=hcx -Dversion=1.0 -Dpackaging=jar
 mvn install:install-file -Dfile=./SharedLib/hcx.jar -DgroupId=id.co.hanoman -DartifactId=hcx -Dversion=1.0 -Dpackaging=jar
 mvn install:install-file -Dfile=./SharedLib/scutils.jar -DgroupId=com.scupid -DartifactId=scutils -Dversion=1.0 -Dpackaging=jar
 mvn install:install-file -Dfile=./SharedLib/scutils.jar -DgroupId=com.scupid -DartifactId=scutils -Dversion=1.0 -Dpackaging=jar
 mvn install:install-file -Dfile=./SharedLib/SppSynchronizerLibrary.jar -DgroupId=com.ztdev -DartifactId=SppSynchronizerLibrary -Dversion=1.0 -Dpackaging=jar
 mvn install:install-file -Dfile=./SharedLib/SppSynchronizerLibrary.jar -DgroupId=com.ztdev -DartifactId=SppSynchronizerLibrary -Dversion=1.0 -Dpackaging=jar
-```
+
+mvn install:install-file -Dfile=./SharedLib/jplugin2.jar -DgroupId=id.co.hanoman -DartifactId=jplugin2 -Dversion=1.0 -Dpackaging=jar
+mvn install:install-file -Dfile=./SharedLib/id.co.hanoman.btnmw.license -DgroupId=id.co.hanoman -DartifactId=btnmw -Dversion=1.0 -Dpackaging=license
+```