import java.util.Dictionary;
+import javax.transaction.UserTransaction;
+
import org.argeo.eclipse.ui.EclipseUiUtils;
import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
import org.argeo.jcr.ArgeoNames;
/** Open a wizard that enables creation of a new user. */
public class NewUser extends AbstractHandler {
// private final static Log log = LogFactory.getLog(NewUser.class);
-
public final static String ID = SecurityAdminPlugin.PLUGIN_ID + ".newUser";
+ /* DEPENDENCY INJECTION */
private UserAdmin userAdmin;
+ private UserTransaction userTransaction;
// TODO implement a dynamic choice of the base dn
private String getDn(String uid) {
((UsersView) part).refresh();
}
- public void setUserAdmin(UserAdmin userAdmin) {
- this.userAdmin = userAdmin;
- }
-
private class NewUserWizard extends Wizard {
// pages
public void addPages() {
mainUserInfo = new MainUserInfoWizardPage();
addPage(mainUserInfo);
- String message = "Dummy wizard to ease user creation tests: mail, last name are automatically "
- + "generated form the uid, password are defauted to 'demo'.";
+ String message = "Dummy wizard to ease user creation tests:\n Mail and last name are automatically "
+ + "generated form the uid. Password are defauted to 'demo'.";
mainUserInfo.setMessage(message, WizardPage.WARNING);
}
return false;
String username = mainUserInfo.getUsername();
try {
+ UiAdminUtils.beginTransactionIfNeeded(userTransaction);
char[] password = mainUserInfo.getPassword();
User user = (User) userAdmin.createRole(getDn(username),
Role.USER);
if (UiAdminUtils.notNull(mailStr))
props.put(UserAdminConstants.KEY_MAIL, mailStr);
- // TODO MANAGE Password
- // pwd1Txt.getText();
+ user.getCredentials().put(null, password);
return true;
} catch (Exception e) {
ErrorFeedback.show("Cannot create new user " + username, e);
}
}
- // Local helpers
+ /* DEPENDENCY INJECTION */
+ public void setUserAdmin(UserAdmin userAdmin) {
+ this.userAdmin = userAdmin;
+ }
+ public void setUserTransaction(UserTransaction userTransaction) {
+ this.userTransaction = userTransaction;
+ }
}
\ No newline at end of file