Annotation Interface EncryptResult
Marks a method or class whose Result responses
should be automatically encrypted. Framework interceptors (e.g., Spring AOP, Jakarta Interceptor)
should check this annotation and delegate to ResultEncryptionHandler.
标记方法或类,其 Result 响应将被自动加密。
框架拦截器(如 Spring AOP、Jakarta 拦截器)应检查此注解并委托给 ResultEncryptionHandler 处理。
Usage Examples | 使用示例:
// Encrypt a single method's response
@EncryptResult
public Result<User> getUser(Long id) { ... }
// Encrypt with specific key alias
@EncryptResult(keyAlias = "partner-api-key")
public Result<Order> getOrder(Long id) { ... }
// Encrypt all methods in a class
@EncryptResult
public class SecureController { ... }
// Skip encryption on a specific method in an encrypted class
@EncryptResult(enabled = false)
public Result<Config> getPublicConfig() { ... }
Security | 安全性:
- Thread-safe: Yes (annotation, immutable) - 线程安全: 是(注解,不可变)
- Since:
- JDK 25, opencode-base-web V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Optional Element Summary
Optional Elements
-
Element Details
-
keyAlias
String keyAliasKey alias for encryption key resolution. 加密密钥别名,用于密钥解析。The alias is passed to
EncryptionKeyResolverto obtain the actual encryption key. Empty string means use the default key.别名传递给
EncryptionKeyResolver以获取实际加密密钥。 空字符串表示使用默认密钥。- Returns:
- the key alias | 密钥别名
- Default:
""
-
algorithm
String algorithmEncryption algorithm name. 加密算法名称。Must match a registered
ResultEncryptor.getAlgorithm(). Empty string means use the default algorithm (AES-GCM).必须匹配已注册的
ResultEncryptor.getAlgorithm()。 空字符串表示使用默认算法(AES-GCM)。- Returns:
- the algorithm name | 算法名称
- Default:
""
-
enabled
boolean enabledWhether encryption is enabled. 是否启用加密。Set to
falseto disable encryption on a method when the class is annotated with@EncryptResult.当类上标注了
@EncryptResult时,设置为false可以在特定方法上禁用加密。- Returns:
- true if encryption is enabled | 如果启用加密则返回true
- Default:
true
-