]>
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
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
.CoworkerNature
;
6 import org
.springframework
.ldap
.core
.DirContextAdapter
;
7 import org
.springframework
.ldap
.core
.DirContextOperations
;
9 public class CoworkerUserNatureMapper
implements UserNatureMapper
{
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"));
17 if (nature
.getDescription() == null && nature
.getMobile() == null
18 && nature
.getTelephoneNumber() == null)
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());
30 if (nature
.getMobile() == null || !nature
.getMobile().equals("")) {
31 ctx
.setAttributeValue("mobile", nature
.getMobile());
33 if (nature
.getTelephoneNumber() == null
34 || !nature
.getTelephoneNumber().equals("")) {
35 ctx
.setAttributeValue("telephoneNumber", nature
36 .getTelephoneNumber());
40 public Boolean
supports(UserNature userNature
) {
41 return userNature
instanceof CoworkerNature
;