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.acegisecurity.ConfigAttributeDefinition;
19 import org.acegisecurity.ConfigAttributeEditor;
20
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23
24 import org.springframework.beans.propertyeditors.PropertiesEditor;
25
26 import java.beans.PropertyEditorSupport;
27
28 import java.util.Iterator;
29 import java.util.Properties;
30
31
32 /***
33 * Property editor to assist with the setup of a {@link
34 * MethodDefinitionSource}.
35 *
36 * <p>
37 * The class creates and populates a {@link MethodDefinitionMap}.
38 * </p>
39 *
40 * @author Ben Alex
41 * @version $Id: MethodDefinitionSourceEditor.java,v 1.2 2005/11/17 00:56:09 benalex Exp $
42 */
43 public class MethodDefinitionSourceEditor extends PropertyEditorSupport {
44
45
46 private static final Log logger = LogFactory.getLog(MethodDefinitionSourceEditor.class);
47
48
49
50 public void setAsText(String s) throws IllegalArgumentException {
51 MethodDefinitionMap source = new MethodDefinitionMap();
52
53 if ((s == null) || "".equals(s)) {
54
55 } else {
56
57 PropertiesEditor propertiesEditor = new PropertiesEditor();
58 propertiesEditor.setAsText(s);
59
60 Properties props = (Properties) propertiesEditor.getValue();
61
62
63 ConfigAttributeEditor configAttribEd = new ConfigAttributeEditor();
64
65 for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
66 String name = (String) iter.next();
67 String value = props.getProperty(name);
68
69
70 configAttribEd.setAsText(value);
71
72 ConfigAttributeDefinition attr = (ConfigAttributeDefinition) configAttribEd
73 .getValue();
74
75
76 source.addSecureMethod(name, attr);
77 }
78 }
79
80 setValue(source);
81 }
82 }