1
0
Эх сурвалжийг харах

update readme add license howto

arkha 1 жил өмнө
parent
commit
236dbf3474

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

@@ -7,8 +7,25 @@
         <feature>jdbc-4.2</feature>
         <feature>servlet-4.0</feature>
         <feature>jndi-1.0</feature>
+        <feature>appSecurity-3.0</feature>
     </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="https.port" defaultValue="9443" />
     <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 {
 			// long sessionTimeout = 300000;
 			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();) {
 				String s = (String) iterator.next();
 				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) {
 		try {
 			// 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;
 			// if (sysParam == null) {
 			// 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();) {
 				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 {
 					if (s.indexOf('_') != -1) {
 						try {
@@ -349,12 +350,11 @@ public class Util {
 		Properties props = getProperties(ctx);
 		return props.getProperty("wpsPort");
 	}
-	
-	
+
 	public ArrayList objRoller(String callerPrincipal) {
 		ArrayList rs = new ArrayList();
 		try {
-			
+
 			String dbCode = "LDAP_LIVE";
 			PersistanceServiceInterface psiConfig = ServiceUtil.getDaoClient(null);
 			Dbconn dbconn = (Dbconn) psiConfig.queryById(Constant.MWCONFIG_DS, "Dbconn", dbCode, null);
@@ -362,38 +362,38 @@ public class Util {
 			String base = dbconn.getDriver();
 			String userBind = dbconn.getUsername();
 			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();
 			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_PRINCIPAL, pn);
 			env.put(Context.SECURITY_CREDENTIALS, "wpsadmindev");
 			InitialDirContext ctx = null;
 			try {
 				ctx = new InitialDirContext(env);
-			}catch (Exception e) {
+			} catch (Exception e) {
 				e.printStackTrace();
 			}
-			
-			if(ctx!=null) {
+
+			if (ctx != null) {
 				SearchControls ctrls = new SearchControls();
 				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();
 				System.out.println("distinguisedName: " + result.getNameInNamespace());
 				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();
 						strGroupIdCallerSubjectItem = strGroupIdCallerSubjectItem.substring(strGroupIdCallerSubjectItem.toLowerCase().indexOf("cn=") + 3);
 						strGroupIdCallerSubjectItem = strGroupIdCallerSubjectItem.substring(0, strGroupIdCallerSubjectItem.indexOf(','));
@@ -403,12 +403,12 @@ public class Util {
 				}
 				ctx.close();
 			}
-		}catch (Exception e) {
+		} catch (Exception e) {
 			e.printStackTrace();
 		}
 		return rs;
 	}
-	
+
 	public static void updateMenu(PersistanceServiceInterface psiConfig, HttpServletRequest request, String callerPrincipal, List objRoleCaller) {
 		try {
 			List<Privilege> privilegeList = new ArrayList<Privilege>();
@@ -430,26 +430,29 @@ public class Util {
 							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);
 							Object[] roleIdItems = roleIdList.getItems();
-							//System.out.println("ROLE LIST roleItems.length >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  "+roleItems.length);
-							
+							// System.out.println("ROLE LIST roleItems.length
+							// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+roleItems.length);
+
 							// new Role
 							if (roleIdItems != null) {
 								for (Object objectRoleIdItem : roleIdItems) {
 									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())) {
 										Collection<Privilege> privileges = role.getPrivileges();
-										//System.out.println("ROLE LIST role.privileges() >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  "+privileges);
+										// System.out.println("ROLE LIST role.privileges()
+										// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+privileges);
 										if (privileges != null) {
 											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")) {
-													//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++) {
 						if (privilegeList.get(i).getParent() == null && "ACTIVE".equals(privilegeList.get(i).getStatus())) {
 							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");
 								getChilds(sb, privilegeList, privilegeList.get(i), false);
 								sb.append("],");
@@ -550,14 +554,14 @@ public class Util {
 							if ("ACTIVE".equals(role.getStatus())) {
 								Collection<Privilege> privileges = role.getPrivileges();
 								if (privileges != null) {
-									
+
 									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"))
 											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();
@@ -718,13 +724,13 @@ public class Util {
 			logActivity.setType(type);
 			logActivity.setDesc(desc);
 			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");
-			}			
-			
+			}
+
 			ChangeLogServiceInterface clsi = ServiceUtil.getChangeLogClient(ctx);
 			clsi.insert(Constant.MWLOG_DS, logActivity, old, New);
 
@@ -732,26 +738,26 @@ public class Util {
 			e.printStackTrace();
 		}
 	}
-	
+
 	public Collection arrayToCollection(Object[] obj) {
 		Collection a = new ArrayList();
-		for(int i = 0; i < obj.length;i++) {
+		for (int i = 0; i < obj.length; i++) {
 			a.add(obj[i]);
 		}
 		return a;
 	}
-	
+
 	public Object[] collectionToArray(Collection obj) {
 		Object[] o = null;
-		if(obj!=null) {
+		if (obj != null) {
 			o = new Object[obj.size()];
 			Iterator itr = obj.iterator();
 			int i = 0;
-			while(itr.hasNext()) {
-				Object object = (Object)itr.next();
+			while (itr.hasNext()) {
+				Object object = (Object) itr.next();
 				o[i] = object;
 				i++;
-			}			
+			}
 		}
 		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.
 
 ## Prerequisites
+
 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.
 
@@ -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/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/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
+```