| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kim.ldap; |
| 17 | |
|
| 18 | |
import org.kuali.rice.kim.api.identity.CodedAttribute; |
| 19 | |
import org.kuali.rice.kim.api.identity.name.EntityName; |
| 20 | |
import org.kuali.rice.kim.util.Constants; |
| 21 | |
import org.springframework.ldap.core.DirContextOperations; |
| 22 | |
import org.springframework.ldap.core.support.AbstractContextMapper; |
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | 0 | public class EntityNameMapper extends AbstractContextMapper { |
| 29 | |
private Constants constants; |
| 30 | |
|
| 31 | |
public EntityName.Builder mapFromContext(DirContextOperations context, boolean isdefault) { |
| 32 | 0 | return (EntityName.Builder) doMapFromContext(context, isdefault); |
| 33 | |
} |
| 34 | |
|
| 35 | |
public EntityName.Builder mapFromContext(DirContextOperations context) { |
| 36 | 0 | return mapFromContext(context, true); |
| 37 | |
} |
| 38 | |
|
| 39 | |
public Object doMapFromContext(DirContextOperations context) { |
| 40 | 0 | return doMapFromContext(context, true); |
| 41 | |
} |
| 42 | |
|
| 43 | |
protected Object doMapFromContext(DirContextOperations context, boolean isdefault) { |
| 44 | 0 | final EntityName.Builder person = EntityName.Builder.create(); |
| 45 | 0 | person.setEntityId(context.getStringAttribute(getConstants().getKimLdapIdProperty())); |
| 46 | 0 | person.setId(context.getStringAttribute(getConstants().getKimLdapIdProperty())); |
| 47 | |
|
| 48 | 0 | final String fullName = (String) context.getStringAttribute(getConstants().getGivenNameLdapProperty()); |
| 49 | |
|
| 50 | 0 | if (fullName != null) { |
| 51 | 0 | final String[] name = fullName.split(" "); |
| 52 | 0 | person.setFirstName(name[0]); |
| 53 | 0 | if (name.length > 1) { |
| 54 | 0 | person.setMiddleName(name[1]); |
| 55 | |
} |
| 56 | 0 | } |
| 57 | |
else { |
| 58 | 0 | person.setFirstName(fullName); |
| 59 | |
} |
| 60 | |
|
| 61 | 0 | person.setLastName(context.getStringAttribute(getConstants().getSnLdapProperty())); |
| 62 | 0 | person.setDefaultValue(isdefault); |
| 63 | 0 | person.setActive(true); |
| 64 | 0 | person.setNameType(CodedAttribute.Builder.create("PRI")); |
| 65 | |
|
| 66 | 0 | return person; |
| 67 | |
} |
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
public final Constants getConstants() { |
| 75 | 0 | return this.constants; |
| 76 | |
} |
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
public final void setConstants(final Constants argConstants) { |
| 84 | 0 | this.constants = argConstants; |
| 85 | 0 | } |
| 86 | |
} |