X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=security%2Fruntime%2Forg.argeo.security.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fsecurity%2Fldap%2FArgeoUserDetailsContextMapper.java;h=03af0f49bd7d5c5268a423746eb7123d98725ac5;hb=490d9907457c43acfa965e7979ce5974bc1ba6ca;hp=d9b76a6c60c6234878d3c062f3c5b6e1d9e6ec9c;hpb=8220766ace9f3bde3a9d69890cd8307c34fe8ddd;p=lgpl%2Fargeo-commons.git 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 d9b76a6c6..03af0f49b 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 @@ -1,11 +1,25 @@ +/* + * 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.ldap; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.argeo.security.ArgeoUser; import org.argeo.security.UserNature; import org.argeo.security.core.ArgeoUserDetails; @@ -16,8 +30,8 @@ import org.springframework.security.userdetails.UserDetails; import org.springframework.security.userdetails.ldap.UserDetailsContextMapper; public class ArgeoUserDetailsContextMapper implements UserDetailsContextMapper { - private final static Log log = LogFactory - .getLog(ArgeoUserDetailsContextMapper.class); +// private final static Log log = LogFactory +// .getLog(ArgeoUserDetailsContextMapper.class); private List userNatureMappers = new ArrayList(); @@ -27,16 +41,15 @@ public class ArgeoUserDetailsContextMapper implements UserDetailsContextMapper { .first(); String password = new String(arr); - List userInfos = new ArrayList(); + List userNatures = new ArrayList(); for (UserNatureMapper userInfoMapper : userNatureMappers) { UserNature userNature = userInfoMapper.mapUserInfoFromContext(ctx); - if (log.isDebugEnabled()) - log.debug("Add user nature " + userNature); - userInfos.add(userNature); + if (userNature != null) + userNatures.add(userNature); } return new ArgeoUserDetails(username, Collections - .unmodifiableList(userInfos), password, authorities); + .unmodifiableList(userNatures), password, authorities); } public void mapUserToContext(UserDetails user, DirContextAdapter ctx) { @@ -45,11 +58,11 @@ public class ArgeoUserDetailsContextMapper implements UserDetailsContextMapper { ctx.setAttributeValue("userPassword", user.getPassword()); if (user instanceof ArgeoUser) { ArgeoUser argeoUser = (ArgeoUser) user; - for (UserNature userInfo : argeoUser.getUserNatures()) { + for (UserNature userNature : argeoUser.getUserNatures()) { for (UserNatureMapper userInfoMapper : userNatureMappers) { - if (userInfoMapper.supports(userInfo)) { - userInfoMapper.mapUserInfoToContext(userInfo, ctx); - break;// use the first mapper found an no others + if (userInfoMapper.supports(userNature)) { + userInfoMapper.mapUserInfoToContext(userNature, ctx); + break;// use the first mapper found and no others } } }