本文整理汇总了Java中org.springframework.ldap.core.AttributesMapper类的典型用法代码示例。如果您正苦于以下问题:Java AttributesMapper类的具体用法?Java AttributesMapper怎么用?Java AttributesMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributesMapper类属于org.springframework.ldap.core包,在下文中一共展示了AttributesMapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttributeMapper
import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
private AttributesMapper getAttributeMapper(final Object... baseArgs) {
return new AttributesMapper() {
@Override
public Object mapFromAttributes(Attributes attrs) throws NamingException {
LdapEntryVO entry = new LdapEntryVO();
entry.setUsername((String) attrs.get(USERNAME_ATTRIBUTE_ID).get());
DistinguishedName dn = new DistinguishedName(getBase(baseArgs));
dn.add(USERNAME_ATTRIBUTE_ID, entry.getUsername());
entry.setAbsoluteDn(dn.encode());
Map<String, Object> attributes = new LinkedHashMap<String, Object>();
if (searchResultAttributes != null) {
for (int i = 0; i < searchResultAttributes.length; i++) {
Attribute attr = attrs.get(searchResultAttributes[i]);
if (attr != null) {
attributes.put(searchResultAttributes[i], attr.get());
}
}
}
entry.setAttributes(attributes);
return entry;
}
};
}
示例2: testSearch
import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
@Test
public void testSearch() throws Exception {
String dn = "some dn";
String filter = "filter";
Integer scope = SearchControls.SUBTREE_SCOPE;
Exchange exchange = new DefaultExchange(context);
Message in = new DefaultMessage();
Map<String, Object> body = new HashMap<String, Object>();
body.put(SpringLdapProducer.DN, dn);
body.put(SpringLdapProducer.FILTER, filter);
when(ldapEndpoint.getOperation()).thenReturn(LdapOperation.SEARCH);
when(ldapEndpoint.scopeValue()).thenReturn(scope);
processBody(exchange, in, body);
verify(ldapTemplate).search(eq(dn), eq(filter), eq(scope),
any(AttributesMapper.class));
}
示例3: createLDAPFilter
import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
/**
* Creates and LDAP filter from the DAO search filter. Currently only "property = value" filters are supported.
*
* @param filter
* @return
*/
public static String createLDAPFilter(Filter filter, AttributesMapper mapper)
{
// TODO add other filter types
if (filter.getOperator() == Filter.OP_EQUAL) {
String propertyName = filter.getProperty();
if (mapper instanceof LdapAttributesMapper) {
propertyName = ((LdapAttributesMapper) mapper)
.getLdapAttribute(propertyName);
}
return propertyName + "=" + filter.getValue().toString();
} else {
LOGGER.error("MISSING IMPLEMENTATION FOR " + filter);
}
return null;
}
示例4: getUserDns
import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
/**
* Produces a set of DN's of all users that are a member of the CDS group in LDAP.
*
* @return The DN's of all members of the CDS group in LDAP.
*/
@SuppressWarnings("unchecked")
private Set<DistinguishedName> getUserDns () {
return (Set<DistinguishedName>)ldapTemplate.lookup (
getLdapGroupDn (),
new AttributesMapper () {
@Override
public Object mapFromAttributes (final Attributes attributes) throws NamingException {
final Attribute attribute = attributes.get ("member");
final Set<DistinguishedName> values = new HashSet<DistinguishedName> ();
for (int i = 0; i < attribute.size (); ++ i) {
values.add (new DistinguishedName (attribute.get (i).toString ()));
}
return values;
}
});
}
示例5: testServerStartup
import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
@Test
public void testServerStartup() throws Exception {
ctx = new ClassPathXmlApplicationContext("/applicationContext-testContextSource.xml");
LdapTemplate ldapTemplate = ctx.getBean(LdapTemplate.class);
assertThat(ldapTemplate).isNotNull();
List<String> list = ldapTemplate.search(
LdapQueryBuilder.query().where("objectclass").is("person"),
new AttributesMapper<String>() {
public String mapFromAttributes(Attributes attrs)
throws NamingException {
return (String) attrs.get("cn").get();
}
});
assertThat(list.size()).isEqualTo(5);
}
示例6: testServerStartup
import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
@Test
public void testServerStartup() throws Exception {
ctx = new ClassPathXmlApplicationContext("/applicationContext-ldifPopulator.xml");
LdapTemplate ldapTemplate = ctx.getBean(LdapTemplate.class);
assertThat(ldapTemplate).isNotNull();
List<String> list = ldapTemplate.search(
LdapQueryBuilder.query().where("objectclass").is("person"),
new AttributesMapper<String>() {
public String mapFromAttributes(Attributes attrs)
throws NamingException {
return (String) attrs.get("cn").get();
}
});
assertThat(list.size()).isEqualTo(5);
}
示例7: testUpdateWithException
import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
@Test
public void testUpdateWithException() {
String dn = "cn=Some Person,ou=company1,ou=Sweden";
try {
dummyDao.updateWithException(dn, "Some Person", "Updated Person", "Updated description");
fail("DummyException expected");
}
catch (DummyException expected) {
assertThat(true).isTrue();
}
log.debug("Verifying result");
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
public Object mapFromAttributes(Attributes attributes) throws NamingException {
assertThat(attributes.get("sn").get()).isEqualTo("Person");
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
return new Object();
}
});
assertThat(ldapResult).isNotNull();
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:24,代码来源:ContextSourceTransactionManagerIntegrationTest.java
示例8: testUpdate
import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
@Test
public void testUpdate() {
String dn = "cn=Some Person,ou=company1,ou=Sweden";
dummyDao.update(dn, "Some Person", "Updated Person", "Updated description");
log.debug("Verifying result");
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
public Object mapFromAttributes(Attributes attributes) throws NamingException {
assertThat(attributes.get("sn").get()).isEqualTo("Updated Person");
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
return new Object();
}
});
assertThat(ldapResult).isNotNull();
dummyDao.update(dn, "Some Person", "Person", "Sweden, Company1, Some Person");
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:19,代码来源:ContextSourceTransactionManagerIntegrationTest.java
示例9: testUpdateAndRename
import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
@Test
public void testUpdateAndRename() {
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
// Perform test
dummyDao.updateAndRename(dn, newDn, "Updated description");
// Verify that entry was moved and updated.
Object object = ldapTemplate.lookup(newDn, new AttributesMapper() {
public Object mapFromAttributes(Attributes attributes) throws NamingException {
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
return new Object();
}
});
assertThat(object).isNotNull();
dummyDao.updateAndRename(newDn, dn, "Sweden, Company1, Some Person2");
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:19,代码来源:ContextSourceTransactionManagerIntegrationTest.java
示例10: testModifyAttributesWithException
import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
@Test
public void testModifyAttributesWithException() {
String dn = "cn=Some Person,ou=company1,ou=Sweden";
try {
// Perform test
dummyDao.modifyAttributesWithException(dn, "Updated lastname", "Updated description");
fail("DummyException expected");
}
catch (DummyException expected) {
assertThat(true).isTrue();
}
// Verify result - check that the operation was properly rolled back
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
public Object mapFromAttributes(Attributes attributes) throws NamingException {
assertThat(attributes.get("sn").get()).isEqualTo("Person");
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
return new Object();
}
});
assertThat(result).isNotNull();
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:24,代码来源:ContextSourceTransactionManagerIntegrationTest.java
示例11: testModifyAttributes
import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
@Test
public void testModifyAttributes() {
String dn = "cn=Some Person,ou=company1,ou=Sweden";
// Perform test
dummyDao.modifyAttributes(dn, "Updated lastname", "Updated description");
// Verify result - check that the operation was not rolled back
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
public Object mapFromAttributes(Attributes attributes) throws NamingException {
assertThat(attributes.get("sn").get()).isEqualTo("Updated lastname");
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
return new Object();
}
});
assertThat(result).isNotNull();
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:18,代码来源:ContextSourceTransactionManagerIntegrationTest.java
示例12: testUnbindWithException
import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
@Test
public void testUnbindWithException() {
String dn = "cn=Some Person,ou=company1,ou=Sweden";
try {
// Perform test
dummyDao.unbindWithException(dn, "Some Person");
fail("DummyException expected");
}
catch (DummyException expected) {
assertThat(true).isTrue();
}
// Verify result - check that the operation was properly rolled back
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
public Object mapFromAttributes(Attributes attributes) throws NamingException {
// Just verify that the entry still exists.
return new Object();
}
});
assertThat(ldapResult).isNotNull();
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:23,代码来源:ContextSourceTransactionManagerIntegrationTest.java
示例13: testUpdate
import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
@Test
public void testUpdate() {
String dn = "cn=Some Person,ou=company1,ou=Sweden";
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, new Integer(1));
person.setLastname("Updated Person");
person.setDescription("Updated description");
dummyDao.update(person);
log.debug("Verifying result");
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
public Object mapFromAttributes(Attributes attributes) throws NamingException {
assertThat(attributes.get("sn").get()).isEqualTo("Updated Person");
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
return new Object();
}
});
OrgPerson updatedPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, new Integer(1));
assertThat(updatedPerson.getLastname()).isEqualTo("Updated Person");
assertThat(updatedPerson.getDescription()).isEqualTo("Updated description");
assertThat(ldapResult).isNotNull();
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:24,代码来源:ContextSourceAndHibernateTransactionManagerNamespaceITest.java
示例14: testUpdateAndRename
import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
@Test
public void testUpdateAndRename() {
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
// Perform test
dummyDao.updateAndRename(dn, newDn, "Updated description");
// Verify that entry was moved and updated.
Object object = ldapTemplate.lookup(newDn, new AttributesMapper() {
public Object mapFromAttributes(Attributes attributes) throws NamingException {
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
return new Object();
}
});
assertThat(object).isNotNull();
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:18,代码来源:ContextSourceAndHibernateTransactionManagerNamespaceITest.java
示例15: testModifyAttributes
import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
@Test
public void testModifyAttributes() {
String dn = "cn=Some Person,ou=company1,ou=Sweden";
// Perform test
dummyDao.modifyAttributes(dn, "Updated lastname", "Updated description");
// Verify result - check that the operation was not rolled back
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
public Object mapFromAttributes(Attributes attributes) throws NamingException {
assertThat(attributes.get("sn").get()).isEqualTo("Updated lastname");
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
return new Object();
}
});
assertThat(result).isNotNull();
dummyDao.update(dn, "Some Person", "Person", "Sweden, Company1, Some Person");
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:19,代码来源:ContextSourceAndDataSourceTransactionManagerNamespaceITest.java