2
0
Эх сурвалжийг харах

SEC-384: Remove Commons-Lang dependency.

Ben Alex 19 жил өмнө
parent
commit
2a65d386d5

+ 0 - 5
.classpath

@@ -6,10 +6,6 @@
 	<classpathentry kind="src" path="samples/acegifier/src/main/resources"/>
 	<classpathentry kind="src" path="samples/acegifier/src/main/java"/>
 	<classpathentry kind="src" path="samples/acegifier/src/test/java"/>
-	<classpathentry kind="src" path="domain/src/main/java"/>
-	<classpathentry kind="src" path="domain/src/main/resource"/>
-	<classpathentry kind="src" path="domain/src/test/java"/>
-	<classpathentry kind="src" path="domain/src/test/resources"/>
 	<classpathentry kind="src" path="adapters/catalina/src/main/resources"/>
 	<classpathentry kind="src" path="samples/attributes/src/main/resources"/>
 	<classpathentry kind="src" path="samples/attributes/src/test/java"/>
@@ -52,7 +48,6 @@
 	<classpathentry kind="var" path="MAVEN_REPO/ehcache/jars/ehcache-1.1.jar"/>
 	<classpathentry kind="var" path="MAVEN_REPO/javax.servlet/jars/jsp-api-2.0.jar"/>
 	<classpathentry kind="var" path="MAVEN_REPO/hibernate/jars/hibernate-3.0.3.jar"/>
-	<classpathentry kind="var" path="MAVEN_REPO/commons-lang/jars/commons-lang-2.0.jar"/>
 	<classpathentry sourcepath="DIST_BASE/commons-beanutils-1.6.1-src/src/java" kind="var" path="MAVEN_REPO/commons-beanutils/jars/commons-beanutils-1.6.1.jar"/>
 	<classpathentry kind="src" path="core-tiger/src/main/java"/>
 	<classpathentry kind="src" path="core-tiger/src/test/java"/>

+ 8 - 8
core/src/main/java/org/acegisecurity/intercept/web/FilterInvocationDefinitionSourceEditor.java

@@ -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);
                 }
 

+ 27 - 0
core/src/main/java/org/acegisecurity/util/StringSplitUtils.java

@@ -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());
+    }
+    
 }