-Import-Package:*, org.argeo.connect.streams
+Import-Package:*
</plugins>
</build>
<dependencies>
- <!-- Connect -->
+ <!-- Core CMS code -->
<dependency>
<groupId>org.argeo.commons</groupId>
<artifactId>org.argeo.cms</artifactId>
import org.argeo.cms.viewers.JcrVersionCmsEditable;
import org.argeo.cms.widgets.ScrolledPage;
import org.argeo.security.UserAdminService;
-import org.argeo.security.jcr.JcrSecurityModel;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
// Enable user CRUD // INJECTED
private UserAdminService userAdminService;
+ // private UserDetailsManager userDetailsManager;
+
// private JcrSecurityModel jcrSecurityModel;
// public UserPage(UserAdminService userAdminService,
cmsEditable);
Control control = userViewer.getControl();
+
+ // FIXME not satisfying.close
+ if (control instanceof UserPart)
+ ((UserPart) control).setUserAdminService(userAdminService);
+
Composite par = control.getParent();
UserRolesPart rolesPart = new UserRolesPart(par, SWT.NO_FOCUS, context,
true);
rolesPart.setUserAdminService(userAdminService);
+ rolesPart.setUserAdminService(userAdminService);
rolesPart.createControl(rolesPart, UserStyles.USER_FORM_TEXT);
rolesPart.refresh();
rolesPart.setLayoutData(CmsUtils.fillWidth());
this.userAdminService = userAdminService;
}
-// public void setJcrSecurityModel(JcrSecurityModel jcrSecurityModel) {
-// this.jcrSecurityModel = jcrSecurityModel;
-// }
+ // public void setUserDetailsManager(UserDetailsManager userDetailsManager)
+ // {
+ // this.userDetailsManager = userDetailsManager;
+ // }
}
\ No newline at end of file
import org.argeo.cms.widgets.StyledControl;
import org.argeo.eclipse.ui.EclipseUiUtils;
import org.argeo.jcr.ArgeoNames;
+import org.argeo.security.UserAdminService;
+import org.argeo.security.jcr.JcrUserDetails;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusEvent;
private List<Text> texts;
private final static String KEY_PROP_NAME = "jcr:propertyName";
+ // the 2 password fields
+ private Text pwd1, pwd2;
+
+ private UserAdminService userAdminService;
+
+ // private UserDetailsManager userDetailsManager;
+
// TODO implement to provide user creation ability for anonymous user?
// public UserPart(Composite parent, int swtStyle) {
// super(parent, swtStyle);
@Override
protected Control createControl(Composite box, String style) {
- if (isEditing())
- return createEditLayout(box, style);
- else
- return createROLayout(box, style);
- }
-
- protected Composite createROLayout(Composite parent, String style) {
- Composite body = new Composite(parent, SWT.NO_FOCUS);
+ Composite body = new Composite(box, SWT.NO_FOCUS);
body.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
GridLayout layout = new GridLayout(2, false);
+ // GridLayout layout = CmsUtils.noSpaceGridLayout(new GridLayout(2,
+ // false));
+
body.setLayout(layout);
+ CmsUtils.style(body, UserStyles.USER_FORM_TEXT);
// header
Label header = new Label(body, SWT.NONE);
// form field
createTexts(body, UserStyles.USER_FORM_TEXT);
- CmsUtils.style(body, UserStyles.USER_FORM_TEXT);
+
+ if (isEditing())
+ for (Text txt : texts)
+ txt.addFocusListener(this);
// Change password link
// header
1));
CmsUtils.style(header, UserStyles.USER_FORM_TITLE);
+ pwd1 = createLP(body, UserStyles.USER_FORM_TEXT, "Enter password");
+ pwd2 = createLP(body, UserStyles.USER_FORM_TEXT, "Re-Enter");
+
final Link link = new Link(body, SWT.NONE);
+ link.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 2, 1));
link.setText("<a>Change password</a>");
link.addSelectionListener(new SelectionAdapter() {
+ private static final long serialVersionUID = 8348668888548451776L;
+
@Override
public void widgetSelected(SelectionEvent e) {
-
- MessageDialog.openInformation(link.getShell(),
- "Not implemented", "Implement This.");
-
- // ChangePasswordDialog dialog = new ChangePasswordDialog(
- // link.getShell(), userDetailsManager);
- // if (dialog.open() == Window.OK) {
- // MessageDialog.openInformation(HandlerUtil.getActiveShell(event),
- // "Password changed", "Password changed.");
- // }
- // return null;
+ String msg = null;
+ if ("".equals(pwd1.getText().trim()))
+ msg = "Passwords cannot be blank";
+ else if (!pwd1.getText().equals(pwd2.getText()))
+ msg = "Passwords do not match, please try again.";
+
+ if (msg != null) {
+ MessageDialog.openError(link.getShell(), "Error", msg);
+ } else {
+ try {
+ String username = getNode().getProperty(
+ ArgeoNames.ARGEO_USER_ID).getString();
+ if (userAdminService.userExists(username)) {
+ JcrUserDetails userDetails = (JcrUserDetails) userAdminService
+ .loadUserByUsername(username);
+ userDetails = userDetails.cloneWithNewPassword(pwd1
+ .getText());
+ userAdminService.updateUser(userDetails);
+ MessageDialog.openInformation(link.getShell(),
+ "Password changed", "Password changed.");
+ }
+ } catch (Exception re) {
+ throw new ArgeoException(
+ "unable to reset password for user "
+ + getNode(), re);
+ }
+ }
+
+ pwd1.setText("");
+ pwd2.setText("");
}
});
-
return body;
}
Property.JCR_DESCRIPTION));
}
- protected Composite createEditLayout(Composite parent, String style) {
- Composite body = new Composite(parent, SWT.NO_FOCUS);
- GridLayout layout = new GridLayout(2, false);
- body.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- body.setLayout(layout);
-
- createTexts(body, UserStyles.USER_FORM_TEXT);
-
- for (Text txt : texts)
- txt.addFocusListener(this);
- CmsUtils.style(body, UserStyles.USER_FORM_TEXT);
- return body;
- }
+ // protected Composite createEditLayout(Composite parent, String style) {
+ // Composite body = new Composite(parent, SWT.NO_FOCUS);
+ // GridLayout layout = new GridLayout(2, false);
+ // body.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ // body.setLayout(layout);
+ //
+ // createTexts(body, UserStyles.USER_FORM_TEXT);
+ //
+ // return body;
+ // }
void refresh() {
for (Text txt : texts) {
}
}
- // THE LISTENER
+ // his.listener methods
@Override
public void focusGained(FocusEvent e) {
// Do nothing
return text;
}
+ // HELPERS
+ /** Creates label and password text. */
+ protected Text createLP(Composite body, String style, String label) {
+ Label lbl = new Label(body, SWT.NONE);
+ lbl.setText(label);
+ lbl.setFont(EclipseUiUtils.getBoldFont(body));
+ lbl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+ Text text = new Text(body, SWT.BORDER | SWT.PASSWORD);
+ text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ CmsUtils.style(text, style);
+ return text;
+ }
+
/** Creates label and multiline text. */
protected Text createLMT(Composite body, String style, String label,
String propName) {
+ node + " with value " + value, e);
}
}
+
+ /* DEPENDENCY INJECTION */
+ // public void setUserDetailsManager(UserDetailsManager userDetailsManager)
+ // {
+ // this.userDetailsManager = userDetailsManager;
+ // }
+
+ public void setUserAdminService(UserAdminService userAdminService) {
+ this.userAdminService = userAdminService;
+ }
}
\ No newline at end of file
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
@Override
protected Control createControl(Composite box, String style) {
- box.setLayout(CmsUtils.noSpaceGridLayout());
+ // box.setLayout(CmsUtils.noSpaceGridLayout());
+ box.setLayout(new GridLayout());
Label header = new Label(box, SWT.NONE);
header.setText(" Groups");
CmsUtils.style(header, UserStyles.USER_FORM_TITLE);
header.setLayoutData(CmsUtils.fillWidth());
-
+
int swtStyle = SWT.CHECK | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL;
if (!isEditing())
swtStyle |= SWT.READ_ONLY;
public void setUserAdminService(UserAdminService userAdminService) {
this.userAdminService = userAdminService;
-
try {
String username = getNode().getProperty(ArgeoNames.ARGEO_USER_ID)
.getString();
- // ;
-
if (userAdminService.userExists(username)) {
JcrUserDetails userDetails = (JcrUserDetails) userAdminService
.loadUserByUsername(username);
setUserDetails(userDetails);
}
} catch (Exception e) {
- throw new ArgeoException("Cannot retrieve userDetails for "// +
- // username
- , e);
+ throw new ArgeoException("Cannot retrieve userDetails for "
+ + getNode(), e);
}
}
public void setUserDetails(JcrUserDetails userDetails) {
this.userDetails = userDetails;
-
this.roles = new ArrayList<String>();
for (GrantedAuthority ga : userDetails.getAuthorities())
roles.add(ga.getAuthority());
import org.argeo.jcr.JcrUtils;
import org.argeo.security.UserAdminService;
import org.argeo.security.jcr.JcrSecurityModel;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.springframework.security.userdetails.UserDetailsManager;
/**
* Simple page to manage users of a given repository. We still rely on Argeo
// Enable user CRUD // INJECTED
private UserAdminService userAdminService;
private JcrSecurityModel jcrSecurityModel;
+ // private UserDetailsManager userDetailsManager;
private String userWkspName;
// Local UI Providers
session, userAdminService, jcrSecurityModel);
WizardDialog dialog = new WizardDialog(addBtn.getShell(),
newUserWizard);
- if (dialog.open() == Window.OK)
+ if (dialog.open() == Dialog.OK)
userTableCmp.refresh();
}
});
this.jcrSecurityModel = jcrSecurityModel;
// userPage.setJcrSecurityModel(jcrSecurityModel);
}
+
+ public void setUserDetailsManager(UserDetailsManager userDetailsManager) {
+ // this.userDetailsManager = userDetailsManager;
+ // userPage.setUserDetailsManager(userDetailsManager);
+ }
}
\ No newline at end of file
import org.eclipse.ui.part.ViewPart;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
/**
* Overview of the bundles as a table. Equivalent to Equinox 'ss' console
private static final long serialVersionUID = 6871926308708629989L;
public String getText(Object element) {
-
- // return "";
- // FIXME triggers compilation failure
Bundle bundle = (org.osgi.framework.Bundle) element;
return bundle.getVersion().toString();
}
});
new ColumnViewerComparator<Bundle>(column, new Comparator<Bundle>() {
public int compare(Bundle o1, Bundle o2) {
- return 0;
- // FIXME getVersion() triggers compilation failure
- // return o1.getVersion().compareTo(o2.getVersion());
+ return o1.getVersion().compareTo(o2.getVersion());
}
});
return "RESOLVED";
case Bundle.STARTING:
String activationPolicy = bundle.getHeaders()
- .get("Bundle-ActivationPolicy").toString();
+ .get(Constants.BUNDLE_ACTIVATIONPOLICY).toString();
+
+ // .get("Bundle-ActivationPolicy").toString();
// FIXME constant triggers the compilation failure
- // .get(Constants.BUNDLE_ACTIVATIONPOLICY).toString();
- if (activationPolicy != null && activationPolicy.equals("lazy"))
+ if (activationPolicy != null
+ && activationPolicy.equals(Constants.ACTIVATION_LAZY))
+ // && activationPolicy.equals("lazy"))
// FIXME constant triggers the compilation failure
// && activationPolicy.equals(Constants.ACTIVATION_LAZY))
return "<<LAZY>>";
}
protected Point getInitialSize() {
- return new Point(300, 250);
+ return new Point(400, 450);
}
protected Control createDialogArea(Composite parent) {
// pages
private MainUserInfoWizardPage mainUserInfo;
- public UserCreationWizard(Session session, UserAdminService userAdminService,
- JcrSecurityModel jcrSecurityModel) {
+ public UserCreationWizard(Session session,
+ UserAdminService userAdminService, JcrSecurityModel jcrSecurityModel) {
this.session = session;
this.userAdminService = userAdminService;
this.jcrSecurityModel = jcrSecurityModel;
+ username, e1);
}
}
- MessageDialog.openError(getShell(), "Eroor",
+ // FIXME re-get ErrorFeedback dialog after single sourcing
+ // refactoring
+ MessageDialog.openError(getShell(), "Error",
"Cannot create new user " + username);
+ log.error("Cannot create new user " + username);
+ e.printStackTrace();
return false;
}
}