package cn.security.license.util;

import org.springframework.web.servlet.HandlerInterceptor;
import cn.security.license.core.verify.LicenseVerifyManager;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * LicenseCheckInterceptor
 * 在业务处理器处理请求之前被调用。预处理，可以进行编码、安全控制等处理； 
 */
public class LicenseCheckInterceptor implements HandlerInterceptor
{
	
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) 
    {
    	LicenseVerifyManager licenseVerify = new LicenseVerifyManager();
        //校验证书是否有效
        boolean verifyResult = licenseVerify.verify();

        if(verifyResult){
            return true;
        }else{
            //new ViewImpl(response).printToClient(MsgTip.HTML_PAGE_LICENSE);
		    return false;
        }
    }
}
