Search in sources :

Example 1 with Capts

use of io.github.ihongs.util.sketch.Capts in project HongsCORE by ihongs.

the class CaptAction method create.

@Action("create")
public void create(ActionHelper helper) throws HongsException, IOException {
    int h = Synt.declare(helper.getParameter("h"), 40);
    String b = Synt.declare(helper.getParameter("b"), "");
    String f = Synt.declare(helper.getParameter("f"), "");
    String e = Synt.declare(helper.getParameter("e"), "png");
    Capts vc = Capts.captcha(h, b, f);
    // 设置会话
    String ss = CoreConfig.getInstance().getProperty("core.capt.session", "capt");
    helper.setSessibute(ss + "_code", /**/
    vc.getCode());
    helper.setSessibute(ss + "_time", System.currentTimeMillis());
    // 禁止缓存
    helper.getResponse().setContentType("image/" + e);
    helper.getResponse().setDateHeader("Expires", 0);
    helper.getResponse().setHeader("Pragma", "no-cache");
    helper.getResponse().setHeader("Cache-Control", "no-cache");
    vc.write(e, helper.getResponse().getOutputStream());
}
Also used : Capts(io.github.ihongs.util.sketch.Capts) Action(io.github.ihongs.action.anno.Action)

Aggregations

Action (io.github.ihongs.action.anno.Action)1 Capts (io.github.ihongs.util.sketch.Capts)1