SEC-384: Remove Commons-Lang dependency.
This commit is contained in:
+8
-8
@@ -15,18 +15,18 @@
|
||||
|
||||
package org.acegisecurity.intercept.web;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.acegisecurity.util.StringSplitUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
||||
/**
|
||||
* Property editor to assist with the setup of a {@link FilterInvocationDefinitionSource}.<p>The class creates and
|
||||
@@ -131,10 +131,10 @@ public class FilterInvocationDefinitionSourceEditor extends PropertyEditorSuppor
|
||||
|
||||
// Tokenize the line into its name/value tokens
|
||||
// As per SEC-219, use the LAST equals as the delimiter between LHS and RHS
|
||||
String name = StringUtils.substringBeforeLast(line, "=");
|
||||
String value = StringUtils.substringAfterLast(line, "=");
|
||||
String name = StringSplitUtils.substringBeforeLast(line, "=");
|
||||
String value = StringSplitUtils.substringAfterLast(line, "=");
|
||||
|
||||
if (StringUtils.isBlank(name) || StringUtils.isBlank(value)) {
|
||||
if (!StringUtils.hasText(name) || !StringUtils.hasText(value)) {
|
||||
throw new IllegalArgumentException("Failed to parse a valid name/value pair from " + line);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,4 +104,31 @@ public class StringSplitUtils {
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
public static String substringBeforeLast(String str, String separator) {
|
||||
if (str == null || separator == null || str.length() == 0 ||
|
||||
separator.length() == 0) {
|
||||
return str;
|
||||
}
|
||||
int pos = str.lastIndexOf(separator);
|
||||
if (pos == -1) {
|
||||
return str;
|
||||
}
|
||||
return str.substring(0, pos);
|
||||
}
|
||||
|
||||
public static String substringAfterLast(String str, String separator) {
|
||||
if (str == null || str.length() == 0) {
|
||||
return str;
|
||||
}
|
||||
if (separator == null || separator.length() == 0) {
|
||||
return "";
|
||||
}
|
||||
int pos = str.lastIndexOf(separator);
|
||||
if (pos == -1 || pos == (str.length() - separator.length())) {
|
||||
return "";
|
||||
}
|
||||
return str.substring(pos + separator.length());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user