From dc6f911c680574a9b57c34dcf515ac8f9aa808da Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Thu, 20 Jan 2011 14:20:57 +0000 Subject: [PATCH] Introduce Argeo user edition git-svn-id: https://svn.argeo.org/commons/trunk@4058 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../eclipse/spring/SpringCommandHandler.java | 37 +++------- .../SecureRCP.product | 1 + .../org.argeo.security.ui/icons/role.gif | Bin 0 -> 563 bytes .../security/ui/SecurityPerspective.java | 6 +- .../security/ui/editors/ArgeoUserEditor.java | 4 +- ...MainPage.java => DefaultUserMainPage.java} | 68 ++++++++++-------- security/eclipse/plugins/pom.xml | 1 + .../argeo/security/AbstractUserNature.java | 37 ++++++++++ .../org/argeo/security/ArgeoSecurityDao.java | 8 ++- .../argeo/security/ArgeoSecurityService.java | 4 ++ .../java/org/argeo/security/ArgeoUser.java | 5 +- .../org/argeo/security/SimpleArgeoUser.java | 41 ++++++++++- .../java/org/argeo/security/UserNature.java | 51 +++---------- .../argeo/security/core/ArgeoUserDetails.java | 10 +-- .../security/core/DefaultArgeoSecurity.java | 2 +- .../ldap/ArgeoUserDetailsContextMapper.java | 4 ++ .../argeo/security/ldap/UserNatureMapper.java | 3 +- .../ldap/nature/SimpleUserNatureMapper.java | 2 +- .../argeo/security/nature/CoworkerNature.java | 4 +- .../security/nature/SimpleUserNature.java | 10 ++- 20 files changed, 174 insertions(+), 124 deletions(-) create mode 100644 security/eclipse/plugins/org.argeo.security.ui/icons/role.gif rename security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/{ArgeoUserMainPage.java => DefaultUserMainPage.java} (55%) create mode 100644 security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/AbstractUserNature.java diff --git a/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringCommandHandler.java b/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringCommandHandler.java index 1fb44c503..0356f57d2 100644 --- a/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringCommandHandler.java +++ b/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringCommandHandler.java @@ -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); } } diff --git a/security/eclipse/plugins/org.argeo.security.ui.application/SecureRCP.product b/security/eclipse/plugins/org.argeo.security.ui.application/SecureRCP.product index b995252f0..50c1f3ca2 100644 --- a/security/eclipse/plugins/org.argeo.security.ui.application/SecureRCP.product +++ b/security/eclipse/plugins/org.argeo.security.ui.application/SecureRCP.product @@ -92,6 +92,7 @@ + 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 index 0000000000000000000000000000000000000000..274a850e4d9b8deaa106f24b9a90f3bb959384dc GIT binary patch literal 563 zcmZ?wbhEHb6krfwc*elsmcGO*Yq@XUDxb`G33c1jnznZ@KD+(Mor3-YC6f+SOgq{% z=S185Qi?Ij z|6i&;6Au`2SMm{|nLoFGc^qHva#{rX3NNcrT2`U9tP+T{mbW;~PU2b89KNbM zVRd)nhDjM4CS`7!p4XFVHX+M;LYB?6Lg%T4&eIBA=2rU7sq|ga6dqz>@c;jRhQSRK zf3h$#FnBTOfSd`669)DP4PH&nO`>e9qAgv`JmS18-QC=xyv!53xtOMRaY_hJo9)FR zDJIOvIMIHUq@=KbAVaskoSclkh=>qBdzYQ8tcI+No$ZmMc1_mm2Il%|=hdXt)TPyI zygXFRJWaJU^$d-SEmc*myxf#^O>|V=>FHT$8@e|;D<~-{>AAQz{p)I~`SHNXL&MQQ MNG?W0Lx8~=0EiT{v;Y7A literal 0 HcmV?d00001 diff --git a/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/SecurityPerspective.java b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/SecurityPerspective.java index 1a630dd17..f15c4e7d9 100644 --- a/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/SecurityPerspective.java +++ b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/SecurityPerspective.java @@ -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"); } } diff --git a/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/ArgeoUserEditor.java b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/ArgeoUserEditor.java index fe5c0db0b..9e258a65f 100644 --- a/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/ArgeoUserEditor.java +++ b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/ArgeoUserEditor.java @@ -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/DefaultUserMainPage.java similarity index 55% rename from security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/ArgeoUserMainPage.java rename to security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/DefaultUserMainPage.java index 3591d0bb5..5495d18d2 100644 --- 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/DefaultUserMainPage.java @@ -2,7 +2,10 @@ 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; @@ -22,17 +25,31 @@ import org.eclipse.ui.forms.widgets.ScrolledForm; * * 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); +public class DefaultUserMainPage extends FormPage { + private final static Log log = LogFactory.getLog(DefaultUserMainPage.class); private ArgeoUser user; + private SimpleUserNature simpleNature; - private Text text; - private Combo combo; + private String simpleNatureType; - public ArgeoUserMainPage(FormEditor editor, ArgeoUser user) { + 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) { @@ -40,7 +57,8 @@ public class ArgeoUserMainPage extends FormPage { ScrolledForm form = managedForm.getForm(); // Set the title of the current form - form.setText(user.toString()); + form.setText(simpleNature.getFirstName() + " " + + simpleNature.getLastName()); ColumnLayout mainLayout = new ColumnLayout(); mainLayout.minNumColumns = 1; @@ -60,35 +78,23 @@ public class ArgeoUserMainPage extends FormPage { body.setLayout(layout); // Comments - toolkit.createLabel(body, "Label1"); - text = toolkit.createText(body, user.getUsername(), SWT.WRAP + toolkit.createLabel(body, "Username"); + toolkit.createLabel(body, user.getUsername()); + toolkit.createLabel(body, "Email"); + email = toolkit.createText(body, simpleNature.getEmail(), 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"); + 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; + } + } diff --git a/security/eclipse/plugins/pom.xml b/security/eclipse/plugins/pom.xml index 24a5a513c..d570105ee 100644 --- a/security/eclipse/plugins/pom.xml +++ b/security/eclipse/plugins/pom.xml @@ -27,6 +27,7 @@ plugin.xml META-INF/** jaas/** + icons/** 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 index 000000000..2a3e2579d --- /dev/null +++ b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/AbstractUserNature.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2010 Mathieu Baudier + * + * 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; + } + +} diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ArgeoSecurityDao.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ArgeoSecurityDao.java index 7156a93ea..f91e86748 100644 --- a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ArgeoSecurityDao.java +++ b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ArgeoSecurityDao.java @@ -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 listUsers(); @@ -40,6 +44,6 @@ public interface ArgeoSecurityDao { public ArgeoUser getUser(String username); public ArgeoUser getUserWithPassword(String username); - + public String getDefaultRole(); } diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ArgeoSecurityService.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ArgeoSecurityService.java index 046c689fe..e6d8274b5 100644 --- a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ArgeoSecurityService.java +++ b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ArgeoSecurityService.java @@ -16,6 +16,10 @@ package org.argeo.security; +/** + * High level access to the user referential (independent from the underlying + * storage). + */ public interface ArgeoSecurityService { public ArgeoUser getCurrentUser(); diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ArgeoUser.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ArgeoUser.java index d77a29647..30f52ed3b 100644 --- a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ArgeoUser.java +++ b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ArgeoUser.java @@ -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 getUserNatures(); + public Map getUserNatures(); /** Implementation should refuse to add new user natures via this method. */ - public void updateUserNatures(Map userNatures); + public void updateUserNatures(Map userNatures); public List getRoles(); diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/SimpleArgeoUser.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/SimpleArgeoUser.java index 19c45dfba..e736da8f4 100644 --- a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/SimpleArgeoUser.java +++ b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/SimpleArgeoUser.java @@ -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 userNaturesData) { - UserNature.updateUserNaturesWithCheck(userNatures, userNaturesData); + updateUserNaturesWithCheck(userNatures, userNaturesData); + } + + public static void updateUserNaturesWithCheck( + Map userNatures, + Map 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 getRoles() { diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/UserNature.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/UserNature.java index 25710e405..8931be2b0 100644 --- a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/UserNature.java +++ b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/UserNature.java @@ -17,48 +17,13 @@ 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 userNatures, - Map 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(); } diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/ArgeoUserDetails.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/ArgeoUserDetails.java index df16008e0..1785357d5 100644 --- a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/ArgeoUserDetails.java +++ b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/ArgeoUserDetails.java @@ -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 userNatures; private final List roles; - public ArgeoUserDetails(String username, Map userNatures, - String password, GrantedAuthority[] authorities) - throws IllegalArgumentException { + public ArgeoUserDetails(String username, + Map 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 userNaturesData) { - UserNature.updateUserNaturesWithCheck(userNatures, userNaturesData); + SimpleArgeoUser + .updateUserNaturesWithCheck(userNatures, userNaturesData); } public List getRoles() { diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/DefaultArgeoSecurity.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/DefaultArgeoSecurity.java index 494828343..4f82889dc 100644 --- a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/DefaultArgeoSecurity.java +++ b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/DefaultArgeoSecurity.java @@ -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() { diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/ArgeoUserDetailsContextMapper.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/ArgeoUserDetailsContextMapper.java index 12c8a3332..459d5e5fc 100644 --- a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/ArgeoUserDetailsContextMapper.java +++ b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/ArgeoUserDetailsContextMapper.java @@ -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); diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/UserNatureMapper.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/UserNatureMapper.java index 152731cfc..81d9f9129 100644 --- a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/UserNatureMapper.java +++ b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/UserNatureMapper.java @@ -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); diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/nature/SimpleUserNatureMapper.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/nature/SimpleUserNatureMapper.java index 56da47005..bc20c9db8 100644 --- a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/nature/SimpleUserNatureMapper.java +++ b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/nature/SimpleUserNatureMapper.java @@ -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) { diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/nature/CoworkerNature.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/nature/CoworkerNature.java index 7cc289eac..ac0503276 100644 --- a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/nature/CoworkerNature.java +++ b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/nature/CoworkerNature.java @@ -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; diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/nature/SimpleUserNature.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/nature/SimpleUserNature.java index 408f2adb5..7d7723e33 100644 --- a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/nature/SimpleUserNature.java +++ b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/nature/SimpleUserNature.java @@ -16,9 +16,15 @@ 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; -- 2.30.2