mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
修复getFileNameFromDisposition不符合规范问题
This commit is contained in:
commit
9097e717f1
@ -2,12 +2,13 @@
|
|||||||
# 🚀Changelog
|
# 🚀Changelog
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
# 5.8.32(2024-08-12)
|
# 5.8.32(2024-08-13)
|
||||||
|
|
||||||
### 🐣新特性
|
### 🐣新特性
|
||||||
|
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【http 】 修复getFileNameFromDisposition不符合规范问题(issue#IAKBPD@Gitee)
|
* 【http 】 修复getFileNameFromDisposition不符合规范问题(issue#IAKBPD@Gitee)
|
||||||
|
* 【crypto 】 修复SymmetricCrypto.setParams和setRandom没有加锁问题(issue#IAJIY3@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
# 5.8.31(2024-08-12)
|
# 5.8.31(2024-08-12)
|
||||||
|
@ -168,7 +168,12 @@ public class AsymmetricCrypto extends AbstractAsymmetricCrypto<AsymmetricCrypto>
|
|||||||
* @param encryptBlockSize 加密块大小
|
* @param encryptBlockSize 加密块大小
|
||||||
*/
|
*/
|
||||||
public void setEncryptBlockSize(int encryptBlockSize) {
|
public void setEncryptBlockSize(int encryptBlockSize) {
|
||||||
|
lock.lock();
|
||||||
|
try{
|
||||||
this.encryptBlockSize = encryptBlockSize;
|
this.encryptBlockSize = encryptBlockSize;
|
||||||
|
}finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -186,7 +191,12 @@ public class AsymmetricCrypto extends AbstractAsymmetricCrypto<AsymmetricCrypto>
|
|||||||
* @param decryptBlockSize 解密块大小
|
* @param decryptBlockSize 解密块大小
|
||||||
*/
|
*/
|
||||||
public void setDecryptBlockSize(int decryptBlockSize) {
|
public void setDecryptBlockSize(int decryptBlockSize) {
|
||||||
|
lock.lock();
|
||||||
|
try{
|
||||||
this.decryptBlockSize = decryptBlockSize;
|
this.decryptBlockSize = decryptBlockSize;
|
||||||
|
}finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -208,7 +218,12 @@ public class AsymmetricCrypto extends AbstractAsymmetricCrypto<AsymmetricCrypto>
|
|||||||
* @since 5.4.3
|
* @since 5.4.3
|
||||||
*/
|
*/
|
||||||
public void setAlgorithmParameterSpec(AlgorithmParameterSpec algorithmParameterSpec) {
|
public void setAlgorithmParameterSpec(AlgorithmParameterSpec algorithmParameterSpec) {
|
||||||
|
lock.lock();
|
||||||
|
try{
|
||||||
this.cipherWrapper.setParams(algorithmParameterSpec);
|
this.cipherWrapper.setParams(algorithmParameterSpec);
|
||||||
|
}finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -219,14 +234,24 @@ public class AsymmetricCrypto extends AbstractAsymmetricCrypto<AsymmetricCrypto>
|
|||||||
* @since 5.7.17
|
* @since 5.7.17
|
||||||
*/
|
*/
|
||||||
public AsymmetricCrypto setRandom(SecureRandom random) {
|
public AsymmetricCrypto setRandom(SecureRandom random) {
|
||||||
|
lock.lock();
|
||||||
|
try{
|
||||||
this.cipherWrapper.setRandom(random);
|
this.cipherWrapper.setRandom(random);
|
||||||
|
}finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AsymmetricCrypto init(String algorithm, PrivateKey privateKey, PublicKey publicKey) {
|
public AsymmetricCrypto init(String algorithm, PrivateKey privateKey, PublicKey publicKey) {
|
||||||
|
lock.lock();
|
||||||
|
try{
|
||||||
super.init(algorithm, privateKey, publicKey);
|
super.init(algorithm, privateKey, publicKey);
|
||||||
initCipher();
|
initCipher();
|
||||||
|
}finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,10 +31,13 @@ import java.util.Set;
|
|||||||
public class Sign extends BaseAsymmetric<Sign> {
|
public class Sign extends BaseAsymmetric<Sign> {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 签名,用于签名和验证 */
|
/**
|
||||||
|
* 签名,用于签名和验证
|
||||||
|
*/
|
||||||
protected Signature signature;
|
protected Signature signature;
|
||||||
|
|
||||||
// ------------------------------------------------------------------ Constructor start
|
// ------------------------------------------------------------------ Constructor start
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造,创建新的私钥公钥对
|
* 构造,创建新的私钥公钥对
|
||||||
*
|
*
|
||||||
@ -113,8 +116,7 @@ public class Sign extends BaseAsymmetric<Sign> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造
|
* 构造<br>
|
||||||
*
|
|
||||||
* 私钥和公钥同时为空时生成一对新的私钥和公钥<br>
|
* 私钥和公钥同时为空时生成一对新的私钥和公钥<br>
|
||||||
* 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做签名或验证
|
* 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做签名或验证
|
||||||
*
|
*
|
||||||
@ -130,7 +132,8 @@ public class Sign extends BaseAsymmetric<Sign> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造 私钥和公钥同时为空时生成一对新的私钥和公钥<br>
|
* 构造<br>
|
||||||
|
* 私钥和公钥同时为空时生成一对新的私钥和公钥<br>
|
||||||
* 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做签名或验证
|
* 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做签名或验证
|
||||||
*
|
*
|
||||||
* @param algorithm 算法,见{@link SignAlgorithm}
|
* @param algorithm 算法,见{@link SignAlgorithm}
|
||||||
@ -141,8 +144,7 @@ public class Sign extends BaseAsymmetric<Sign> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造
|
* 构造<br>
|
||||||
*
|
|
||||||
* 私钥和公钥同时为空时生成一对新的私钥和公钥<br>
|
* 私钥和公钥同时为空时生成一对新的私钥和公钥<br>
|
||||||
* 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做签名或验证
|
* 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做签名或验证
|
||||||
*
|
*
|
||||||
@ -165,8 +167,13 @@ public class Sign extends BaseAsymmetric<Sign> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Sign init(String algorithm, PrivateKey privateKey, PublicKey publicKey) {
|
public Sign init(String algorithm, PrivateKey privateKey, PublicKey publicKey) {
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
signature = SecureUtil.createSignature(algorithm);
|
signature = SecureUtil.createSignature(algorithm);
|
||||||
super.init(algorithm, privateKey, publicKey);
|
super.init(algorithm, privateKey, publicKey);
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,15 +185,19 @@ public class Sign extends BaseAsymmetric<Sign> {
|
|||||||
* @since 4.6.5
|
* @since 4.6.5
|
||||||
*/
|
*/
|
||||||
public Sign setParameter(AlgorithmParameterSpec params) {
|
public Sign setParameter(AlgorithmParameterSpec params) {
|
||||||
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
this.signature.setParameter(params);
|
this.signature.setParameter(params);
|
||||||
} catch (InvalidAlgorithmParameterException e) {
|
} catch (InvalidAlgorithmParameterException e) {
|
||||||
throw new CryptoException(e);
|
throw new CryptoException(e);
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------- Sign and Verify
|
// --------------------------------------------------------------------------------- Sign and Verify
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成文件签名
|
* 生成文件签名
|
||||||
*
|
*
|
||||||
@ -298,7 +309,7 @@ public class Sign extends BaseAsymmetric<Sign> {
|
|||||||
* @return 签名bytes
|
* @return 签名bytes
|
||||||
* @since 5.7.0
|
* @since 5.7.0
|
||||||
*/
|
*/
|
||||||
public byte[] sign(InputStream data, int bufferLength){
|
public byte[] sign(InputStream data, int bufferLength) {
|
||||||
if (bufferLength < 1) {
|
if (bufferLength < 1) {
|
||||||
bufferLength = IoUtil.DEFAULT_BUFFER_SIZE;
|
bufferLength = IoUtil.DEFAULT_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
|
@ -170,14 +170,13 @@ public class SymmetricCrypto implements SymmetricEncryptor, SymmetricDecryptor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置 {@link AlgorithmParameterSpec},通常用于加盐或偏移向量
|
* 设置偏移向量
|
||||||
*
|
*
|
||||||
* @param params {@link AlgorithmParameterSpec}
|
* @param iv 偏移向量,加盐
|
||||||
* @return 自身
|
* @return 自身
|
||||||
*/
|
*/
|
||||||
public SymmetricCrypto setParams(AlgorithmParameterSpec params) {
|
public SymmetricCrypto setIv(byte[] iv) {
|
||||||
this.cipherWrapper.setParams(params);
|
return setIv(new IvParameterSpec(iv));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -191,13 +190,19 @@ public class SymmetricCrypto implements SymmetricEncryptor, SymmetricDecryptor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置偏移向量
|
* 设置 {@link AlgorithmParameterSpec},通常用于加盐或偏移向量
|
||||||
*
|
*
|
||||||
* @param iv 偏移向量,加盐
|
* @param params {@link AlgorithmParameterSpec}
|
||||||
* @return 自身
|
* @return 自身
|
||||||
*/
|
*/
|
||||||
public SymmetricCrypto setIv(byte[] iv) {
|
public SymmetricCrypto setParams(AlgorithmParameterSpec params) {
|
||||||
return setIv(new IvParameterSpec(iv));
|
lock.lock();
|
||||||
|
try {
|
||||||
|
this.cipherWrapper.setParams(params);
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -207,8 +212,13 @@ public class SymmetricCrypto implements SymmetricEncryptor, SymmetricDecryptor,
|
|||||||
* @return this
|
* @return this
|
||||||
* @since 5.7.17
|
* @since 5.7.17
|
||||||
*/
|
*/
|
||||||
public SymmetricCrypto setRandom(SecureRandom random){
|
public SymmetricCrypto setRandom(SecureRandom random) {
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
this.cipherWrapper.setRandom(random);
|
this.cipherWrapper.setRandom(random);
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +231,7 @@ public class SymmetricCrypto implements SymmetricEncryptor, SymmetricDecryptor,
|
|||||||
* @return this
|
* @return this
|
||||||
* @since 5.7.12
|
* @since 5.7.12
|
||||||
*/
|
*/
|
||||||
public SymmetricCrypto setMode(CipherMode mode){
|
public SymmetricCrypto setMode(CipherMode mode) {
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
initMode(mode.getValue());
|
initMode(mode.getValue());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user