Class EnrollmentSubjectPattern

java.lang.Object
zeroecho.pki.server.enrollment.EnrollmentSubjectPattern

public final class EnrollmentSubjectPattern extends Object
Immutable linear-time matcher for bounded enrollment subject constraints.

The grammar accepts literal text and .* wildcards, with optional leading ^ and trailing $. Matching always covers the entire subject. Backslash escapes only regex punctuation as literal text; groups, alternatives, character classes, backreferences, and other quantifiers are rejected. Patterns are at most 512 UTF-16 code units and subjects at most 4096. This deliberately restricted grammar avoids regex backtracking.

Compilation requires O(M) time and space. Matching requires O(N + M) time and O(1) auxiliary memory, where M and N are pattern and subject lengths.

  • Method Details

    • compile

      public static EnrollmentSubjectPattern compile(String pattern)
      Compiles the closed, bounded subject-pattern grammar.
      Parameters:
      pattern - nonempty pattern, at most 512 code units
      Returns:
      immutable thread-safe matcher
      Throws:
      IllegalArgumentException - if the syntax or size is unsupported
    • matches

      public boolean matches(String subject)
      Tests the complete subject against the compiled constraint.
      Parameters:
      subject - canonical subject DN text, at most 4096 code units
      Returns:
      whether the entire subject matches
      Throws:
      IllegalArgumentException - if the subject exceeds the finite bound