|
@@ -80,29 +80,35 @@ public class UserMapEditor extends PropertyEditorSupport {
|
|
|
propertiesEditor.setAsText(s);
|
|
|
|
|
|
Properties props = (Properties) propertiesEditor.getValue();
|
|
|
+ addUsersFromProperties(userMap, props);
|
|
|
+ }
|
|
|
|
|
|
- // Now we have properties, process each one individually
|
|
|
- UserAttributeEditor configAttribEd = new UserAttributeEditor();
|
|
|
+ setValue(userMap);
|
|
|
+ }
|
|
|
|
|
|
- for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
|
|
|
- String username = (String) iter.next();
|
|
|
- String value = props.getProperty(username);
|
|
|
+ public static UserMap addUsersFromProperties(UserMap userMap,
|
|
|
+ Properties props) {
|
|
|
+ // Now we have properties, process each one individually
|
|
|
+ UserAttributeEditor configAttribEd = new UserAttributeEditor();
|
|
|
|
|
|
- // Convert value to a password, enabled setting, and list of granted authorities
|
|
|
- configAttribEd.setAsText(value);
|
|
|
+ for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
|
|
|
+ String username = (String) iter.next();
|
|
|
+ String value = props.getProperty(username);
|
|
|
|
|
|
- UserAttribute attr = (UserAttribute) configAttribEd.getValue();
|
|
|
+ // Convert value to a password, enabled setting, and list of granted authorities
|
|
|
+ configAttribEd.setAsText(value);
|
|
|
|
|
|
- // Make a user object, assuming the properties were properly provided
|
|
|
- if (attr != null) {
|
|
|
- UserDetails user = new User(username, attr.getPassword(),
|
|
|
- attr.isEnabled(), true, true, true,
|
|
|
- attr.getAuthorities());
|
|
|
- userMap.addUser(user);
|
|
|
- }
|
|
|
+ UserAttribute attr = (UserAttribute) configAttribEd.getValue();
|
|
|
+
|
|
|
+ // Make a user object, assuming the properties were properly provided
|
|
|
+ if (attr != null) {
|
|
|
+ UserDetails user = new User(username, attr.getPassword(),
|
|
|
+ attr.isEnabled(), true, true, true,
|
|
|
+ attr.getAuthorities());
|
|
|
+ userMap.addUser(user);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- setValue(userMap);
|
|
|
+ return userMap;
|
|
|
}
|
|
|
}
|