]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/nature/SimpleUserNatureMapper.java
c9d1efd7a98c1ad038e2c13184d2af18bf50f98b
1 package org
.argeo
.security
.ldap
.nature
;
3 import org
.argeo
.security
.UserNature
;
4 import org
.argeo
.security
.ldap
.UserNatureMapper
;
5 import org
.argeo
.security
.nature
.SimpleUserNature
;
6 import org
.springframework
.ldap
.core
.DirContextAdapter
;
7 import org
.springframework
.ldap
.core
.DirContextOperations
;
9 public class SimpleUserNatureMapper
implements UserNatureMapper
{
11 public UserNature
mapUserInfoFromContext(DirContextOperations ctx
) {
12 SimpleUserNature nature
= new SimpleUserNature();
13 nature
.setLastName(ctx
.getStringAttribute("sn"));
14 nature
.setFirstName(ctx
.getStringAttribute("givenName"));
15 nature
.setEmail(ctx
.getStringAttribute("mail"));
16 nature
.setDescription(ctx
.getStringAttribute("description"));
20 public void mapUserInfoToContext(UserNature userInfoArg
,
21 DirContextAdapter ctx
) {
22 SimpleUserNature nature
= (SimpleUserNature
) userInfoArg
;
23 ctx
.setAttributeValue("cn", nature
.getFirstName() + " "
24 + nature
.getLastName());
25 ctx
.setAttributeValue("sn", nature
.getLastName());
26 ctx
.setAttributeValue("givenName", nature
.getFirstName());
27 ctx
.setAttributeValue("mail", nature
.getEmail());
28 if (nature
.getDescription() != null) {
29 ctx
.setAttributeValue("description", nature
.getDescription());
33 public Boolean
supports(UserNature userNature
) {
34 return userNature
instanceof SimpleUserNature
;