@Test public void testUserAttributesMapperDN() throws Exception { LdapUserAttributesMapper mapper = new LdapUserAttributesMapper(createTestLdapConfig( "DN:alias", "mail", "fn", "ln", "guid", "userPrincipalName")); String aliasValue1 = "peter_test"; String aliasValue2 = "petertest"; String aliasValue3 = "peter.test"; String emailValue = "test1@test.domain"; String fnValue = UUID.randomUUID().toString(); String lnValue = UUID.randomUUID().toString(); String uidValue = UUID.randomUUID().toString(); String upnValue = emailValue; BasicAttribute aliasAttribute = new BasicAttribute("alias", aliasValue1); aliasAttribute.add(aliasValue2); aliasAttribute.add(aliasValue3); Attributes attributes = new BasicAttributes(); attributes.put(aliasAttribute); attributes.put(new BasicAttribute("mail", emailValue)); attributes.put(new BasicAttribute("fn", fnValue)); attributes.put(new BasicAttribute("ln", lnValue)); attributes.put(new BasicAttribute("guid", uidValue)); attributes.put(new BasicAttribute("userPrincipalName", upnValue)); String userDN = "alias=" + aliasValue3 + ",ou=test,dc=communote,dc=com"; ExternalUserVO userVo = mapper.mapAttributes(userDN, attributes); Assert.assertNotNull(userVo); Assert.assertEquals(aliasValue3, userVo.getExternalUserName()); Assert.assertEquals(emailValue, userVo.getEmail()); Assert.assertEquals(fnValue, userVo.getFirstName()); Assert.assertEquals(lnValue, userVo.getLastName()); Assert.assertEquals(uidValue, userVo.getPermanentId()); Assert.assertEquals(userDN, userVo.getAdditionalProperty()); userDN = "ALIAS=" + aliasValue3 + " , ou=test,dc=communote,dc=com"; userVo = mapper.mapAttributes(userDN, attributes); Assert.assertNotNull(userVo); Assert.assertEquals(aliasValue3, userVo.getExternalUserName()); Assert.assertEquals(emailValue, userVo.getEmail()); Assert.assertEquals(fnValue, userVo.getFirstName()); Assert.assertEquals(lnValue, userVo.getLastName()); Assert.assertEquals(uidValue, userVo.getPermanentId()); Assert.assertEquals(userDN, userVo.getAdditionalProperty()); boolean mappingFailed = false; userDN = "ALIASAttribute=" + aliasValue3 + ",ou=test,dc=communote,dc=com"; try { userVo = mapper.mapAttributes(userDN, attributes); } catch (LdapAttributeMappingException e) { mappingFailed = true; } Assert.assertTrue(mappingFailed, "AttributesMappingException was not thrown."); StringPropertyTO[] properties = userVo.getProperties().toArray( new StringPropertyTO[userVo.getProperties().size()]); Assert.assertEquals(upnValue, properties[0].getPropertyValue()); }
public abstract T mapAttributes(String dn, Attributes ldapAttributes) throws LdapAttributeMappingException;
LdapAttributesMapper { public abstract T mapAttributes(String dn, Attributes ldapAttributes) throws LdapAttributeMappingException; }
LdapAttributesMapper { public abstract T mapAttributes(String dn, Attributes ldapAttributes) throws LdapAttributeMappingException; LdapAttributesMapper(Map<String, String> mapping);  LdapAttributesMapper(String mapping); }
LdapAttributesMapper { public abstract T mapAttributes(String dn, Attributes ldapAttributes) throws LdapAttributeMappingException; LdapAttributesMapper(Map<String, String> mapping);  LdapAttributesMapper(String mapping); abstract String[] getBinaryLdapAttributeName(); String getLdapAttributName(String name); String[] getMappedLdapAttributeNames(); String getMappingAsString(); boolean isKenmeiAttributeMapped(String communoteAttributeName); abstract T mapAttributes(String dn, Attributes ldapAttributes); }
LdapAttributesMapper { public abstract T mapAttributes(String dn, Attributes ldapAttributes) throws LdapAttributeMappingException; LdapAttributesMapper(Map<String, String> mapping);  LdapAttributesMapper(String mapping); abstract String[] getBinaryLdapAttributeName(); String getLdapAttributName(String name); String[] getMappedLdapAttributeNames(); String getMappingAsString(); boolean isKenmeiAttributeMapped(String communoteAttributeName); abstract T mapAttributes(String dn, Attributes ldapAttributes);  }