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
.SimpleUserNature
;
6 import org
.springframework
.ldap
.core
.DirContextAdapter
;
7 import org
.springframework
.ldap
.core
.DirContextOperations
;
9 public class SimpleUserNatureMapper
implements UserNatureMapper
{
11 public UserNature
mapUserInfoFromContext(DirContextOperations ctx
) {
12 SimpleUserNature basicUserInfo
= new SimpleUserNature();
13 basicUserInfo
.setLastName(ctx
.getStringAttribute("sn"));
14 basicUserInfo
.setFirstName(ctx
.getStringAttribute("givenName"));
15 basicUserInfo
.setEmail(ctx
.getStringAttribute("mail"));
16 basicUserInfo
.setUuid(ctx
.getStringAttribute("seeAlso"));
20 public void mapUserInfoToContext(UserNature userInfoArg
,
21 DirContextAdapter ctx
) {
22 SimpleUserNature userInfo
= (SimpleUserNature
) userInfoArg
;
23 ctx
.setAttributeValue("cn", userInfo
.getFirstName() + " "
24 + userInfo
.getLastName());
25 ctx
.setAttributeValue("sn", userInfo
.getLastName());
26 ctx
.setAttributeValue("givenName", userInfo
.getFirstName());
27 ctx
.setAttributeValue("mail", userInfo
.getEmail());
28 // TODO: find a cleaner way?
29 ctx
.setAttributeValue("seeAlso", userInfo
.getUuid());
32 public Boolean
supports(UserNature userInfo
) {
33 return userInfo
instanceof SimpleUserNature
;