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

This commit is contained in:
lzh
2022-09-21 16:30:58 +08:00
parent 22d3aca3ca
commit 3fc27a74e8
5 changed files with 12 additions and 17 deletions

View File

@@ -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) {

View File

@@ -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() {

View File

@@ -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);

View File

@@ -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);
}
/**

View File

@@ -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);
}
/**