Class CreateNamePattern
java.lang.Object
io.jenkins.plugins.batchcontrol.model.CreateNamePattern
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
public final class CreateNamePattern
extends Object
The optional name restriction of a CREATE grant (D-40): either an exact item name, or a Java
regular expression written as
/regex/ that must match the whole item name. Only the item
name is ever matched, never the full name.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intUpper bound on the stored restriction, so a request cannot carry an unbounded regex.static final intD-40a (security-08 S-03): a longer new name never matches a restriction. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringPlain-text description of a stored restriction for an explanation to the holder (e2e-03 DEF-19), for examplenames matching the pattern /app-[0-9]+/orthe name 'app-2'.static CreateNamePatternCompiles a stored restriction for matching; a stored value that no longer parses matches nothing (fail-safe), represented by a pattern that never matches.booleanWhether the new item's name (not its full name) satisfies the restriction.static StringNormalizes user input:nullfor an absent or blank restriction, otherwise the trimmed text.static CreateNamePatternValidates and compiles a restriction at submission time.toString()
-
Field Details
-
MAX_LENGTH
public static final int MAX_LENGTHUpper bound on the stored restriction, so a request cannot carry an unbounded regex.- See Also:
-
MAX_NAME_LENGTH
public static final int MAX_NAME_LENGTHD-40a (security-08 S-03): a longer new name never matches a restriction.- See Also:
-
-
Method Details
-
normalize
Normalizes user input:nullfor an absent or blank restriction, otherwise the trimmed text. -
describe
Plain-text description of a stored restriction for an explanation to the holder (e2e-03 DEF-19), for examplenames matching the pattern /app-[0-9]+/orthe name 'app-2'. -
parse
Validates and compiles a restriction at submission time.- Parameters:
text- the normalized restriction (seenormalize(java.lang.String)); must not benull- Throws:
IllegalArgumentException- if the text is too long, the regex does not compile, or an exact name is not a valid item name
-
forStored
Compiles a stored restriction for matching; a stored value that no longer parses matches nothing (fail-safe), represented by a pattern that never matches. -
matches
Whether the new item's name (not its full name) satisfies the restriction. The name is matched exactly as submitted, untrimmed (S-06). A name over 255 characters never matches, and a regular-expression match that runs longer than the deadline fails (S-03), so no pattern can stall the calling thread. -
toString
-