Introduce Argeo user edition
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 20 Jan 2011 14:20:57 +0000 (14:20 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 20 Jan 2011 14:20:57 +0000 (14:20 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@4058 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

21 files changed:
eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringCommandHandler.java
security/eclipse/plugins/org.argeo.security.ui.application/SecureRCP.product
security/eclipse/plugins/org.argeo.security.ui/icons/role.gif [new file with mode: 0644]
security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/SecurityPerspective.java
security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/ArgeoUserEditor.java
security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/ArgeoUserMainPage.java [deleted file]
security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/DefaultUserMainPage.java [new file with mode: 0644]
security/eclipse/plugins/pom.xml
security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/AbstractUserNature.java [new file with mode: 0644]
security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ArgeoSecurityDao.java
security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ArgeoSecurityService.java
security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ArgeoUser.java
security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/SimpleArgeoUser.java
security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/UserNature.java
security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/ArgeoUserDetails.java
security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/DefaultArgeoSecurity.java
security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/ArgeoUserDetailsContextMapper.java
security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/UserNatureMapper.java
security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/nature/SimpleUserNatureMapper.java
security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/nature/CoworkerNature.java
security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/nature/SimpleUserNature.java

index 1fb44c50399cf83a10092d0f0ffa2c5624658403..0356f57d2e850acd5cbb9930dca51974cd43bd4c 100644 (file)
@@ -35,36 +35,14 @@ public class SpringCommandHandler implements IHandler {
        }
 
        public Object execute(ExecutionEvent event) throws ExecutionException {
+               String commandId = event.getCommand().getId();
+               String bundleSymbolicName = commandId.substring(0,
+                               commandId.lastIndexOf('.'));
                try {
-                       if (log.isDebugEnabled())
-                               log.debug("Execute " + event + " via spring command handler "
+                       if (log.isTraceEnabled())
+                               log.trace("Execute " + event + " via spring command handler "
                                                + this);
-
-                       // Find the application context of the bundle defining the command
-                       // extension
-                       // ICommandService commandService =
-                       // (ICommandService)ArgeoUiPlugin.getDefault().getWorkbench().getService(ICommandService.class);
-                       //              
-                       // Command command =
-                       // commandService.getCommand(event.getCommand().getId());
-                       // log.debug("command=" + command);
-                       // log.debug("Command id " + command.getId());
-                       //              
-                       // Platform.getExtensionRegistry().getE
-                       //              
-                       // IExtension extension =
-                       // Platform.getExtensionRegistry().getExtension(
-                       // "org.eclipse.ui.commands", command.getId());
-                       // log.debug("extension=" + extension);
-                       // String bundleSymbolicName = extension.getContributor().getName();
-
-                       // Assume that the defining bundle name is the first part of the
-                       // command
-                       // id
                        // TODO: make it more flexible and robust
-                       String commandId = event.getCommand().getId();
-                       String bundleSymbolicName = commandId.substring(0, commandId
-                                       .lastIndexOf('.'));
                        ApplicationContext applicationContext = ApplicationContextTracker
                                        .getApplicationContext(bundleSymbolicName);
 
@@ -84,8 +62,9 @@ public class SpringCommandHandler implements IHandler {
                        return handler.execute(event);
                } catch (Exception e) {
                        // TODO: use eclipse error management
-                       log.error(e);
-                       return null;
+//                     log.error(e);
+                       throw new ExecutionException("Cannot execute Spring command "
+                                       + commandId + " in bundle " + bundleSymbolicName, e);
                }
        }
 
index b995252f010345c6f814496e4eb9c9ccd78df199..50c1f3ca2ce59bc0ea75d65806b236c27e423784 100644 (file)
@@ -92,6 +92,7 @@
       <plugin id="org.eclipse.swt.gtk.linux.x86_64" fragment="true"/>
       <plugin id="org.eclipse.swt.win32.win32.x86" fragment="true"/>
       <plugin id="org.eclipse.ui"/>
+      <plugin id="org.eclipse.ui.forms"/>
       <plugin id="org.eclipse.ui.workbench"/>
       <plugin id="org.springframework.aop"/>
       <plugin id="org.springframework.beans"/>
diff --git a/security/eclipse/plugins/org.argeo.security.ui/icons/role.gif b/security/eclipse/plugins/org.argeo.security.ui/icons/role.gif
new file mode 100644 (file)
index 0000000..274a850
Binary files /dev/null and b/security/eclipse/plugins/org.argeo.security.ui/icons/role.gif differ
index 1a630dd178793da685ab2e879f54548f22196bc4..f15c4e7d95bdf436eb8f96abe6f7d066e50d4fde 100644 (file)
@@ -8,16 +8,14 @@ public class SecurityPerspective implements IPerspectiveFactory {
 
        public void createInitialLayout(IPageLayout layout) {
                String editorArea = layout.getEditorArea();
-               layout.setEditorAreaVisible(false);
+               layout.setEditorAreaVisible(true);
                layout.setFixed(false);
 
-               IFolderLayout main = layout.createFolder("main", IPageLayout.RIGHT,
-                               0.3f, editorArea);
                IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
                                0.3f, editorArea);
 
                left.addView("org.argeo.security.ui.usersView");
-               main.addView("org.argeo.security.ui.currentUserView");
+               left.addView("org.argeo.security.ui.currentUserView");
        }
 
 }
index fe5c0db0b1033134695f04795d740e61da507cfe..9e258a65f8dbcf2cf471adcb2422c3efc9e7051f 100644 (file)
@@ -3,6 +3,7 @@ package org.argeo.security.ui.editors;
 import org.argeo.ArgeoException;
 import org.argeo.security.ArgeoSecurityService;
 import org.argeo.security.ArgeoUser;
+import org.argeo.security.UserNature;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorSite;
@@ -27,7 +28,8 @@ public class ArgeoUserEditor extends FormEditor {
 
        protected void addPages() {
                try {
-                       addPage(new ArgeoUserMainPage(this, user));
+                       addPage(new DefaultUserMainPage(this, user));
+                               
                } catch (PartInitException e) {
                        throw new ArgeoException("Not able to add page ", e);
                }
diff --git a/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/ArgeoUserMainPage.java b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/ArgeoUserMainPage.java
deleted file mode 100644 (file)
index 3591d0b..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-package org.argeo.security.ui.editors;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.security.ArgeoUser;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.ColumnLayout;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * 
- * @author bsinou
- * 
- *         This page display main info of a specified Ebi. Roles enable the
- */
-public class ArgeoUserMainPage extends FormPage {
-       private final static Log log = LogFactory.getLog(ArgeoUserMainPage.class);
-
-       private ArgeoUser user;
-
-       private Text text;
-       private Combo combo;
-
-       public ArgeoUserMainPage(FormEditor editor, ArgeoUser user) {
-               super(editor, "argeoUserEditor.mainPage", "Main");
-               this.user = user;
-       }
-
-       protected void createFormContent(IManagedForm managedForm) {
-               try {
-                       ScrolledForm form = managedForm.getForm();
-
-                       // Set the title of the current form
-                       form.setText(user.toString());
-
-                       ColumnLayout mainLayout = new ColumnLayout();
-                       mainLayout.minNumColumns = 1;
-                       mainLayout.maxNumColumns = 4;
-
-                       mainLayout.topMargin = 0;
-                       mainLayout.bottomMargin = 5;
-                       mainLayout.leftMargin = mainLayout.rightMargin = mainLayout.horizontalSpacing = mainLayout.verticalSpacing = 10;
-                       form.getBody().setLayout(mainLayout);
-
-                       FormToolkit toolkit = managedForm.getToolkit();
-
-                       Composite body = toolkit.createComposite(form.getBody());
-                       GridLayout layout = new GridLayout();
-                       layout.marginWidth = layout.marginHeight = 0;
-                       layout.numColumns = 2;
-                       body.setLayout(layout);
-
-                       // Comments
-                       toolkit.createLabel(body, "Label1");
-                       text = toolkit.createText(body, user.getUsername(), SWT.WRAP
-                                       | SWT.BORDER);
-
-                       // Project Status
-                       // A combo Box
-                       toolkit.createLabel(body, "Statut du Projet");
-                       // TIP : we have to create a composite to wrap the combo box that
-                       // cannot be handled directly by the toolkit.
-                       Composite subBody = toolkit.createComposite(body);
-
-                       GridLayout subLayout = new GridLayout();
-                       subLayout.marginWidth = 3;
-                       layout.numColumns = 2;
-                       subBody.setLayout(subLayout);
-
-                       // The subBody fills 2 columns and a row
-                       GridData gd;
-                       gd = new GridData(GridData.FILL_BOTH);
-                       gd.horizontalSpan = 2;
-                       subBody.setLayoutData(gd);
-
-                       toolkit.adapt(subBody, true, true);
-
-                       toolkit.createLabel(body, "Some more text");
-                       toolkit.createLabel(body, "And Again");
-
-               } catch (Exception e) {
-                       e.printStackTrace();
-               }
-       }
-}
diff --git a/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/DefaultUserMainPage.java b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/DefaultUserMainPage.java
new file mode 100644 (file)
index 0000000..5495d18
--- /dev/null
@@ -0,0 +1,100 @@
+package org.argeo.security.ui.editors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.ArgeoException;
+import org.argeo.security.ArgeoUser;
+import org.argeo.security.UserNature;
+import org.argeo.security.nature.SimpleUserNature;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.ColumnLayout;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/**
+ * 
+ * @author bsinou
+ * 
+ *         This page display main info of a specified Ebi. Roles enable the
+ */
+public class DefaultUserMainPage extends FormPage {
+       private final static Log log = LogFactory.getLog(DefaultUserMainPage.class);
+
+       private ArgeoUser user;
+       private SimpleUserNature simpleNature;
+
+       private String simpleNatureType;
+
+       private Text email;
+       private Text description;
+
+       public DefaultUserMainPage(FormEditor editor, ArgeoUser user) {
+               super(editor, "argeoUserEditor.mainPage", "Main");
+               this.user = user;
+
+               if (simpleNatureType != null)
+                       simpleNature = (SimpleUserNature) user.getUserNatures().get(
+                                       simpleNatureType);
+               else
+                       for (UserNature userNature : user.getUserNatures().values())
+                               if (userNature instanceof SimpleUserNature)
+                                       simpleNature = (SimpleUserNature) userNature;
+
+               if (simpleNature == null)
+                       throw new ArgeoException("No simple user nature in user " + user);
+       }
+
+       protected void createFormContent(IManagedForm managedForm) {
+               try {
+                       ScrolledForm form = managedForm.getForm();
+
+                       // Set the title of the current form
+                       form.setText(simpleNature.getFirstName() + " "
+                                       + simpleNature.getLastName());
+
+                       ColumnLayout mainLayout = new ColumnLayout();
+                       mainLayout.minNumColumns = 1;
+                       mainLayout.maxNumColumns = 4;
+
+                       mainLayout.topMargin = 0;
+                       mainLayout.bottomMargin = 5;
+                       mainLayout.leftMargin = mainLayout.rightMargin = mainLayout.horizontalSpacing = mainLayout.verticalSpacing = 10;
+                       form.getBody().setLayout(mainLayout);
+
+                       FormToolkit toolkit = managedForm.getToolkit();
+
+                       Composite body = toolkit.createComposite(form.getBody());
+                       GridLayout layout = new GridLayout();
+                       layout.marginWidth = layout.marginHeight = 0;
+                       layout.numColumns = 2;
+                       body.setLayout(layout);
+
+                       // Comments
+                       toolkit.createLabel(body, "Username");
+                       toolkit.createLabel(body, user.getUsername());
+                       toolkit.createLabel(body, "Email");
+                       email = toolkit.createText(body, simpleNature.getEmail(), SWT.WRAP
+                                       | SWT.BORDER);
+                       toolkit.createLabel(body, "Description");
+                       description = toolkit.createText(body,
+                                       simpleNature.getDescription(), SWT.MULTI | SWT.WRAP
+                                                       | SWT.BORDER);
+
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+       public void setSimpleNatureType(String simpleNatureType) {
+               this.simpleNatureType = simpleNatureType;
+       }
+
+}
index 24a5a513cdfe6bd88663d6f8dfa325cdb2b324a8..d570105ee8f422feadb3f63e1a66c91222c7d30b 100644 (file)
@@ -27,6 +27,7 @@
                                        <include>plugin.xml</include>
                                        <include>META-INF/**</include>
                                        <include>jaas/**</include>
+                                       <include>icons/**</include>
                                </includes>
                        </resource>
                </resources>
diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/AbstractUserNature.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/AbstractUserNature.java
new file mode 100644 (file)
index 0000000..2a3e257
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.argeo.security;
+
+
+/** A set of specific data attached to a user. */
+public abstract class AbstractUserNature implements UserNature {
+       private static final long serialVersionUID = 1169323440459736478L;
+       
+       private String type;
+
+       public String getType() {
+               if (type != null)
+                       return type;
+               else
+                       return getClass().getName();
+       }
+
+       public void setType(String type) {
+               this.type = type;
+       }
+
+}
index 7156a93eaccd3a25a11dc0a0bb51a03ea186ce1e..f91e86748457669de1ce0cd31edcaae995f85742 100644 (file)
@@ -18,8 +18,12 @@ package org.argeo.security;
 
 import java.util.List;
 
+/**
+ * Access to the users and roles referential (dependent from the underlying
+ * storage, e.g. LDAP).
+ */
 public interface ArgeoSecurityDao {
-//     public ArgeoUser getCurrentUser();
+       // public ArgeoUser getCurrentUser();
 
        public List<ArgeoUser> listUsers();
 
@@ -40,6 +44,6 @@ public interface ArgeoSecurityDao {
        public ArgeoUser getUser(String username);
 
        public ArgeoUser getUserWithPassword(String username);
-       
+
        public String getDefaultRole();
 }
index 046c689fe040f269051f04e5fb9b66eb61aa7eb5..e6d8274b5b2fe6ba5d21500934407794c34718e0 100644 (file)
 
 package org.argeo.security;
 
+/**
+ * High level access to the user referential (independent from the underlying
+ * storage).
+ */
 public interface ArgeoSecurityService {
        public ArgeoUser getCurrentUser();
 
index d77a296471323823df912b94ec87bfa113e20366..30f52ed3b3df2d198e98815bb4eebbd32c2a96b6 100644 (file)
@@ -19,13 +19,14 @@ package org.argeo.security;
 import java.util.List;
 import java.util.Map;
 
+/** Abstraction for a user. */
 public interface ArgeoUser {
        public String getUsername();
 
-       public Map<String,UserNature> getUserNatures();
+       public Map<String, UserNature> getUserNatures();
 
        /** Implementation should refuse to add new user natures via this method. */
-       public void updateUserNatures(Map<String,UserNature> userNatures);
+       public void updateUserNatures(Map<String, UserNature> userNatures);
 
        public List<String> getRoles();
 
index 19c45dfbad0e0aeb7087272bb90cc28823894bc8..e736da8f4edfdb430e43117a03bede536aaa143b 100644 (file)
@@ -22,6 +22,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.argeo.ArgeoException;
+
 public class SimpleArgeoUser implements ArgeoUser, Serializable {
        private static final long serialVersionUID = 1L;
 
@@ -47,7 +49,44 @@ public class SimpleArgeoUser implements ArgeoUser, Serializable {
        }
 
        public void updateUserNatures(Map<String, UserNature> userNaturesData) {
-               UserNature.updateUserNaturesWithCheck(userNatures, userNaturesData);
+               updateUserNaturesWithCheck(userNatures, userNaturesData);
+       }
+
+       public static void updateUserNaturesWithCheck(
+                       Map<String, UserNature> userNatures,
+                       Map<String, UserNature> userNaturesData) {
+               // checks consistency
+               if (userNatures.size() != userNaturesData.size())
+                       throw new ArgeoException(
+                                       "It is forbidden to add or remove user natures via this method");
+
+               for (String type : userNatures.keySet()) {
+                       if (!userNaturesData.containsKey(type))
+                               throw new ArgeoException(
+                                               "Could not find a user nature of type " + type);
+               }
+
+               // for (int i = 0; i < userNatures.size(); i++) {
+               // String type = userNatures.get(i).getType();
+               // boolean found = false;
+               // for (int j = 0; j < userNatures.size(); j++) {
+               // String newType = userNaturesData.get(j).getType();
+               // if (type.equals(newType))
+               // found = true;
+               // }
+               // if (!found)
+               // throw new ArgeoException(
+               // "Could not find a user nature of type " + type);
+               // }
+
+               for (String key : userNatures.keySet()) {
+                       userNatures.put(key, userNaturesData.get(key));
+               }
+       }
+
+       @Override
+       public String toString() {
+               return username;
        }
 
        public List<String> getRoles() {
index 25710e40529021018fdf94fa1529b7bc42a3aa74..8931be2b002e35ffc5cdefa11643dea315828cee 100644 (file)
 package org.argeo.security;
 
 import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
 
-import org.argeo.ArgeoException;
-
-public class UserNature implements Serializable {
-       private static final long serialVersionUID = 1L;
-
-       private String type;
-
-       public String getType() {
-               if (type != null)
-                       return type;
-               else
-                       return getClass().getName();
-       }
-
-       public void setType(String type) {
-               this.type = type;
-       }
-
-       public final static void updateUserNaturesWithCheck(
-                       Map<String, UserNature> userNatures,
-                       Map<String, UserNature> userNaturesData) {
-               if (userNatures.size() != userNaturesData.size())
-                       throw new ArgeoException(
-                                       "It is forbidden to add or remove user natures via this method");
-               for (int i = 0; i < userNatures.size(); i++) {
-                       String type = userNatures.get(i).getType();
-                       boolean found = false;
-                       for (int j = 0; j < userNatures.size(); j++) {
-                               String newType = userNaturesData.get(j).getType();
-                               if (type.equals(newType))
-                                       found = true;
-                       }
-                       if (!found)
-                               throw new ArgeoException(
-                                               "Could not find a user nature of type " + type);
-               }
-
-               for (String key : userNatures.keySet()) {
-                       userNatures.put(key, userNaturesData.get(key));
-               }
-       }
+/**
+ * A set of specific data attached to a user. TODO: is this interface really
+ * useful?
+ */
+public interface UserNature extends Serializable {
+       @Deprecated
+       /** @deprecated will be removed soon*/
+       public String getType();
 }
index df16008e0da61607dd92c73d1d6dcb793aad2efa..1785357d589a253af76012de5ca29fc11a03fe97 100644 (file)
@@ -26,6 +26,7 @@ import org.apache.commons.logging.LogFactory;
 import org.argeo.security.ArgeoUser;
 import org.argeo.security.SimpleArgeoUser;
 import org.argeo.security.UserNature;
+import org.argeo.security.nature.SimpleUserNature;
 import org.springframework.security.Authentication;
 import org.springframework.security.GrantedAuthority;
 import org.springframework.security.GrantedAuthorityImpl;
@@ -40,9 +41,9 @@ public class ArgeoUserDetails extends User implements ArgeoUser {
        private final Map<String, UserNature> userNatures;
        private final List<String> roles;
 
-       public ArgeoUserDetails(String username, Map<String, UserNature> userNatures,
-                       String password, GrantedAuthority[] authorities)
-                       throws IllegalArgumentException {
+       public ArgeoUserDetails(String username,
+                       Map<String, UserNature> userNatures, String password,
+                       GrantedAuthority[] authorities) throws IllegalArgumentException {
                super(username, password, true, true, true, true, authorities);
                this.userNatures = Collections.unmodifiableMap(userNatures);
 
@@ -61,7 +62,8 @@ public class ArgeoUserDetails extends User implements ArgeoUser {
        }
 
        public void updateUserNatures(Map<String, UserNature> userNaturesData) {
-               UserNature.updateUserNaturesWithCheck(userNatures, userNaturesData);
+               SimpleArgeoUser
+                               .updateUserNaturesWithCheck(userNatures, userNaturesData);
        }
 
        public List<String> getRoles() {
index 494828343f8d5e9649c9ce67aad7867b8fe832d2..4f82889dc944c4ee261e0374ca89ad4cded380be 100644 (file)
@@ -26,7 +26,7 @@ public class DefaultArgeoSecurity implements ArgeoSecurity {
        public void beforeCreate(ArgeoUser user) {
                SimpleUserNature simpleUserNature = new SimpleUserNature();
                simpleUserNature.setLastName("empty");// to prevent issue with sn in LDAP
-               user.getUserNatures().put("simple",simpleUserNature);
+               user.getUserNatures().put("simpleUserNature",simpleUserNature);
        }
 
        public String getSuperUsername() {
index 12c8a333251f8f84fe0d41af677abbbc325f740a..459d5e5fc834989b43081c3271c5db673ae5f5c0 100644 (file)
@@ -31,6 +31,10 @@ import org.springframework.security.GrantedAuthority;
 import org.springframework.security.userdetails.UserDetails;
 import org.springframework.security.userdetails.ldap.UserDetailsContextMapper;
 
+/**
+ * Performs the mapping between LDAP and the user natures, using
+ * {@link UserNatureMapper}.
+ */
 public class ArgeoUserDetailsContextMapper implements UserDetailsContextMapper {
        // private final static Log log = LogFactory
        // .getLog(ArgeoUserDetailsContextMapper.class);
index 152731cfc8b13bdc6c3210a1fa3b8bd28af0f5a3..81d9f9129cd49c5211647a33970067ef82f614e5 100644 (file)
@@ -20,9 +20,10 @@ import org.argeo.security.UserNature;
 import org.springframework.ldap.core.DirContextAdapter;
 import org.springframework.ldap.core.DirContextOperations;
 
+/** Maps a user nature from LDAP. */
 public interface UserNatureMapper {
        public String getName();
-       
+
        public void mapUserInfoToContext(UserNature userInfo, DirContextAdapter ctx);
 
        public UserNature mapUserInfoFromContext(DirContextOperations ctx);
index 56da470056de67ba5184548140fac8ce4f709bb2..bc20c9db8026909b3352ac417b0448a1ccfdd26a 100644 (file)
@@ -24,7 +24,7 @@ import org.springframework.ldap.core.DirContextOperations;
 
 public class SimpleUserNatureMapper implements UserNatureMapper {
        public String getName() {
-               return "simpleUser";
+               return SimpleUserNature.TYPE;
        }
 
        public UserNature mapUserInfoFromContext(DirContextOperations ctx) {
index 7cc289eac649ea8f13f3c4b35b1945ade91c9cce..ac0503276e80acdff8f065f7f0d287728269e6ab 100644 (file)
@@ -16,9 +16,9 @@
 
 package org.argeo.security.nature;
 
-import org.argeo.security.UserNature;
+import org.argeo.security.AbstractUserNature;
 
-public class CoworkerNature extends UserNature {
+public class CoworkerNature extends AbstractUserNature {
        private static final long serialVersionUID = 1L;
        private String mobile;
        private String telephoneNumber;
index 408f2adb51ed79be537bdfaa77cda1ad39f0b19a..7d7723e33f599df7c320e42b80a3e50750e8814c 100644 (file)
 
 package org.argeo.security.nature;
 
-import org.argeo.security.UserNature;
+import org.argeo.security.AbstractUserNature;
+
+public class SimpleUserNature extends AbstractUserNature {
+       /**
+        * No PAI, for internal use within the Argeo Security framework. Will
+        * probably be removed.
+        */
+       public final static String TYPE = "simpleUser";
 
-public class SimpleUserNature extends UserNature {
        private static final long serialVersionUID = 1L;
        private String email;
        private String firstName;