<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      lelonta

      導航

      patchca驗證碼的使用

      /**
      * 生成驗證碼
      */
      private static RandomFontFactory ff = null;
      // 自定義驗證碼圖片背景
      private static MyCustomBackgroundFactory backgroundFactory = new MyCustomBackgroundFactory();
      private static ConfigurableCaptchaService cs = new ConfigurableCaptchaService();
      private static Random random = new Random();
      static {
      cs.setColorFactory(new ColorFactory() {
      public Color getColor(int x) {
      int[] c = new int[3];
      int i = random.nextInt(c.length);
      for (int fi = 0; fi < c.length; fi++) {
      if (fi == i) {
      c[fi] = random.nextInt(71);// 71
      } else {
      c[fi] = random.nextInt(256);// 256
      }
      }
      return new Color(c[0], c[1], c[2]);
      }
      });
      ff = new RandomFontFactory();
      RandomWordFactory wf = new RandomWordFactory();
      wf.setCharacters("abcdefghigkmnpqrstuvwxyzABCDEFGHIGKLMNPQRSTUVWXYZ1234567890");
      wf.setMaxLength(5);
      wf.setMinLength(4);
      // 該代碼經過測試 在后臺修改字體大小不能自適應,只能在前臺頁面修改驗證碼高度和寬度
      //設置驗證碼的背景顏色
      cs.setBackgroundFactory(backgroundFactory);
      cs.setWordFactory(wf);
      cs.setFontFactory(ff);
      }

      protected void setResponseHeaders(HttpServletResponse response) {
      response.setContentType("image/png");
      response.setHeader("Cache-Control", "no-cache, no-store");
      response.setHeader("Pragma", "no-cache");
      long time = System.currentTimeMillis();
      response.setDateHeader("Last-Modified", time);
      response.setDateHeader("Date", time);
      response.setDateHeader("Expires", time);
      }

      /**
      *
      * 自定義驗證碼圖片背景,主要畫一些噪點和干擾線
      */
      private static class MyCustomBackgroundFactory implements BackgroundFactory {
      private Random random = new Random();

      public void fillBackground(BufferedImage image) {
      Graphics graphics = image.getGraphics();
      // 驗證碼圖片的寬高
      int imgWidth = image.getWidth();
      int imgHeight = image.getHeight();
      // 填充為白色背景
      graphics.setColor(Color.lightGray);
      graphics.fillRect(0, 0, imgWidth, imgHeight);
      // 畫100個噪點(顏色及位置隨機)
      for (int i = 0; i < 100; i++) {
      // 隨機顏色
      int rInt = random.nextInt(255);
      int gInt = random.nextInt(255);
      int bInt = random.nextInt(255);
      graphics.setColor(new Color(rInt, gInt, bInt));
      // 隨機位置
      int xInt = random.nextInt(imgWidth - 3);

      int yInt = random.nextInt(imgHeight - 2);
      // 隨機旋轉角度
      int sAngleInt = random.nextInt(360);
      int eAngleInt = random.nextInt(360);
      // 隨機大小
      int wInt = random.nextInt(6);
      int hInt = random.nextInt(6);
      graphics.fillArc(xInt, yInt, wInt, hInt, sAngleInt, eAngleInt);
      // 畫5條干擾線
      if (i % 20 == 0) {
      int xInt2 = random.nextInt(imgWidth);
      int yInt2 = random.nextInt(imgHeight);
      graphics.drawLine(xInt, yInt, xInt2, yInt2);
      }
      }
      }
      }

      @RequestMapping("/safecode.do")
      public void safecode(HttpServletRequest request,
      HttpServletResponse response) throws IOException {
      switch (random.nextInt(5)) {
      case 0:
      cs.setFilterFactory(new CurvesRippleFilterFactory(cs
      .getColorFactory()));
      break;
      case 1:
      cs.setFilterFactory(new MarbleRippleFilterFactory());
      break;
      case 2:
      cs.setFilterFactory(new DoubleRippleFilterFactory());
      break;
      case 3:
      cs.setFilterFactory(new WobbleRippleFilterFactory());
      break;
      case 4:
      cs.setFilterFactory(new DiffuseRippleFilterFactory());
      break;
      }
      HttpSession session = request.getSession(false);
      if (session == null) {
      session = request.getSession();
      }
      setResponseHeaders(response);
      String randomCode = EncoderHelper.getChallangeAndWriteImage(cs, "png",
      response.getOutputStream());
      session.setAttribute("randomCode", randomCode);
      }

      posted on 2016-03-09 17:40  lelonta  閱讀(408)  評論(0)    收藏  舉報

      主站蜘蛛池模板: 亚洲精品久久久久国产| 日本丶国产丶欧美色综合| 国产精品天天在线午夜更新| 韩日午夜在线资源一区二区| 国产成人精品亚洲精品密奴| 午夜av高清在线观看| av无码精品一区二区三区四区 | 亚洲综合精品第一页| 久久精品av国产一区二区 | 国产成人无码av一区二区| 精品在免费线中文字幕久久| 亚洲性日韩精品一区二区| 欧美成人精品手机在线| 五月丁香激激情亚洲综合| 免费久久人人爽人人爽AV| 强开少妇嫩苞又嫩又紧九色| 久久精品天天中文字幕人妻| 摸丰满大乳奶水www免费| 亚洲一区二区三区丝袜| 99热门精品一区二区三区无码 | 欧洲性开放老太大| 修武县| 亚洲av高清一区二区三| 收藏| 日本夜爽爽一区二区三区| 日本无人区一区二区三区| free性开放小少妇| 国产亚洲av手机在线观看| 91精品国产一二三产区| a毛片免费在线观看| 午夜国产精品福利一二| 国产天美传媒性色av高清| 狠狠精品久久久无码中文字幕| 在线观看中文字幕码国产| 婷婷综合亚洲| 免费观看全黄做爰大片| 台南县| 二区中文字幕在线观看| 又大又紧又粉嫩18p少妇| 97中文字幕在线观看| 亚洲精品揄拍自拍首页一|