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