• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AttributesMapper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.ldap.core.AttributesMapper的典型用法代码示例。如果您正苦于以下问题:Java AttributesMapper类的具体用法?Java AttributesMapper怎么用?Java AttributesMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AttributesMapper类属于org.springframework.ldap.core包,在下文中一共展示了AttributesMapper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
		}
	};
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:25,代码来源:LdapService.java


示例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));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:SpringLdapProducerTest.java


示例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;
}
 
开发者ID:geoserver,项目名称:geofence,代码行数:22,代码来源:LdapUtils.java


示例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;
			}
		});
	
}
 
开发者ID:CDS-INSPIRE,项目名称:InSpider,代码行数:25,代码来源:ManagerDaoImpl.java


示例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);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:17,代码来源:TestContextSourceFactoryBeanTest.java


示例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);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:17,代码来源:EmbeddedLdapServerFactoryBeanTest.java


示例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


示例16: testSearch_AttributesMapper_MultiValue

import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
/**
 * Demonstrates how to retrieve all values of a multi-value attribute.
 * 
 * @see LdapTemplateContextMapperITest#testSearch_ContextMapper_MultiValue()
 */
@Test
public void testSearch_AttributesMapper_MultiValue() throws Exception {
	AttributesMapper mapper = new AttributesMapper() {
		public Object mapFromAttributes(Attributes attributes) throws NamingException {
			LinkedList list = new LinkedList();
			NamingEnumeration enumeration = attributes.get("uniqueMember").getAll();
			while (enumeration.hasMoreElements()) {
				String value = (String) enumeration.nextElement();
				list.add(value);
			}
			String[] members = (String[]) list.toArray(new String[0]);
			return members;
		}
	};
	List result = tested.search("ou=groups", "(&(objectclass=groupOfUniqueNames)(cn=ROLE_USER))", mapper);

	assertThat(result).hasSize(1);

	assertThat(((String[]) result.get(0)).length).isEqualTo(4);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:26,代码来源:LdapTemplateAttributesMapperITest.java


示例17: testServerStartup

import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
@Test
  public void testServerStartup() throws Exception {
      ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/applicationContext.xml");
      LdapTemplate ldapTemplate = ctx.getBean(LdapTemplate.class);
      assertNotNull(ldapTemplate);

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();
			}
		});
      assertEquals(5, list.size());
  }
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:17,代码来源:EmbeddedLdapServerFactoryBeanTest.java


示例18: determineOwfGroups

import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
/**
 * Determine owf groups from the list of groups. Translates into OwfGroup
 * objects
 * 
 * @param dn
 *            the user's dn
 * @return GrantedAuthority array
 */
   @SuppressWarnings("unchecked")
protected Collection<OwfGroup> determineOwfGroups(final String dn) {
       return (Collection<OwfGroup>) ldapTemplate.search(searchBase, 
           //fill in the filter string
           MessageFormat.format(filter, LdapEncoder.filterEncode(dn + "," + contextSource.getBaseLdapPath().toString())),
               new AttributesMapper() {
                   public Object mapFromAttributes(Attributes attrs) throws NamingException {
                       //our sample ldap data does not include all of these fields
                       return new OwfGroupImpl((String)attrs.get("cn").get(), null, null, true);
                   }   
               });
}
 
开发者ID:ozoneplatform,项目名称:owf-security,代码行数:21,代码来源:OWFUserDetailsContextMapper.java


示例19: testLookup_AttributesMapper

import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
@Test
public void testLookup_AttributesMapper() {
	AttributesMapper mapper = new PersonAttributesMapper();
	Person person = (Person) tested.lookup("cn=Some Person2, ou=company1,ou=Sweden", mapper);

	assertThat(person.getFullname()).isEqualTo("Some Person2");
	assertThat(person.getLastname()).isEqualTo("Person2");
	assertThat(person.getDescription()).isEqualTo("Sweden, Company1, Some Person2");
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:10,代码来源:LdapTemplateLookupITest.java


示例20: testLookup_AttributesMapper_LdapName

import org.springframework.ldap.core.AttributesMapper; //导入依赖的package包/类
@Test
public void testLookup_AttributesMapper_LdapName() {
	AttributesMapper mapper = new PersonAttributesMapper();
	Person person = (Person) tested.lookup(LdapUtils.newLdapName("cn=Some Person2, ou=company1,ou=Sweden"), mapper);

	assertThat(person.getFullname()).isEqualTo("Some Person2");
	assertThat(person.getLastname()).isEqualTo("Person2");
	assertThat(person.getDescription()).isEqualTo("Sweden, Company1, Some Person2");
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:10,代码来源:LdapTemplateLookupITest.java



注:本文中的org.springframework.ldap.core.AttributesMapper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OWLClassExpression类代码示例发布时间:2022-05-21
下一篇:
Java WSDLReader类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap