|
|
@@ -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;
|
|
|
}
|