import static org.eclipse.jface.dialogs.IMessageProvider.INFORMATION;
import java.security.AccessController;
import static org.eclipse.jface.dialogs.IMessageProvider.INFORMATION;
import java.security.AccessController;
import org.apache.commons.logging.LogFactory;
import org.argeo.cms.CmsException;
import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
import org.apache.commons.logging.LogFactory;
import org.argeo.cms.CmsException;
import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
- ChangePasswordDialog dialog = new ChangePasswordDialog(
- HandlerUtil.getActiveShell(event), userAdmin);
+ ChangePasswordDialog dialog = new ChangePasswordDialog(HandlerUtil.getActiveShell(event), userAdmin);
- MessageDialog.openInformation(HandlerUtil.getActiveShell(event),
- passwordChanged.lead(), passwordChanged.lead());
+ MessageDialog.openInformation(HandlerUtil.getActiveShell(event), passwordChanged.lead(),
+ passwordChanged.lead());
@SuppressWarnings("unchecked")
protected void changePassword(char[] oldPassword, char[] newPassword) {
Subject subject = Subject.getSubject(AccessController.getContext());
@SuppressWarnings("unchecked")
protected void changePassword(char[] oldPassword, char[] newPassword) {
Subject subject = Subject.getSubject(AccessController.getContext());
User user = (User) userAdmin.getRole(dn.toString());
if (!user.hasCredential(null, oldPassword))
throw new CmsException("Invalid password");
User user = (User) userAdmin.getRole(dn.toString());
if (!user.hasCredential(null, oldPassword))
throw new CmsException("Invalid password");
throw new CmsException("New password empty");
try {
userTransaction.begin();
user.getCredentials().put(null, newPassword);
throw new CmsException("New password empty");
try {
userTransaction.begin();
user.getCredentials().put(null, newPassword);
- public void setUserAdmin(UserAdmin userDetailsManager) {
- this.userAdmin = userDetailsManager;
- }
-
- public void setUserTransaction(UserTransaction userTransaction) {
- this.userTransaction = userTransaction;
- }
-
class ChangePasswordDialog extends TitleAreaDialog {
private static final long serialVersionUID = -6963970583882720962L;
private Text oldPassword, newPassword1, newPassword2;
class ChangePasswordDialog extends TitleAreaDialog {
private static final long serialVersionUID = -6963970583882720962L;
private Text oldPassword, newPassword1, newPassword2;
protected Control createDialogArea(Composite parent) {
Composite dialogarea = (Composite) super.createDialogArea(parent);
protected Control createDialogArea(Composite parent) {
Composite dialogarea = (Composite) super.createDialogArea(parent);
- dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
- true));
+ dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Composite composite = new Composite(dialogarea, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
Composite composite = new Composite(dialogarea, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
- false));
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
oldPassword = createLP(composite, currentPassword.lead());
newPassword1 = createLP(composite, newPassword.lead());
newPassword2 = createLP(composite, repeatNewPassword.lead());
setMessage(changePassword.lead(), INFORMATION);
parent.pack();
oldPassword = createLP(composite, currentPassword.lead());
newPassword1 = createLP(composite, newPassword.lead());
newPassword2 = createLP(composite, repeatNewPassword.lead());
setMessage(changePassword.lead(), INFORMATION);
parent.pack();
try {
if (!newPassword1.getText().equals(newPassword2.getText()))
throw new CmsException("New passwords are different");
try {
if (!newPassword1.getText().equals(newPassword2.getText()))
throw new CmsException("New passwords are different");
/** Creates label and password. */
protected Text createLP(Composite parent, String label) {
new Label(parent, SWT.NONE).setText(label);
/** Creates label and password. */
protected Text createLP(Composite parent, String label) {
new Label(parent, SWT.NONE).setText(label);
text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
return text;
}
text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
return text;
}