c3p0工具包(jdbc)

时间:2016-07-02 04:59:58
【文件属性】:

文件名称:c3p0工具包(jdbc)

文件大小:2KB

文件格式:RAR

更新时间:2016-07-02 04:59:58

c3p0 jdbc filter

用jdbc开发项目的工具包,采用数据库连接池c3p0 恶意脚本过滤器,采用‘装饰者设计模式’增强类功能~~,过滤恶意脚本 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cn.secondteam.utils; import java.io.IOException; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * 恶意脚本字符过滤器 * @author Administrator * */ public class CharFilter implements Filter { public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { final HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; chain.doFilter((ServletRequest) Proxy.newProxyInstance(CharFilter.class.getClassLoader(),request.getClass().getInterfaces(), new InvocationHandler(){ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if(method.getName().equals("getParameter")){ return formatHTML((String)method.invoke(request, args)); } return method.invoke(request, args); } }), res); } public void init(FilterConfig filterConfig) throws ServletException { } private String formatHTML(String str) { if(str==null){ return null; } str = str.replaceAll("", ">"); return str; } public void destroy() { // TODO Auto-generated method stub } }


【文件预览】:
CharFilter.java
DbUtil.java

网友评论