]> git.argeo.org Git - lgpl/argeo-commons.git/blob - security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/nature/CoworkerUserNatureMapper.java
Add update user self service
[lgpl/argeo-commons.git] / security / runtime / org.argeo.security.core / src / main / java / org / argeo / security / ldap / nature / CoworkerUserNatureMapper.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.CoworkerNature;
6 import org.springframework.ldap.core.DirContextAdapter;
7 import org.springframework.ldap.core.DirContextOperations;
8
9 public class CoworkerUserNatureMapper implements UserNatureMapper {
10
11 public UserNature mapUserInfoFromContext(DirContextOperations ctx) {
12 CoworkerNature nature = new CoworkerNature();
13 nature.setDescription(ctx.getStringAttribute("description"));
14 nature.setMobile(ctx.getStringAttribute("mobile"));
15 nature.setTelephoneNumber(ctx.getStringAttribute("telephoneNumber"));
16
17 if (nature.getDescription() == null && nature.getMobile() == null
18 && nature.getTelephoneNumber() == null)
19 return null;
20 else
21 return nature;
22 }
23
24 public void mapUserInfoToContext(UserNature userInfoArg,
25 DirContextAdapter ctx) {
26 CoworkerNature nature = (CoworkerNature) userInfoArg;
27 if (nature.getDescription() != null) {
28 ctx.setAttributeValue("description", nature.getDescription());
29 }
30 if (nature.getMobile() == null || !nature.getMobile().equals("")) {
31 ctx.setAttributeValue("mobile", nature.getMobile());
32 }
33 if (nature.getTelephoneNumber() == null
34 || !nature.getTelephoneNumber().equals("")) {
35 ctx.setAttributeValue("telephoneNumber", nature
36 .getTelephoneNumber());
37 }
38 }
39
40 public Boolean supports(UserNature userNature) {
41 return userNature instanceof CoworkerNature;
42 }
43
44 }