Class XmlSecurityException

All Implemented Interfaces:
Serializable

public class XmlSecurityException extends OpenXmlException
XML Security Exception - Thrown when a security violation is detected XML 安全异常 - 当检测到安全违规时抛出

This exception is thrown when the parser detects potential security threats, such as XXE (XML External Entity) attacks or entity expansion attacks.

当解析器检测到潜在的安全威胁(如 XXE 攻击或实体扩展攻击)时抛出此异常。

Features | 主要功能:

  • Exception for XML security violations (XXE, entity expansion, etc.) - XML 安全违规异常(XXE、实体扩展等)
  • Carries SecurityViolationType for programmatic handling - 携带 SecurityViolationType 用于编程式处理

Usage Examples | 使用示例:

// Catch security exception
try {
    DomParser.parse(untrustedXml);
} catch (XmlSecurityException e) {
    System.err.println("Security violation: " + e.getType());
}
Since:
JDK 25, opencode-base-xml V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • XmlSecurityException

      public XmlSecurityException(XmlSecurityException.SecurityViolationType type, String message)
      Constructs a security exception with violation type and message. 构造带违规类型和消息的安全异常。
      Parameters:
      type - the security violation type | 安全违规类型
      message - the detail message | 详细消息
    • XmlSecurityException

      public XmlSecurityException(XmlSecurityException.SecurityViolationType type, String message, Throwable cause)
      Constructs a security exception with violation type, message and cause. 构造带违规类型、消息和原因的安全异常。
      Parameters:
      type - the security violation type | 安全违规类型
      message - the detail message | 详细消息
      cause - the cause | 原因
  • Method Details