|
@@ -17,8 +17,8 @@ import java.security.NoSuchAlgorithmException;
|
|
|
import java.util.*;
|
|
|
|
|
|
public final class RSBIUtils {
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 给str加密md5。
|
|
|
* @return
|
|
@@ -33,36 +33,36 @@ public final class RSBIUtils {
|
|
|
* @param source
|
|
|
* @return
|
|
|
*/
|
|
|
- public static String getMD5(byte[] source) {
|
|
|
- String s = null;
|
|
|
- char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
|
|
- 'a', 'b', 'c', 'd', 'e', 'f' };// 用来将字节转换成16进制表示的字符
|
|
|
- try {
|
|
|
- java.security.MessageDigest md = java.security.MessageDigest
|
|
|
- .getInstance("MD5");
|
|
|
- md.update(source);
|
|
|
- byte tmp[] = md.digest();// MD5 的计算结果是一个 128 位的长整数,
|
|
|
- // 用字节表示就是 16 个字节
|
|
|
- char str[] = new char[16 * 2];// 每个字节用 16 进制表示的话,使用两个字符, 所以表示成 16
|
|
|
- // 进制需要 32 个字符
|
|
|
- int k = 0;// 表示转换结果中对应的字符位置
|
|
|
- for (int i = 0; i < 16; i++) {// 从第一个字节开始,对 MD5 的每一个字节// 转换成 16
|
|
|
- // 进制字符的转换
|
|
|
- byte byte0 = tmp[i];// 取第 i 个字节
|
|
|
- str[k++] = hexDigits[byte0 >>> 4 & 0xf];// 取字节中高 4 位的数字转换,// >>>
|
|
|
- // 为逻辑右移,将符号位一起右移
|
|
|
- str[k++] = hexDigits[byte0 & 0xf];// 取字节中低 4 位的数字转换
|
|
|
+ public static String getMD5(byte[] source) {
|
|
|
+ String s = null;
|
|
|
+ char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
|
|
+ 'a', 'b', 'c', 'd', 'e', 'f' };// 用来将字节转换成16进制表示的字符
|
|
|
+ try {
|
|
|
+ java.security.MessageDigest md = java.security.MessageDigest
|
|
|
+ .getInstance("MD5");
|
|
|
+ md.update(source);
|
|
|
+ byte tmp[] = md.digest();// MD5 的计算结果是一个 128 位的长整数,
|
|
|
+ // 用字节表示就是 16 个字节
|
|
|
+ char str[] = new char[16 * 2];// 每个字节用 16 进制表示的话,使用两个字符, 所以表示成 16
|
|
|
+ // 进制需要 32 个字符
|
|
|
+ int k = 0;// 表示转换结果中对应的字符位置
|
|
|
+ for (int i = 0; i < 16; i++) {// 从第一个字节开始,对 MD5 的每一个字节// 转换成 16
|
|
|
+ // 进制字符的转换
|
|
|
+ byte byte0 = tmp[i];// 取第 i 个字节
|
|
|
+ str[k++] = hexDigits[byte0 >>> 4 & 0xf];// 取字节中高 4 位的数字转换,// >>>
|
|
|
+ // 为逻辑右移,将符号位一起右移
|
|
|
+ str[k++] = hexDigits[byte0 & 0xf];// 取字节中低 4 位的数字转换
|
|
|
|
|
|
- }
|
|
|
- s = new String(str);// 换后的结果转换为字符串
|
|
|
+ }
|
|
|
+ s = new String(str);// 换后的结果转换为字符串
|
|
|
|
|
|
- } catch (NoSuchAlgorithmException e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return s;
|
|
|
+ } catch (NoSuchAlgorithmException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return s;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 获取ext-config中配置的变量。
|
|
|
* @return
|
|
@@ -73,7 +73,7 @@ public final class RSBIUtils {
|
|
|
public static String getUUIDStr(){
|
|
|
return UUID.randomUUID().toString().replace("-","");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static String dealStringParam(List<String> vals){
|
|
|
if(vals == null){
|
|
|
return null;
|
|
@@ -102,7 +102,7 @@ public final class RSBIUtils {
|
|
|
}
|
|
|
return sb.toString();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static Map<String, String> getAllParams(HttpServletRequest req){
|
|
|
Map<String, String> dt = new HashMap<String, String>();
|
|
|
Enumeration<String> enu = req.getParameterNames();
|
|
@@ -112,7 +112,7 @@ public final class RSBIUtils {
|
|
|
}
|
|
|
return dt;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static boolean isShowMenu(String name, HttpServletRequest req){
|
|
|
JSONObject obj = (JSONObject)req.getAttribute("menuDisp");
|
|
|
if(obj == null){
|
|
@@ -128,12 +128,12 @@ public final class RSBIUtils {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static String getAppUserId(){
|
|
|
String uid = "";
|
|
|
return uid;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static SqlSession getSqlSession(ServletContext sctx){
|
|
|
SqlSession sqlSession=null;
|
|
|
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(sctx);
|
|
@@ -141,19 +141,19 @@ public final class RSBIUtils {
|
|
|
sqlSession = sqlSessionFactory.openSession();
|
|
|
return sqlSession;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static void closeSqlSession(SqlSession sqlSession){
|
|
|
if(sqlSession!=null){
|
|
|
sqlSession.close();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static User getLoginUserInfo(){
|
|
|
Subject us = SecurityUtils.getSubject();
|
|
|
User u = (User)us.getSession().getAttribute(ShiroDbRealm.SESSION_USER_KEY);
|
|
|
return u;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 生成导出html
|
|
|
* @param body
|
|
@@ -163,11 +163,11 @@ public final class RSBIUtils {
|
|
|
*/
|
|
|
public static String htmlPage(String body, String host, String type){
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
-
|
|
|
+
|
|
|
sb.append("<!DOCTYPE html>");
|
|
|
sb.append("<html lang=\"en\">");
|
|
|
sb.append("<head>");
|
|
|
- sb.append("<title>睿思BI</title>");
|
|
|
+ sb.append("<title>首佳BI</title>");
|
|
|
sb.append("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0\">");
|
|
|
sb.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
|
|
|
sb.append("<script type=\"text/javascript\" src=\""+host+"/ext-res/js/jquery.min.js\"></script>");
|
|
@@ -189,15 +189,15 @@ public final class RSBIUtils {
|
|
|
sb.append(".inputtext {width:90px;}");
|
|
|
sb.append("</style>");
|
|
|
sb.append("<body class=\"gray-bg\">");
|
|
|
-
|
|
|
+
|
|
|
sb.append(body);
|
|
|
-
|
|
|
+
|
|
|
sb.append("</body>");
|
|
|
sb.append("</html>");
|
|
|
-
|
|
|
+
|
|
|
return sb.toString();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static boolean exist(String id, String[] ids){
|
|
|
boolean exist = false;
|
|
|
for(String tid : ids){
|
|
@@ -208,9 +208,9 @@ public final class RSBIUtils {
|
|
|
}
|
|
|
return exist;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
- * 将容易引起xss漏洞的半角字符直接替换成全角字符 在保证不删除数据的情况下保存
|
|
|
+ * 将容易引起xss漏洞的半角字符直接替换成全角字符 在保证不删除数据的情况下保存
|
|
|
* @param value
|
|
|
* @return
|
|
|
*/
|
|
@@ -226,7 +226,7 @@ public final class RSBIUtils {
|
|
|
value = value.replaceAll("script", "");
|
|
|
return value;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Escape解码
|
|
|
* @param src 加盐字符串
|