Class AbstractResultEncryptor
java.lang.Object
cloud.opencode.base.web.crypto.AbstractResultEncryptor
- All Implemented Interfaces:
ResultEncryptor
- Direct Known Subclasses:
AesResultEncryptor
Abstract Result Encryptor
抽象响应加密器
Base class for result encryptors providing common functionality.
响应加密器基类,提供通用功能。
Features | 主要功能:
- Base class for result encryptors - 响应加密器基类
- JSON serialization/deserialization - JSON序列化/反序列化
- Base64 encoding of encrypted data - 加密数据的Base64编码
Usage Examples | 使用示例:
public class MyEncryptor extends AbstractResultEncryptor {
protected byte[] doEncrypt(byte[] data) { ... }
protected byte[] doDecrypt(byte[] data) { ... }
public String getAlgorithm() { return "MY-ALG"; }
}
Security | 安全性:
- Thread-safe: Implementation-dependent - 取决于实现
- Null-safe: No (result must not be null) - 否(结果不能为null)
- Since:
- JDK 25, opencode-base-web V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> Result<T> decrypt(EncryptedResult encrypted, Class<T> dataType) Decrypt to result 解密为响应protected <T> TdeserializeData(String json, Class<T> dataType) Deserialize JSON string to data 将JSON字符串反序列化为数据protected abstract byte[]doDecrypt(byte[] data) Perform decryption 执行解密protected abstract byte[]doEncrypt(byte[] data) Perform encryption 执行加密<T> EncryptedResultEncrypt result 加密响应protected StringserializeData(Object data) Serialize data to JSON string 将数据序列化为JSON字符串Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ResultEncryptor
getAlgorithm, supports
-
Constructor Details
-
AbstractResultEncryptor
public AbstractResultEncryptor()
-
-
Method Details
-
encrypt
Description copied from interface:ResultEncryptorEncrypt result 加密响应- Specified by:
encryptin interfaceResultEncryptor- Type Parameters:
T- the data type | 数据类型- Parameters:
result- the result to encrypt | 要加密的响应- Returns:
- the encrypted result | 加密后的响应
-
decrypt
Description copied from interface:ResultEncryptorDecrypt to result 解密为响应- Specified by:
decryptin interfaceResultEncryptor- Type Parameters:
T- the data type | 数据类型- Parameters:
encrypted- the encrypted result | 加密的响应dataType- the data type class | 数据类型类- Returns:
- the decrypted result | 解密后的响应
-
doEncrypt
-
doDecrypt
-
serializeData
-
deserializeData
Deserialize JSON string to data 将JSON字符串反序列化为数据Override this method to use custom deserialization.
重写此方法以使用自定义反序列化。
- Type Parameters:
T- the data type | 数据类型- Parameters:
json- the JSON string | JSON字符串dataType- the data type | 数据类型- Returns:
- the deserialized data | 反序列化的数据
-