1 package org
.argeo
.security
.ldap
;
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
;
8 public class SimpleUserNatureMapper
implements UserNatureMapper
{
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"));
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());
28 public Boolean
supports(UserNature userInfo
) {
29 return userInfo
instanceof SimpleUserNature
;