ExtendedLdapUserMapper extends LdapUserDetailsMapper { public void setPhoneNumberAttributeName(String phoneNumberAttributeName) { this.phoneNumberAttributeName = phoneNumberAttributeName; }  @Override UserDetails mapUserFromContext(DirContextOperations ctx, String username, Collection<? extends GrantedAuthority> authorities); String getMailAttributeName(); void setMailAttributeName(String mailAttributeName); String getPhoneNumberAttributeName(); void setPhoneNumberAttributeName(String phoneNumberAttributeName); String getGivenNameAttributeName(); void setGivenNameAttributeName(String givenNameAttributeName); String getFamilyNameAttributeName(); void setFamilyNameAttributeName(String familyNameAttributeName); String getMailSubstitute(); void setMailSubstitute(String mailSubstitute); boolean isMailSubstituteOverridesLdap(); void setMailSubstituteOverridesLdap(boolean mailSubstituteOverridesLdap); String getEmailVerifiedAttributeName(); void setEmailVerifiedAttributeName(String emailVerifiedAttributeName); static final String SUBSTITUTE_MAIL_ATTR_NAME; }
@Test public void testPhoneNumberAttributeNameMapping() throws Exception { attrs.put("phoneNumber", "8675309"); adapter = new DirContextAdapter(attrs, new LdapName("cn=marissa,ou=Users,dc=test,dc=com")); mapper.setPhoneNumberAttributeName("phoneNumber"); ExtendedLdapUserImpl ldapUserDetails = getExtendedLdapUser(); Assert.assertThat(ldapUserDetails.getPhoneNumber(), is("8675309")); }