现在都有什么电影技术??

最近一个人在写一个论坛系统,求共享在现实中的项目的WEB开发安全姿势。
对于常见的SQL注入采用预编译就行了,但是很多时候简单的条件较多或较为复杂的时候很多人都想偷懒拼SQL总是似乎免不了的。
写了个这样的多条件查询条件自动匹配:
public static String SQL_FORUM_CLASS_SETTING = &SELECT * from bjcyw_forum_forum where 1=1 &;
public List&Map&String, Object&& getForumClass(Map&String,Object& forum) {
&&&&StringBuilder sql=new StringBuilder(SQL_FORUM_CLASS_SETTING);
&&&&List&Object& ls=new ArrayList&Object&();
&&&&if (forum.size()&0) {
&&&&&&for (String key : forum.keySet()) {
&&&&&&&&Object obj[]=(Object [])forum.get(key);
&&&&&&&&sql = SqlHelper.selectHelper(sql, obj);
&&&&&&&&if (&like&.equalsIgnoreCase(obj[2].toString().trim())) {
&&&&&&&&&&ls.add(&%&+obj[1]+&%&);
&&&&&&&&}else {
&&&&&&&&&&ls.add(obj[1]);
&&&&&&&&}
&&&&&&}
&&&&}
&&&&return jdbcTemplate.queryForList(sql.toString(),(Object[])ls.toArray());
&&}
public static StringBuilder selectHelper(StringBuilder sql, Object obj[]){
&&&&if (Constants.SQL_HELPER_LIKE.equalsIgnoreCase(obj[2].toString())) {
&&&&&&sql.append(& AND &+obj[0]+& like ?&);
&&&&}else if (Constants.SQL_HELPER_EQUAL.equalsIgnoreCase(obj[2].toString())) {
&&&&&&sql.append(& AND &+obj[0]+& = ?&);
&&&&}else if (Constants.SQL_HELPER_GREATERTHAN.equalsIgnoreCase(obj[2].toString())) {
&&&&&&sql.append(& AND &+obj[0]+& & ?&);
&&&&}else if (Constants.SQL_HELPER_LESSTHAN.equalsIgnoreCase(obj[2].toString())) {
&&&&&&sql.append(& AND &+obj[0]+& & ?&);
&&&&}else if (Constants.SQL_HELPER_NOTEQUAL.equalsIgnoreCase(obj[2].toString())) {
&&&&&&sql.append(& AND &+obj[0]+& != ?&);
&&&&}
&&&&
&&}
信任客户端的参数一切参数只匹配查询条件,把参数和条件自动装配到框架。如果客户端提交了危险的SQL也没有关系在query的时候是会预编译。
XSS和Get的参数的简易处理(参数过滤得有点问题,懒得改一般就用下htmlSpecialChars):
package net.ltan.bbs.
import java.net.InetA
import java.net.UnknownHostE
import java.util.regex.M
import java.util.regex.P
import javax.servlet.http.HttpServletR
import javax.servlet.http.HttpServletR
import org.apache.log4j.L
* 检测用户提交的数据
* @author selina
*/
public class CheckRequestData {
&&
&&public static String getIpAddr(HttpServletRequest request) {
&&&&String ipAddress =
&&&&ipAddress = request.getHeader(&x-forwarded-for&);
&&&&if (ipAddress == null || ipAddress.length() == 0
&&&&&&&&|| &unknown&.equalsIgnoreCase(ipAddress)) {
&&&&&&ipAddress = request.getHeader(&Proxy-Client-IP&);
&&&&}
&&&&if (ipAddress == null || ipAddress.length() == 0
&&&&&&&&|| &unknown&.equalsIgnoreCase(ipAddress)) {
&&&&&&ipAddress = request.getHeader(&WL-Proxy-Client-IP&);
&&&&}
&&&&if (ipAddress == null || ipAddress.length() == 0
&&&&&&&&|| &unknown&.equalsIgnoreCase(ipAddress)) {
&&&&&&ipAddress = request.getRemoteAddr();
&&&&&&if (ipAddress.equals(&127.0.0.1&)) {
&&&&&&&&// 根据网卡取本机配置的IP
&&&&&&&&InetAddress inet =
&&&&&&&&try {
&&&&&&&&&&inet = InetAddress.getLocalHost();
&&&&&&&&} catch (UnknownHostException e) {
&&&&&&&&&&e.printStackTrace();
&&&&&&&&}
&&&&&&&&ipAddress = inet.getHostAddress();
&&&&&&}
&&&&}
&&&&// 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
&&&&if (ipAddress != null && ipAddress.length() & 15) { // &***.***.***.***&.length()
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&// = 15
&&&&&&if (ipAddress.indexOf(&,&) & 0) {
&&&&&&&&ipAddress = ipAddress.substring(0, ipAddress.indexOf(&,&));
&&&&&&}
&&&&}
&&&&return ipA
&&}
&&
&&/**
&& * SQL注入于XSS攻击自动检测
&& * @param str
&& * @return
&& */
&&public static boolean checkSqlInjection(String str) {
&&&&Logger logger = Logger.getLogger(&u3&);
&&&&String limit = &-囧script囧alert囧hex囧\\(囧\\)囧\\*囧iframe囧\\+囧\\%囧window囧cookie囧and囧or囧net user囧/add囧execute囧into囧outfile囧exec囧net囧select囧count囧char囧insert囧delete囧drop囧from囧master囧truncate囧char囧declare囧or囧by囧;囧#囧%囧`囧:囧\&囧\'囧&;
&&&&String keys[] = limit.split(&囧&);
&&&&for (int i = 0; i & keys. i++) {
&&&&&&Pattern checkSQL = pile(keys[i],Pattern.CASE_INSENSITIVE);
&&&&&&Matcher matcherFaild = checkSQL.matcher(str.trim());
&&&&&&if (matcherFaild.find()) {
&&&&&&&&(&攻击地址:&+str);
&&&&&&&&
&&&&&&}
&&&&}
&&&&
&&}
&&
&&/**
&& * 模拟PHP的htmlSpecialChars,替换HTML标记
&& * @param str
&& * @return
&& */
&&public static String htmlSpecialChars(String str) {
&&&&str = str.replaceAll(&&&, &&&);
&&&&str = str.replaceAll(&&&, &&&);
&&&&str = str.replaceAll(&&&, &&&);
&&&&str = str.replaceAll(&\&&, &&&);
&&&&str = str.replaceAll(&'&, &'&);
&&&&
&&}
}
防御还得从根入手,JEECMS在这做的就非常不错。是JSP、PHP、ASP的filter让所有的动态脚本请求失效,我们也可以采用类似的手段来保护我们的WEB应用程序。
我这里采用的框架是:Spring3+SpringMVC+FreeMarker。没有采用ORM框架而是用了Spring的jdbcTemplate,缓存采用了memcached(IP限制端口修改)。服务器:apache+nginx+resin3。
展示层采用了htm,对没错只是把freemarker的ftl换做了htm然后在htm里面写freemarker的循环。
&!-- FreeMarker 配置 --&
&&&servlet&
&&&&&servlet-name&freemarker&/servlet-name&
&&&&&servlet-class&freemarker.ext.servlet.FreemarkerServlet&/servlet-class&
&&&&&!-- FreemarkerServlet settings: --&
&&&&&init-param&
&&&&&&&param-name&TemplatePath&/param-name&
&&&&&&&param-value&/&/param-value&
&&&&&/init-param&
&&&&&init-param&
&&&&&&&param-name&NoCache&/param-name&
&&&&&&&param-value&true&/param-value&
&&&&&/init-param&
&&&&&init-param&
&&&&&&&param-name&ContentType&/param-name&
&&&&&&&param-value&text/html&/param-value&
&&&&&/init-param&
&&&&&!-- FreeMarker settings: --&
&&&&&init-param&
&&&&&&&param-name&template_update_delay&/param-name&
&&&&&&&param-value&0&/param-value&
&&&&&&&!--
&&&&&&&&0 is for development only! Use higher value otherwise.
&&&&&&--&
&&&&&/init-param&
&&&&&init-param&
&&&&&&&param-name&default_encoding&/param-name&
&&&&&&&param-value&utf-8&/param-value&
&&&&&/init-param&
&&&&&init-param&
&&&&&&&param-name&locale&/param-name&
&&&&&&&param-value&zh_CN&/param-value&
&&&&&/init-param&
&&&&&init-param&
&&&&&&&param-name&number_format&/param-name&
&&&&&&&param-value&0.##########&/param-value&
&&&&&/init-param&
&&&&&load-on-startup&1&/load-on-startup&
&&&/servlet&
&&&servlet-mapping&
&&&&&servlet-name&freemarker&/servlet-name&
&&&&&url-pattern&*.htm&/url-pattern&
&&&/servlet-mapping&
控制层的配置:
&servlet&
&&&&&servlet-name&dispatcherServlet&/servlet-name&
&&&&&servlet-class&org.springframework.web.servlet.DispatcherServlet&/servlet-class&
&&&&&init-param&
&&&&&&&param-name&contextConfigLocation&/param-name&
&&&&&&&param-value&/WEB-INF/applicationContext.xml&/param-value&
&&&&&/init-param&
&&&&&load-on-startup&1&/load-on-startup&
&&&/servlet&
&&
&&&servlet-mapping&
&&&&&servlet-name&dispatcherServlet&/servlet-name&
&&&&&url-pattern&*.shmtl&/url-pattern&
&&&&&url-pattern&*.php&/url-pattern&
&&&&&url-pattern&*.phpx&/url-pattern&
&&&/servlet-mapping&
很明显我们的一切的shmtl(特殊业务保留后缀)、php(前台的普通业务请求后缀)、phpx(后台的一般请求后缀)都会被Spring处理。URL授权和业务逻辑权限控制。也许用户在前台会看到这样的连接:http://ltan.net/index.php。但是这并不是请求了服务器的index.php文件而是Controller,采用了kindEditor,简单改改就行了:
package net.ltan.bbs.app.
import java.util.*;
import java.io.*;
import java.text.SimpleDateF
import javax.servlet.http.HttpServletR
import javax.servlet.http.HttpServletR
import mons.fileupload.*;
import mons.fileupload.disk.*;
import mons.fileupload.servlet.*;
import org.json.simple.*;
import org.springframework.stereotype.C
import org.springframework.web.bind.annotation.RequestM
* kindEditor 编辑器文件上传
* @author selina
*/
@SuppressWarnings(&unchecked&)
@Controller
public class KindEditorUploadUtil {
&&@RequestMapping(&/editor/upload_json.php&)
&&public void upload(HttpServletRequest request, HttpServletResponse response)
&&&&&&throws IOException, FileUploadException {
&&&&PrintWriter out = response.getWriter();
&&&&// 文件保存目录路径
&&&&String savePath = request.getSession().getServletContext().getRealPath(
&&&&&&&&&/&)
&&&&&&&&+ &uploads/&;
&&&&// 文件保存目录URL
&&&&String saveUrl = request.getContextPath() + &/uploads/&;
&&&&// 定义允许上传的文件扩展名
&&&&HashMap&String, String& extMap = new HashMap&String, String&();
&&&&extMap.put(&image&, &gif,jpg,jpeg,png,bmp&);
&&&&extMap.put(&flash&, &swf,flv&);
&&&&extMap.put(&media&, &swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb&);
&&&&extMap.put(&file&, &doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2&);
&&&&// 最大文件大小
&&&&long maxSize = 1000000;
&&&&response.setContentType(&text/ charset=UTF-8&);
&&&&if (!ServletFileUpload.isMultipartContent(request)) {
&&&&&&out.println(getError(&请选择文件。&));
&&&&&&
&&&&}
&&&&// 检查目录
&&&&File uploadDir = new File(savePath);
&&&&if (!uploadDir.isDirectory()) {
&&&&&&out.println(getError(&上传目录不存在。&));
&&&&&&
&&&&}
&&&&// 检查目录写权限
&&&&if (!uploadDir.canWrite()) {
&&&&&&out.println(getError(&上传目录没有写权限。&));
&&&&&&
&&&&}
&&&&String dirName = request.getParameter(&dir&);
&&&&if (dirName == null) {
&&&&&&dirName = &image&;
&&&&}
&&&&if (!extMap.containsKey(dirName)) {
&&&&&&out.println(getError(&目录名不正确。&));
&&&&&&
&&&&}
&&&&// 创建文件夹
&&&&savePath += dirName + &/&;
&&&&saveUrl += dirName + &/&;
&&&&File saveDirFile = new File(savePath);
&&&&if (!saveDirFile.exists()) {
&&&&&&saveDirFile.mkdirs();
&&&&}
&&&&SimpleDateFormat sdf = new SimpleDateFormat(&yyyyMMdd&);
&&&&String ymd = sdf.format(new Date());
&&&&savePath += ymd + &/&;
&&&&saveUrl += ymd + &/&;
&&&&File dirFile = new File(savePath);
&&&&if (!dirFile.exists()) {
&&&&&&dirFile.mkdirs();
&&&&}
&&&&FileItemFactory factory = new DiskFileItemFactory();
&&&&ServletFileUpload upload = new ServletFileUpload(factory);
&&&&upload.setHeaderEncoding(&UTF-8&);
&&&&List items = upload.parseRequest(request);
&&&&Iterator itr = items.iterator();
&&&&while (itr.hasNext()) {
&&&&&&FileItem item = (FileItem) itr.next();
&&&&&&String fileName = item.getName();
&&&&&&if (!item.isFormField()) {
&&&&&&&&// 检查文件大小
&&&&&&&&if (item.getSize() & maxSize) {
&&&&&&&&&&out.println(getError(&上传文件大小超过限制。&));
&&&&&&&&&&
&&&&&&&&}
&&&&&&&&// 检查扩展名
&&&&&&&&String fileExt = fileName.substring(
&&&&&&&&&&&&fileName.lastIndexOf(&.&) + 1).toLowerCase();
&&&&&&&&if (!Arrays.&String& asList(extMap.get(dirName).split(&,&))
&&&&&&&&&&&&.contains(fileExt)) {
&&&&&&&&&&out.println(getError(&上传文件扩展名是不允许的扩展名。\n只允许&
&&&&&&&&&&&&&&+ extMap.get(dirName) + &格式。&));
&&&&&&&&&&
&&&&&&&&}
&&&&&&&&SimpleDateFormat df = new SimpleDateFormat(&yyyyMMddHHmmss&);
&&&&&&&&String newFileName = df.format(new Date()) + &_&
&&&&&&&&&&&&+ new Random().nextInt(1000) + &.& + fileE
&&&&&&&&try {
&&&&&&&&&&File uploadedFile = new File(savePath, newFileName);
&&&&&&&&&&item.write(uploadedFile);
&&&&&&&&} catch (Exception e) {
&&&&&&&&&&out.println(getError(&上传文件失败。&));
&&&&&&&&&&
&&&&&&&&}
&&&&&&&&JSONObject obj = new JSONObject();
&&&&&&&&obj.put(&error&, 0);
&&&&&&&&obj.put(&url&, saveUrl + newFileName);
&&&&&&&&out.println(obj.toJSONString());
&&&&&&}
&&&&}
&&private String getError(String message) {
&&&&JSONObject obj = new JSONObject();
&&&&obj.put(&error&, 1);
&&&&obj.put(&message&, message);
&&&&return obj.toJSONString();
&&}
package net.ltan.bbs.app.
import java.util.*;
import java.io.*;
import java.text.SimpleDateF
import javax.servlet.http.HttpServletR
import javax.servlet.http.HttpServletR
import mons.fileupload.FileUploadE
import org.json.simple.*;
import org.springframework.stereotype.C
import org.springframework.web.bind.annotation.RequestM
* kindEditor 编辑器文件管理
* @author selina
*/
@SuppressWarnings(&unchecked&)
@Controller
public class KindEditorFileManager {
&&@RequestMapping(&/editor/file_manager_json.php&)
&&public void fileManager(HttpServletRequest request,
&&&&&&HttpServletResponse response) throws IOException,
&&&&&&FileUploadException {
&&&&PrintWriter out = response.getWriter();
&&&&// 根目录路径,可以指定绝对路径,比如 /var/www/attached/
&&&&String rootPath = request.getSession().getServletContext().getRealPath(
&&&&&&&&&/&)
&&&&&&&&+ &uploads/&;
&&&&// 根目录URL,可以指定绝对路径,比如 /attached/
&&&&String rootUrl = request.getContextPath() + &/uploads/&;
&&&&// 图片扩展名
&&&&String[] fileTypes = new String[] { &gif&, &jpg&, &jpeg&, &png&, &bmp& };
&&&&String dirName = request.getParameter(&dir&);
&&&&if (dirName != null) {
&&&&&&if (!Arrays.&String& asList(
&&&&&&&&&&new String[] { &image&, &flash&, &media&, &file& })
&&&&&&&&&&.contains(dirName)) {
&&&&&&&&out.println(&Invalid Directory name.&);
&&&&&&&&
&&&&&&}
&&&&&&rootPath += dirName + &/&;
&&&&&&rootUrl += dirName + &/&;
&&&&&&File saveDirFile = new File(rootPath);
&&&&&&if (!saveDirFile.exists()) {
&&&&&&&&saveDirFile.mkdirs();
&&&&&&}
&&&&}
&&&&// 根据path参数,设置各路径和URL
&&&&String path = request.getParameter(&path&) != null ? request
&&&&&&&&.getParameter(&path&) : &&;
&&&&String currentPath = rootPath +
&&&&String currentUrl = rootUrl +
&&&&String currentDirPath =
&&&&String moveupDirPath = &&;
&&&&if (!&&.equals(path)) {
&&&&&&String str = currentDirPath.substring(0,
&&&&&&&&&&currentDirPath.length() - 1);
&&&&&&moveupDirPath = str.lastIndexOf(&/&) &= 0 ? str.substring(0, str
&&&&&&&&&&.lastIndexOf(&/&) + 1) : &&;
&&&&}
&&&&// 排序形式,name or size or type
&&&&String order = request.getParameter(&order&) != null ? request
&&&&&&&&.getParameter(&order&).toLowerCase() : &name&;
&&&&// 不允许使用..移动到上一级目录
&&&&if (path.indexOf(&..&) &= 0) {
&&&&&&out.println(&Access is not allowed.&);
&&&&&&
&&&&}
&&&&// 最后一个字符不是/
&&&&if (!&&.equals(path) && !path.endsWith(&/&)) {
&&&&&&out.println(&Parameter is not valid.&);
&&&&&&
&&&&}
&&&&// 目录不存在或不是目录
&&&&File currentPathFile = new File(currentPath);
&&&&if (!currentPathFile.isDirectory()) {
&&&&&&out.println(&Directory does not exist.&);
&&&&&&
&&&&}
&&&&// 遍历目录取的文件信息
&&&&List&Hashtable& fileList = new ArrayList&Hashtable&();
&&&&if (currentPathFile.listFiles() != null) {
&&&&&&for (File file : currentPathFile.listFiles()) {
&&&&&&&&Hashtable&String, Object& hash = new Hashtable&String, Object&();
&&&&&&&&String fileName = file.getName();
&&&&&&&&if (file.isDirectory()) {
&&&&&&&&&&hash.put(&is_dir&, true);
&&&&&&&&&&hash.put(&has_file&, (file.listFiles() != null));
&&&&&&&&&&hash.put(&filesize&, 0L);
&&&&&&&&&&hash.put(&is_photo&, false);
&&&&&&&&&&hash.put(&filetype&, &&);
&&&&&&&&} else if (file.isFile()) {
&&&&&&&&&&String fileExt = fileName.substring(
&&&&&&&&&&&&&&fileName.lastIndexOf(&.&) + 1).toLowerCase();
&&&&&&&&&&hash.put(&is_dir&, false);
&&&&&&&&&&hash.put(&has_file&, false);
&&&&&&&&&&hash.put(&filesize&, file.length());
&&&&&&&&&&hash.put(&is_photo&, Arrays.&String& asList(fileTypes)
&&&&&&&&&&&&&&.contains(fileExt));
&&&&&&&&&&hash.put(&filetype&, fileExt);
&&&&&&&&}
&&&&&&&&hash.put(&filename&, fileName);
&&&&&&&&hash.put(&datetime&,
&&&&&&&&&&&&new SimpleDateFormat(&yyyy-MM-dd HH:mm:ss&).format(file
&&&&&&&&&&&&&&&&.lastModified()));
&&&&&&&&fileList.add(hash);
&&&&&&}
&&&&}
&&&&if (&size&.equals(order)) {
&&&&&&Collections.sort(fileList, new SizeComparator());
&&&&} else if (&type&.equals(order)) {
&&&&&&Collections.sort(fileList, new TypeComparator());
&&&&} else {
&&&&&&Collections.sort(fileList, new NameComparator());
&&&&}
&&&&JSONObject result = new JSONObject();
&&&&result.put(&moveup_dir_path&, moveupDirPath);
&&&&result.put(&current_dir_path&, currentDirPath);
&&&&result.put(&current_url&, currentUrl);
&&&&result.put(&total_count&, fileList.size());
&&&&result.put(&file_list&, fileList);
&&&&response.setContentType(&application/ charset=UTF-8&);
&&&&out.println(result.toJSONString());
&&public class NameComparator implements Comparator {
&&&&public int compare(Object a, Object b) {
&&&&&&Hashtable hashA = (Hashtable)
&&&&&&Hashtable hashB = (Hashtable)
&&&&&&if (((Boolean) hashA.get(&is_dir&))
&&&&&&&&&&&& !((Boolean) hashB.get(&is_dir&))) {
&&&&&&&&return -1;
&&&&&&} else if (!((Boolean) hashA.get(&is_dir&))
&&&&&&&&&&&& ((Boolean) hashB.get(&is_dir&))) {
&&&&&&&&return 1;
&&&&&&} else {
&&&&&&&&return ((String) hashA.get(&filename&))
&&&&&&&&&&&&.compareTo((String) hashB.get(&filename&));
&&&&&&}
&&&&}
&&}
&&public class SizeComparator implements Comparator {
&&&&public int compare(Object a, Object b) {
&&&&&&Hashtable hashA = (Hashtable)
&&&&&&Hashtable hashB = (Hashtable)
&&&&&&if (((Boolean) hashA.get(&is_dir&))
&&&&&&&&&&&& !((Boolean) hashB.get(&is_dir&))) {
&&&&&&&&return -1;
&&&&&&} else if (!((Boolean) hashA.get(&is_dir&))
&&&&&&&&&&&& ((Boolean) hashB.get(&is_dir&))) {
&&&&&&&&return 1;
&&&&&&} else {
&&&&&&&&if (((Long) hashA.get(&filesize&)) & ((Long) hashB
&&&&&&&&&&&&.get(&filesize&))) {
&&&&&&&&&&return 1;
&&&&&&&&} else if (((Long) hashA.get(&filesize&)) & ((Long) hashB
&&&&&&&&&&&&.get(&filesize&))) {
&&&&&&&&&&return -1;
&&&&&&&&} else {
&&&&&&&&&&return 0;
&&&&&&&&}
&&&&&&}
&&&&}
&&}
&&public class TypeComparator implements Comparator {
&&&&public int compare(Object a, Object b) {
&&&&&&Hashtable hashA = (Hashtable)
&&&&&&Hashtable hashB = (Hashtable)
&&&&&&if (((Boolean) hashA.get(&is_dir&))
&&&&&&&&&&&& !((Boolean) hashB.get(&is_dir&))) {
&&&&&&&&return -1;
&&&&&&} else if (!((Boolean) hashA.get(&is_dir&))
&&&&&&&&&&&& ((Boolean) hashB.get(&is_dir&))) {
&&&&&&&&return 1;
&&&&&&} else {
&&&&&&&&return ((String) hashA.get(&filetype&))
&&&&&&&&&&&&.compareTo((String) hashB.get(&filetype&));
&&&&&&}
&&&&}
&&}
}
数据库直接采用的是DZ,所以提供了几个普遍的加密:
package net.ltan.bbs.
import java.util.HashM
import java.util.M
import net.ltan.bbs.util.StringU
import mons.codec.digest.DigestU
* 加密业务
* @author selina
*/
public class Encryption {
&&
&&/**
&& * 实现Discuz用户加密算法
&& * @author Administrator
&& *
&& */
&&public static Map&String,String& Encryptions(String context)
&&{
&&&&String salt=StringUtil.randomString(6);
&&&&String password=DigestUtils.md5Hex(DigestUtils.md5Hex(context)+salt).toString();
&&&&Map&String,String& encryption=new HashMap&String, String&();
&&&&encryption.put(&salt&,salt);
&&&&encryption.put(&password&,password);
&&&&
&&}
&&
&&public static Map&String,String& Encryptions(String context,String salt)
&&{
&&&&String password=DigestUtils.md5Hex(DigestUtils.md5Hex(context)+salt).toString();
&&&&Map&String,String& encryption=new HashMap&String, String&();
&&&&encryption.put(&salt&,salt);
&&&&encryption.put(&password&,password);
&&&&
&&}
&&
&&/**
&& * 管理员密码加密
&& * @param context
&& * @return
&& */
&&public static String AdminPassWordEncryptions(String context)
&&{
&&&&StringBuffer sb=new StringBuffer();
&&&&String md5=DigestUtils.md5Hex(context+&ltan&);
&&&&return sb.append(md5).reverse().delete(3,6).delete(13,19).delete(2,9).toString();
&&}
}
异常处理就丢log就行了,界面最好不要出现报错。
log4j.appender.a_manage.File=${catalina.home}/logs/lt_manage.log
log4j.appender.a_forum.File=${catalina.home}/logs/lt_forum.log
log4j.appender.a_spr.File=${catalina.home}/logs/spring.log
log4j.appender.a_lt.File=${catalina.home}/logs/lt.log
XSS危险确实非常大,用户认证session+IP。
添加新回复
后才能参与评论.现在的防伪都有些什么技术?
防伪标签都具有一定的防伪造、防揭除、安全管理等功能。 但是现在的防伪都有哪些技术呢?
09-09-18 & 发布
在新版驾驶证上,“证号”两个字采用的是光变油墨,正面看是紫色的,侧面看是黑色的,这是一个重点防伪技术。新驾驶证和旧驾驶证的底纹有明显的区别,新新版驾驶证采用防伪底纹。另外,新版驾驶证使用专门的防伪纸张,右下角有一维条码,通过条码识别仪器可以检查核发时间、核发人等信息。    驾驶证上有一条虚线,是增加的开窗金属线,属于新的防伪技术。    新版驾驶证外面有一个塑封膜叫护卡膜,膜上面是一个“平安结”图案,象征吉祥,这是新版驾驶证人性化管理的特点。在荧光灯下还可以看到新版驾驶证有荧光的长城防伪图案。
   新版驾驶证正副证中间采用无缝印刷,正副证是一个整体的图案。在荧光灯照射下,右边的小图片会呈现红黄蓝三色的荧光丝。
请登录后再发表评论!
防伪技术介绍 物理学防伪技术是应用物理学中机械、光、热、电、磁、声以及计算机辅助识别系统建立的防伪技术,如特种印刷图文、水印、激光全息图像、光学可变薄膜、超能防伪标识、磁性密码等。化学防伪技术是在防伪标识中加入一定条件下可引起化学反应的物质,如光致变色、热致变色、压致变色防伪技术和电化学防伪技术以及各种无机荧光化合物的合成、利用等。生物学防伪技术是利用生物本身固有的特异性标志作为防伪的措施,如人的指纹、动植物的DNA遗传密码、人眼视网膜血管图等。 多学科防伪技术是物理学与化学方法的综合利用,或二者与生物学方法的综合利用。如电化学、光化学的应甩;把荧光、光致变色、光磁、光声等多种化学材料嫁接在动植物DNA上,作为示踪显示物,便于简化识别方法。另外,还有近几年兴起的信息网络编码防伪技术。版纹防伪设计技术与印刷技术结合版纹防伪设计技术系统是一套专业的完全运用线条进行防伪设计的软件系统,其特点是运用线条进行防伪,能产生丰富的线条及图案变化,防伪设计在制版中完成、在印刷中实现,不增加额外的制作成本,防伪性能高。版纹防伪的原理是:通过软件无法复制这种线条效果,通过防止扫描,达到防伪目的。版纹防伪设计技术系统作为一种高精密度的防伪手段,以其多变性、灵活性开辟了广阔的创意空间,适用范围极为广泛,主要用于证件类防伪,包括有价证券防伪、票据防伪、证卡、护照、身份证等,如纸币上那些有线条组成的全部元素就是版纹。版纹的主要功能是安全防伪,但并不局限于钱币,随着社会的发展,票据、有价证券、证件等的印刷也运用了版纹,而且开始走向了更加广阔的包装市场。如烟酒包装防伪、化妆品包装、药品包装、食品包装、饮料包装等。目前世界上形成商品化的专业版纹设计软件很少,知名的不超过五家,国内共引进了l0余套防伪设计软件,分布在公安部和各印钞厂及设计中心。国内具有设计和生产这类软件的公司有北大方正和武汉的蒙泰科技发展公司,用户有印钞厂,包装印刷厂,防伪印刷厂,商标、票据设计公司等。一些有先见之明的企业已率先将先进的钞票防伪技术包括版纹设计应用于名优产品的包装和商标中,如太阳神口服液封签,手机入网许可证,蒙特娇服装标牌等。
请登录后再发表评论!

我要回帖

更多关于 都有什么技术 的文章

 

随机推荐