]> git.argeo.org Git - lgpl/argeo-commons.git/blob - security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/ldap/SimpleUserNatureMapper.java
Explore JSon approach
[lgpl/argeo-commons.git] / security / runtime / org.argeo.security.core / src / main / java / org / argeo / security / ldap / SimpleUserNatureMapper.java
1 package org.argeo.security.ldap;
2
3 import org.argeo.security.UserNature;
4 import org.argeo.security.nature.SimpleUserNature;
5 import org.springframework.ldap.core.DirContextAdapter;
6 import org.springframework.ldap.core.DirContextOperations;
7
8 public class SimpleUserNatureMapper implements UserNatureMapper {
9
10 public UserNature mapUserInfoFromContext(DirContextOperations ctx) {
11 SimpleUserNature basicUserInfo = new SimpleUserNature();
12 basicUserInfo.setLastName(ctx.getStringAttribute("sn"));
13 basicUserInfo.setFirstName(ctx.getStringAttribute("givenName"));
14 basicUserInfo.setEmail(ctx.getStringAttribute("mail"));
15 return basicUserInfo;
16 }
17
18 public void mapUserInfoToContext(UserNature userInfoArg,
19 DirContextAdapter ctx) {
20 SimpleUserNature userInfo = (SimpleUserNature) userInfoArg;
21 ctx.setAttributeValue("cn", userInfo.getFirstName() + " "
22 + userInfo.getLastName());
23 ctx.setAttributeValue("sn", userInfo.getLastName());
24 ctx.setAttributeValue("givenName", userInfo.getFirstName());
25 ctx.setAttributeValue("mail", userInfo.getEmail());
26 }
27
28 public Boolean supports(UserNature userInfo) {
29 return userInfo instanceof SimpleUserNature;
30 }
31
32 }