| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.acegisecurity.intercept.method; |
| 17 |
|
|
| 18 |
|
import org.apache.commons.logging.Log; |
| 19 |
|
import org.apache.commons.logging.LogFactory; |
| 20 |
|
|
| 21 |
|
import org.springframework.beans.propertyeditors.PropertiesEditor; |
| 22 |
|
import org.springframework.util.StringUtils; |
| 23 |
|
|
| 24 |
|
import java.beans.PropertyEditorSupport; |
| 25 |
|
|
| 26 |
|
import java.util.ArrayList; |
| 27 |
|
import java.util.Iterator; |
| 28 |
|
import java.util.List; |
| 29 |
|
import java.util.Properties; |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
32 |
public class MethodDefinitionSourceEditor extends PropertyEditorSupport { |
| 40 |
|
|
| 41 |
|
|
| 42 |
2 |
private static final Log logger = LogFactory.getLog(MethodDefinitionSourceEditor.class); |
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
public void setAsText(String s) throws IllegalArgumentException { |
| 47 |
32 |
MethodDefinitionMap source = new MethodDefinitionMap(); |
| 48 |
|
|
| 49 |
32 |
if ((s == null) || "".equals(s)) { |
| 50 |
|
|
| 51 |
|
} else { |
| 52 |
|
|
| 53 |
30 |
PropertiesEditor propertiesEditor = new PropertiesEditor(); |
| 54 |
30 |
propertiesEditor.setAsText(s); |
| 55 |
|
|
| 56 |
30 |
Properties props = (Properties) propertiesEditor.getValue(); |
| 57 |
|
|
| 58 |
|
|
| 59 |
30 |
List mappings = new ArrayList(); |
| 60 |
|
|
| 61 |
30 |
for (Iterator iter = props.keySet().iterator(); iter.hasNext();) { |
| 62 |
64 |
String name = (String) iter.next(); |
| 63 |
64 |
String value = props.getProperty(name); |
| 64 |
|
|
| 65 |
64 |
MethodDefinitionSourceMapping mapping = new MethodDefinitionSourceMapping(); |
| 66 |
64 |
mapping.setMethodName(name); |
| 67 |
|
|
| 68 |
64 |
String[] tokens = StringUtils.commaDelimitedListToStringArray(value); |
| 69 |
|
|
| 70 |
172 |
for (int i = 0; i < tokens.length; i++) { |
| 71 |
108 |
mapping.addConfigAttribute(tokens[i].trim()); |
| 72 |
|
} |
| 73 |
|
|
| 74 |
64 |
mappings.add(mapping); |
| 75 |
64 |
} |
| 76 |
30 |
source.setMappings(mappings); |
| 77 |
|
} |
| 78 |
|
|
| 79 |
29 |
setValue(source); |
| 80 |
29 |
} |
| 81 |
|
} |