Class SecureFeatureManager
java.lang.Object
cloud.opencode.base.feature.security.SecureFeatureManager
Secure Feature Manager
安全功能管理器
Feature manager with permission control and audit logging.
带有权限控制和审计日志的功能管理器。
Features | 主要功能:
- Permission control - 权限控制
- Admin whitelist - 管理员白名单
- Audit logging - 审计日志
Usage Examples | 使用示例:
SecureFeatureManager manager = new SecureFeatureManager(
Set.of("admin1", "admin2"),
new FileAuditLogger(logPath)
);
manager.enable("new-feature", "admin1"); // OK
manager.enable("new-feature", "user1"); // throws FeatureSecurityException
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Null-safe: Partial (validates inputs) - 空值安全: 部分(验证输入)
- Since:
- JDK 25, opencode-base-feature V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSecureFeatureManager(OpenFeature features, Set<String> adminUsers, AuditLogger auditLogger) Create with custom OpenFeature instance 使用自定义OpenFeature实例创建SecureFeatureManager(Set<String> adminUsers, AuditLogger auditLogger) Create secure feature manager 创建安全功能管理器 -
Method Summary
Modifier and TypeMethodDescriptionvoidDisable a feature (requires admin) 禁用功能(需要管理员)voidEnable a feature (requires admin) 启用功能(需要管理员)Get a feature (no permission required) 获取功能(无需权限)booleanCheck if operator is admin 检查操作者是否为管理员booleanCheck if feature is enabled (no permission required) 检查功能是否启用(无需权限)booleanisEnabled(String featureKey, FeatureContext context) Check if feature is enabled for context (no permission required) 检查功能对上下文是否启用(无需权限)voidRegister a feature (requires admin) 注册功能(需要管理员)voidupdateStrategy(String featureKey, EnableStrategy strategy, String operatorId) Update feature strategy (requires admin) 更新功能策略(需要管理员)
-
Constructor Details
-
SecureFeatureManager
Create secure feature manager 创建安全功能管理器- Parameters:
adminUsers- the set of admin user IDs | 管理员用户ID集合auditLogger- the audit logger | 审计日志记录器
-
SecureFeatureManager
Create with custom OpenFeature instance 使用自定义OpenFeature实例创建- Parameters:
features- the OpenFeature instance | OpenFeature实例adminUsers- the set of admin user IDs | 管理员用户ID集合auditLogger- the audit logger | 审计日志记录器
-
-
Method Details
-
register
Register a feature (requires admin) 注册功能(需要管理员)- Parameters:
feature- the feature to register | 要注册的功能operatorId- the operator ID | 操作者ID- Throws:
FeatureSecurityException- if not authorized | 如果未授权
-
enable
Enable a feature (requires admin) 启用功能(需要管理员)- Parameters:
featureKey- the feature key | 功能键operatorId- the operator ID | 操作者ID- Throws:
FeatureSecurityException- if not authorized | 如果未授权
-
disable
Disable a feature (requires admin) 禁用功能(需要管理员)- Parameters:
featureKey- the feature key | 功能键operatorId- the operator ID | 操作者ID- Throws:
FeatureSecurityException- if not authorized | 如果未授权
-
updateStrategy
Update feature strategy (requires admin) 更新功能策略(需要管理员)- Parameters:
featureKey- the feature key | 功能键strategy- the new strategy | 新策略operatorId- the operator ID | 操作者ID- Throws:
FeatureSecurityException- if not authorized | 如果未授权
-
isEnabled
Check if feature is enabled (no permission required) 检查功能是否启用(无需权限)- Parameters:
featureKey- the feature key | 功能键- Returns:
- true if enabled | 如果启用返回true
-
isEnabled
Check if feature is enabled for context (no permission required) 检查功能对上下文是否启用(无需权限)- Parameters:
featureKey- the feature key | 功能键context- the context | 上下文- Returns:
- true if enabled | 如果启用返回true
-
get
-
isAdmin
Check if operator is admin 检查操作者是否为管理员- Parameters:
operatorId- the operator ID | 操作者ID- Returns:
- true if admin | 如果是管理员返回true
-