1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity;
17
18 import org.springframework.util.StringUtils;
19
20 import java.beans.PropertyEditorSupport;
21
22
23 /***
24 * A property editor that can create a populated {@link
25 * ConfigAttributeDefinition} from a comma separated list of values.
26 *
27 * <P>
28 * Trims preceding and trailing spaces from presented command separated tokens,
29 * as this can be a source of hard-to-spot configuration issues for end users.
30 * </p>
31 *
32 * @author Ben Alex
33 * @version $Id: ConfigAttributeEditor.java,v 1.4 2005/11/17 00:55:49 benalex Exp $
34 */
35 public class ConfigAttributeEditor extends PropertyEditorSupport {
36
37
38 public void setAsText(String s) throws IllegalArgumentException {
39 if ((s == null) || "".equals(s)) {
40 setValue(null);
41 } else {
42 String[] tokens = StringUtils.commaDelimitedListToStringArray(s);
43 ConfigAttributeDefinition configDefinition = new ConfigAttributeDefinition();
44
45 for (int i = 0; i < tokens.length; i++) {
46 configDefinition.addConfigAttribute(new SecurityConfig(
47 tokens[i].trim()));
48 }
49
50 setValue(configDefinition);
51 }
52 }
53 }