]> 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
Add update user self service
[lgpl/argeo-commons.git] / security / runtime / org.argeo.security.core / src / main / java / org / argeo / security / ldap / nature / SimpleUserNatureMapper.java
1 package org.argeo.security.ldap.nature;
2
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;
8
9 public class SimpleUserNatureMapper implements UserNatureMapper {
10
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 return nature;
17 }
18
19 public void mapUserInfoToContext(UserNature userInfoArg,
20 DirContextAdapter ctx) {
21 SimpleUserNature nature = (SimpleUserNature) userInfoArg;
22 ctx.setAttributeValue("cn", nature.getFirstName() + " "
23 + nature.getLastName());
24 ctx.setAttributeValue("sn", nature.getLastName());
25 ctx.setAttributeValue("givenName", nature.getFirstName());
26 ctx.setAttributeValue("mail", nature.getEmail());
27 }
28
29 public Boolean supports(UserNature userNature) {
30 return userNature instanceof SimpleUserNature;
31 }
32
33 }