Browse Source

去掉sun.misc.BASE64Encoder,使用cn.hutool.core.codec.Base64代替

master
lzh 3 years ago
parent
commit
3fc27a74e8
  1. 7
      yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/ImageUtils.java
  2. 5
      yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/factory/impl/AbstractCaptcha.java
  3. 7
      yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/factory/impl/BlockPuzzleCaptcha.java
  4. 5
      yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/component/DocPdfComponent.java
  5. 5
      yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/utils/WordUtils.java

7
yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/ImageUtils.java

@ -1,9 +1,8 @@
package com.yxt.common.base.config.captcha;
import cn.hutool.core.codec.Base64;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import sun.misc.BASE64Decoder;
import java.io.*;
@ -89,12 +88,12 @@ public class ImageUtils {
return false;
}
BASE64Decoder decoder = new BASE64Decoder();
// BASE64Decoder decoder = new BASE64Decoder();
OutputStream out = null;
try {
out = new FileOutputStream(imgFilePath);
// Base64解码
byte[] b = decoder.decodeBuffer(imgData);
byte[] b = Base64.decode(imgData);
for (int i = 0; i < b.length; ++i) {
// 调整异常数据
if (b[i] < 0) {

5
yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/factory/impl/AbstractCaptcha.java

@ -1,10 +1,10 @@
package com.yxt.common.base.config.captcha.factory.impl;
import cn.hutool.core.codec.Base64;
import com.yxt.common.base.config.captcha.CaptchaBaseParam;
import com.yxt.common.base.config.captcha.CaptchaException;
import com.yxt.common.core.vo.CaptchaBaseVO;
import org.apache.commons.lang3.StringUtils;
import sun.misc.BASE64Encoder;
import javax.imageio.ImageIO;
import java.awt.*;
@ -75,8 +75,7 @@ public abstract class AbstractCaptcha {
throw new CaptchaException("ImageIO.write is error", e);
}
byte[] bytes = baos.toByteArray();
BASE64Encoder encoder = new sun.misc.BASE64Encoder();
return encoder.encodeBuffer(bytes).trim();
return Base64.encode(bytes).trim();
}
public String getJigsawUrlOrPath() {

7
yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/factory/impl/BlockPuzzleCaptcha.java

@ -1,12 +1,12 @@
package com.yxt.common.base.config.captcha.factory.impl;
import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson.JSON;
import com.yxt.common.base.config.captcha.CaptchaBaseParam;
import com.yxt.common.base.config.captcha.CaptchaException;
import com.yxt.common.core.vo.BlockPuzzleCaptchaVO;
import com.yxt.common.core.vo.CaptchaBaseVO;
import org.apache.commons.lang3.StringUtils;
import sun.misc.BASE64Encoder;
import javax.imageio.ImageIO;
import java.awt.*;
@ -87,10 +87,9 @@ public class BlockPuzzleCaptcha extends AbstractCaptcha {
// 源图生成遮罩
byte[] oriCopyImages = DealOriPictureByTemplate(originalImage, jigsawImage, x, 0);
BASE64Encoder encoder = new sun.misc.BASE64Encoder();
dataVO.setOriginalImageBase64(encoder.encode(oriCopyImages));
dataVO.setOriginalImageBase64(Base64.encode(oriCopyImages));
dataVO.setPoint(point);
dataVO.setJigsawImageBase64(encoder.encode(jigsawImages));
dataVO.setJigsawImageBase64(Base64.encode(jigsawImages));
return dataVO;
} catch (Exception e){
throw new CaptchaException(e);

5
yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/component/DocPdfComponent.java

@ -1,5 +1,6 @@
package com.yxt.common.base.config.component;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DateUtil;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
@ -11,7 +12,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import sun.misc.BASE64Encoder;
import java.io.*;
import java.util.Date;
@ -94,8 +94,7 @@ public class DocPdfComponent {
} catch (Exception e) {
e.printStackTrace();
}
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data);
return Base64.encode(data);
}
/**

5
yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/utils/WordUtils.java

@ -1,12 +1,12 @@
package com.yxt.common.base.utils;
import cn.hutool.core.codec.Base64;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.ComThread;
import com.jacob.com.Dispatch;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.Version;
import sun.misc.BASE64Encoder;
import java.io.*;
import java.util.*;
@ -73,8 +73,7 @@ public class WordUtils {
} catch (Exception e) {
e.printStackTrace();
}
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data);
return Base64.encode(data);
}
/**

Loading…
Cancel
Save