Class YmlSecurityException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.yml.exception.OpenYmlException
cloud.opencode.base.yml.exception.YmlSecurityException
- All Implemented Interfaces:
OpenExceptionMeta, Serializable
YAML Security Exception - Thrown when security violation is detected
YAML 安全异常 - 当检测到安全违规时抛出
This exception is thrown when YAML content violates security constraints.
当 YAML 内容违反安全约束时抛出此异常。
Features | 主要功能:
- Categorized violation types (alias, depth, size, type, recursion) - 分类违规类型(别名、深度、大小、类型、递归)
- Factory methods for common security violations - 常见安全违规的工厂方法
- Error code YML_SECURITY_001 - 错误码 YML_SECURITY_001
Usage Examples | 使用示例:
try {
YmlSecurity.validate(yamlContent);
} catch (YmlSecurityException e) {
System.err.println("Violation: " + e.getType());
}
Security | 安全性:
- Thread-safe: Yes (immutable after construction) - 线程安全: 是(构建后不可变)
- Null-safe: No (type must not be null) - 空值安全: 否(类型不能为空)
- Since:
- JDK 25, opencode-base-yml V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSecurity Violation Type - Types of security violations 安全违规类型 - 安全违规的类型 -
Constructor Summary
ConstructorsConstructorDescriptionYmlSecurityException(YmlSecurityException.SecurityViolationType type, String message) Constructs a security exception with type and message.YmlSecurityException(YmlSecurityException.SecurityViolationType type, String message, Throwable cause) Constructs a security exception with type, message and cause. -
Method Summary
Modifier and TypeMethodDescriptionstatic YmlSecurityExceptionaliasLimitExceeded(int count, int limit) Creates an exception for alias limit exceeded.static YmlSecurityExceptiondocumentSizeExceeded(long size, long limit) Creates an exception for document size exceeded.static YmlSecurityExceptionforbiddenType(String typeName) Creates an exception for forbidden type.getType()Gets the security violation type.static YmlSecurityExceptionnestingDepthExceeded(int depth, int limit) Creates an exception for nesting depth exceeded.static YmlSecurityExceptionunsafeType(String typeName) Creates an exception for unsafe type.Methods inherited from class OpenYmlException
getColumn, getLine, hasLocationMethods inherited from class OpenException
getComponent, getErrorCode, getMessage, getRawMessageMethods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface OpenExceptionMeta
getMetaPrefix
-
Constructor Details
-
YmlSecurityException
Constructs a security exception with type and message. 构造带类型和消息的安全异常。- Parameters:
type- the violation type | 违规类型message- the detail message | 详细消息
-
YmlSecurityException
public YmlSecurityException(YmlSecurityException.SecurityViolationType type, String message, Throwable cause) Constructs a security exception with type, message and cause. 构造带类型、消息和原因的安全异常。- Parameters:
type- the violation type | 违规类型message- the detail message | 详细消息cause- the cause | 原因
-
-
Method Details
-
getType
Gets the security violation type. 获取安全违规类型。- Returns:
- the violation type | 违规类型
-
aliasLimitExceeded
Creates an exception for alias limit exceeded. 为别名超限创建异常。- Parameters:
count- the alias count | 别名数量limit- the alias limit | 别名限制- Returns:
- the exception | 异常
-
nestingDepthExceeded
Creates an exception for nesting depth exceeded. 为嵌套深度超限创建异常。- Parameters:
depth- the nesting depth | 嵌套深度limit- the depth limit | 深度限制- Returns:
- the exception | 异常
-
documentSizeExceeded
Creates an exception for document size exceeded. 为文档大小超限创建异常。- Parameters:
size- the document size | 文档大小limit- the size limit | 大小限制- Returns:
- the exception | 异常
-
forbiddenType
Creates an exception for forbidden type. 为禁止类型创建异常。- Parameters:
typeName- the forbidden type name | 禁止的类型名称- Returns:
- the exception | 异常
-
unsafeType
Creates an exception for unsafe type. 为不安全类型创建异常。- Parameters:
typeName- the unsafe type name | 不安全的类型名称- Returns:
- the exception | 异常
-