in geronimo-jacc_1.4_spec/src/main/java/javax/security/jacc/URLPatternSpec.java [42:107]
public URLPatternSpec(String name) {
if (name == null) throw new java.lang.IllegalArgumentException("URLPatternSpec cannot be null");
if (name.length() == 0) name = "/";
pattern = name;
String[] tokens = pattern.split(":", -1);
first = new URLPattern(tokens[0]);
URLPattern candidate;
for (int i = 1; i < tokens.length; i++) {
candidate = new URLPattern(tokens[i]);
// No pattern may exist in the URLPatternList that matches the first pattern.
if (candidate.matches(first)) {
throw new java.lang.IllegalArgumentException("Qualifier patterns in the URLPatternSpec cannot match the first URLPattern");
}
if (first.type == URLPattern.PATH_PREFIX) {
// If the first pattern is a path-prefix pattern, only exact patterns
// matched by the first pattern and path-prefix patterns matched by,
// but different from, the first pattern may occur in the URLPatternList.
if (candidate.type == URLPattern.EXACT && !first.matches(candidate)) {
throw new java.lang.IllegalArgumentException("Exact qualifier patterns in the URLPatternSpec must be matched by the first URLPattern");
} else if (candidate.type == URLPattern.PATH_PREFIX
&& !(first.matches(candidate)
&& first.pattern.length() < candidate.pattern.length())) {
throw new java.lang.IllegalArgumentException("path-prefix qualifier patterns in the URLPatternSpec must be matched by, but different from, the first URLPattern");
} else if (candidate.type == URLPattern.EXTENSION) {
throw new java.lang.IllegalArgumentException("extension qualifier patterns in the URLPatternSpec are not allowed when the first URLPattern is path-prefix");
}
} else if (first.type == URLPattern.EXTENSION) {
// If the first pattern is an extension pattern, only exact patterns
// that are matched by the first pattern and path-prefix patterns may
// occur in the URLPatternList.
if (candidate.type == URLPattern.EXACT) {
if (!first.matches(candidate)) {
throw new java.lang.IllegalArgumentException("Exact qualifier patterns in the URLPatternSpec must be matched when first URLPattern is an extension pattern");
}
} else if (candidate.type != URLPattern.PATH_PREFIX) {
throw new java.lang.IllegalArgumentException("Only exact and path-prefix qualifiers in the URLPatternSpec are allowed when first URLPattern is an extension pattern");
}
} else if (first.type == URLPattern.DEFAULT) {
// If the first pattern is the default pattern, "/", any pattern
// except the default pattern may occur in the URLPatternList.
if (candidate.type == URLPattern.DEFAULT) {
//This is actually tested for by the "qualifier must not match first" rule
throw new java.lang.IllegalArgumentException("Qualifier patterns must not be default when first URLPattern is a default pattern");
}
} else if (first.type == URLPattern.EXACT) {
// If the first pattern is an exact pattern a URLPatternList
// must not be present in the URLPatternSpec
throw new java.lang.IllegalArgumentException("Qualifier patterns must not be present when first URLPattern is an exact pattern");
}
qualifiers.add(candidate);
}
}