当前位置: 首页>>代码示例>>Java>>正文


Java AndFilter.and方法代码示例

本文整理汇总了Java中org.springframework.ldap.filter.AndFilter.and方法的典型用法代码示例。如果您正苦于以下问题:Java AndFilter.and方法的具体用法?Java AndFilter.and怎么用?Java AndFilter.and使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.ldap.filter.AndFilter的用法示例。


在下文中一共展示了AndFilter.and方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: zzdeleteUser

import org.springframework.ldap.filter.AndFilter; //导入方法依赖的package包/类
@Test
public void zzdeleteUser() {
	initSpringSecurityContext("assist");
	Assert.assertEquals(1, resource.findAll("ing", null, "jdoe5", newUriInfo()).getData().size());
	Assert.assertNotNull(getUser().findByIdNoCache("jdoE5"));
	Assert.assertTrue(getGroup().findAll().get("dig rha").getMembers().contains("jdoe5"));
	resource.delete("jDOE5");
	Assert.assertEquals(0, resource.findAll("ing", null, "jdoe5", newUriInfo()).getData().size());
	Assert.assertNull(getUser().findByIdNoCache("jdoe5"));
	Assert.assertFalse(getGroup().findAll().get("dig rha").getMembers().contains("jdoe5"));

	final AndFilter filter = new AndFilter();
	filter.and(new EqualsFilter("objectclass", "groupOfUniqueNames"));
	filter.and(new EqualsFilter("cn", "dig rha"));
	final List<DirContextAdapter> groups = getTemplate().search("ou=groups,dc=sample,dc=com", filter.encode(),
			(Object ctx) -> (DirContextAdapter) ctx);
	Assert.assertEquals(1, groups.size());
	final DirContextAdapter group = groups.get(0);
	final String[] stringAttributes = group.getStringAttributes("uniqueMember");
	Assert.assertFalse(stringAttributes.length == 0);
	for (final String memberDN : stringAttributes) {
		Assert.assertFalse(memberDN.startsWith("uid=jdoe5"));
	}

	// Restore the state, create back the user
	initSpringSecurityContext(DEFAULT_USER);
	final UserOrgEditionVo user = new UserOrgEditionVo();
	user.setId("jdoe5");
	user.setFirstName("First5");
	user.setLastName("Last5");
	user.setCompany("ing-internal");
	final List<String> groups2 = new ArrayList<>();
	groups2.add("DIG RHA");
	user.setGroups(groups2);
	resource.create(user);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:37,代码来源:UserLdapResourceTest.java

示例2: getNextEntities

import org.springframework.ldap.filter.AndFilter; //导入方法依赖的package包/类
/**
 * 
 * @param searchBase
 *            The current search base.
 * @return The next entities or null, if this search base hasn't anymore entities.
 * @throws Exception
 *             Exception.
 */
@SuppressWarnings("unchecked")
private Collection<T> getNextEntities(LdapSearchBaseDefinition searchBase)
        throws Exception {
    final Name baseDN = new CompositeName(searchBase.getSearchBase());
    SearchControls searchControls = getSearchControl(searchBase.isSearchSubtree());
    AndFilter filter = new AndFilter();
    filter.and(new HardcodedFilter(getSearchFilter()));
    filter.and(new GreaterThanOrEqualsFilter(USN_ATTRIBUTE_KEY, Long
            .toString(internalHighestCommittedUSN + 1)));
    if (isPagingAllowed) {
        return pageSearchResults(baseDN, filter.encode(), searchControls);
    }
    if (noEntitiesLeft) {
        return null;
    }
    List<T> result = ldapTemplate.search(baseDN, filter.encode(), searchControls,
            getContextMapper());
    noEntitiesLeft = true;
    return result;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:29,代码来源:Retriever.java

示例3: search

import org.springframework.ldap.filter.AndFilter; //导入方法依赖的package包/类
@Override
public Collection<User> search(String query) {
    AndFilter filter = new AndFilter();
    filter.and(new EqualsFilter("objectclass", "person"));
    filter.and(new WhitespaceWildcardsFilter("cn", query));

    LdapQuery ldapQuery = LdapQueryBuilder
            .query()
            .base(baseDn)
            .countLimit(20)
            .timeLimit(5000)
            .searchScope(SearchScope.SUBTREE)
            .attributes(identifierAttribute, "givenname", "sn", "mail")
            .filter(filter);


    return ldapTemplate.search(ldapQuery, new UserAttributesMapper());
}
 
开发者ID:gravitee-io,项目名称:gravitee-management-rest-api,代码行数:19,代码来源:LdapIdentityLookup.java

示例4: findAllBy

import org.springframework.ldap.filter.AndFilter; //导入方法依赖的package包/类
@Override
public List<UserOrg> findAllBy(final String attribute, final String value) {
	final AndFilter filter = new AndFilter();
	filter.and(new EqualsFilter(OBJECT_CLASS, peopleClass));
	filter.and(new EqualsFilter(attribute, value));
	return template.search(peopleBaseDn, filter.encode(), mapper).stream().map(u -> Optional.ofNullable(findById(u.getId())).orElse(u))
			.collect(Collectors.toList());
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:9,代码来源:UserLdapRepository.java

示例5: getToken

import org.springframework.ldap.filter.AndFilter; //导入方法依赖的package包/类
@Override
public String getToken(final String login) {
	final AndFilter filter = new AndFilter();
	filter.and(new EqualsFilter(OBJECT_CLASS, peopleClass));
	filter.and(new EqualsFilter(uidAttribute, login));
	return template.search(peopleBaseDn, filter.encode(), new AbstractContextMapper<String>() {
		@Override
		public String doMapFromContext(final DirContextOperations context) {
			// Get the password
			return new String(ObjectUtils.defaultIfNull((byte[]) context.getObjectAttribute(PASSWORD_ATTRIBUTE), new byte[0]),
					StandardCharsets.UTF_8);
		}
	}).stream().findFirst().orElse(null);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:15,代码来源:UserLdapRepository.java

示例6: findByDepartment

import org.springframework.ldap.filter.AndFilter; //导入方法依赖的package包/类
@Override
public GroupOrg findByDepartment(final String department) {
	final AndFilter filter = new AndFilter();
	filter.and(new EqualsFilter("objectclass", GROUP_OF_UNIQUE_NAMES));
	filter.and(new EqualsFilter(DEPARTMENT_ATTRIBUTE, department));
	return template.search(groupsBaseDn, filter.encode(), (Object ctx) -> (DirContextAdapter) ctx).stream().findFirst()
			.map(c -> c.getStringAttribute("cn")).map(Normalizer::normalize).map(this::findById).orElse(null);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:9,代码来源:GroupLdapRepository.java

示例7: createEmptyDeleteWithParent

import org.springframework.ldap.filter.AndFilter; //导入方法依赖的package包/类
@Test
public void createEmptyDeleteWithParent() {
	final GroupEditionVo group = new GroupEditionVo();
	group.setDepartments(Collections.singletonList("SOME"));
	group.setOwners(Collections.singletonList("fdaugan"));
	group.setAssistants(Collections.singletonList("wuser"));
	group.setParent("DIG");

	createInternal(group, "cn=new-ax-1-z:z 0,cn=dig,ou=fonction,ou=groups,dc=sample,dc=com");

	// Check the group and its attributes
	final AndFilter filter = new AndFilter();
	filter.and(new EqualsFilter("objectclass", "groupOfUniqueNames"));
	filter.and(new EqualsFilter("cn", "New-Ax-1-z:Z 0"));
	final DirContextAdapter contextAdapter = getTemplate()
			.search("cn=DIG,ou=fonction,ou=groups,dc=sample,dc=com", filter.encode(), (Object ctx) -> (DirContextAdapter) ctx).get(0);
	Assert.assertEquals("uid=wuser,ou=ing,ou=external,ou=people,dc=sample,dc=com", contextAdapter.getObjectAttribute("seeAlso"));
	Assert.assertEquals("SOME", contextAdapter.getStringAttribute("businessCategory"));
	Assert.assertEquals("uid=fdaugan,ou=gfi,ou=france,ou=people,dc=sample,dc=com", contextAdapter.getStringAttribute("owner"));

	userResource.addUserToGroup("wuser", "New-Ax-1-z:Z 0");

	// Pre check
	final TableItem<ContainerCountVo> groups = resource.findAll(newUriInfoAscSearch("name", "New-Ax-1-z:Z 0"));
	Assert.assertEquals(1, groups.getRecordsTotal());
	Assert.assertEquals(1, groups.getData().get(0).getCount());

	resource.empty("New-Ax-1-z:Z 0");

	// Post check
	final TableItem<ContainerCountVo> groupsEmpty = resource.findAll(newUriInfoAscSearch("name", "New-Ax-1-z:Z 0"));
	Assert.assertEquals(1, groupsEmpty.getRecordsTotal());
	Assert.assertEquals(0, groupsEmpty.getData().get(0).getCount());

	resource.delete("New-Ax-1-z:Z 0");

	// Post check
	final TableItem<ContainerCountVo> groupsDelete = resource.findAll(newUriInfoAscSearch("name", "New-Ax-1-z:Z 0"));
	Assert.assertEquals(0, groupsDelete.getRecordsTotal());
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:41,代码来源:GroupLdapResourceTest.java

示例8: checkMember

import org.springframework.ldap.filter.AndFilter; //导入方法依赖的package包/类
/**
 * Check the uniqueMember is updated for the related groups
 */
private void checkMember(final String dn) {
	final AndFilter filter = new AndFilter();
	filter.and(new EqualsFilter("objectclass", "groupOfUniqueNames"));
	filter.and(new EqualsFilter("cn", "gfi-gStack"));
	final DirContextAdapter groupContext = getTemplate()
			.search("ou=gfi,ou=project,dc=sample,dc=com", filter.encode(), (Object ctx) -> (DirContextAdapter) ctx).get(0);
	final String[] members = groupContext.getStringAttributes("uniqueMember");
	Assert.assertEquals(1, members.length);
	Assert.assertEquals(dn, members[0]);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:14,代码来源:UserLdapResourceTest.java

示例9: getTagLogBySwissEduPersonCardUID

import org.springframework.ldap.filter.AndFilter; //导入方法依赖的package包/类
public TagLog getTagLogBySwissEduPersonCardUID(String cardUID, String cardUidType) {
	AndFilter filter = new AndFilter();
	filter.and(new EqualsFilter("objectclass", "person"));
	filter.and(new LikeFilter("swissEduPersonCardUID", cardUID + "@" + cardUidType));
	List<TagLog> tagLogs = ldapTemplate.search("", filter.encode(),
			new TagLogLdapAttributMapper(cardUidType));
	if(!tagLogs.isEmpty()) {
		log.info("Got ldap entry from : " + ((LdapContextSource)ldapTemplate.getContextSource()).getUrls() + "for this swissEduPersonCardUID " + cardUID + "@" + cardUidType);
		return tagLogs.get(0);
	} else {
		log.warn("Got NO ldap entry from : " + ((LdapContextSource)ldapTemplate.getContextSource()).getUrls() + "for this swissEduPersonCardUID " + cardUID + "@" + cardUidType);
		return null;
	}
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:15,代码来源:LdapService.java

示例10: retrieve

import org.springframework.ldap.filter.AndFilter; //导入方法依赖的package包/类
@Override
public User retrieve(String id) {
    AndFilter filter = new AndFilter();
    filter.and(new EqualsFilter("objectclass", "person"));
    filter.and(new EqualsFilter(identifierAttribute, id));

    LdapQuery ldapQuery = LdapQueryBuilder
            .query()
            .base(baseDn)
            .countLimit(1)
            .timeLimit(5000)
            .searchScope(SearchScope.SUBTREE)
            .attributes(identifierAttribute, "givenname", "sn", "mail")
            .filter(filter);

    List<User> users = ldapTemplate.search(ldapQuery, new UserAttributesMapper());
    if (users != null && ! users.isEmpty()) {
        LdapUser user = (LdapUser) users.iterator().next();
        List<String> result = ldapTemplate.search(
                baseDn, filter.encode(),
                (ContextMapper<String>) o -> ((LdapCtx) o).getNameInNamespace());
        user.setDn(result.iterator().next());

        return user;
    } else {
        return null;
    }
}
 
开发者ID:gravitee-io,项目名称:gravitee-management-rest-api,代码行数:29,代码来源:LdapIdentityLookup.java

示例11: update

import org.springframework.ldap.filter.AndFilter; //导入方法依赖的package包/类
private void update(LdapTemplate ldapTemplate, LdapAccountRefVO ref){
    String uid = ref.getLdapUid();

    AndFilter filter = new AndFilter();
    filter.and(new EqualsFilter("uid", ref.getLdapUid()));

    List<Object> result = ldapTemplate.search("", filter.toString(), new AbstractContextMapper<Object>() {
        @Override
        protected Object doMapFromContext(DirContextOperations ctx) {
            return ctx.getNameInNamespace();
        }
    });

    if(result.size() == 0){
        logger.error(String.format("Can not find ldapUid[%s] dn", uid));
        return;
    }

    if(result.size() > 1){
        logger.error(String.format("ldapUid[%s] More than one dn result", uid));
        return;
    }

    String dn = result.get(0).toString();
    ref.setLdapUid(dn);
    dbf.update(ref);
    logger.info(String.format("update ldapUid[%s] to ldapDn[%s] success", uid, dn));
}
 
开发者ID:zstackio,项目名称:zstack,代码行数:29,代码来源:LdapUpgradeExtension.java

示例12: testAddLdapServerConnection

import org.springframework.ldap.filter.AndFilter; //导入方法依赖的package包/类
private ErrorCode testAddLdapServerConnection(LdapServerInventory inv) {
    LdapTemplateContextSource ldapTemplateContextSource = new LdapUtil().loadLdap(inv);

    try {
        AndFilter filter = new AndFilter();
        // Any search conditions
        filter.and(new EqualsFilter(LdapConstant.LDAP_UID_KEY, ""));
        ldapTemplateContextSource.getLdapTemplate().authenticate("", filter.toString(), "");
        logger.info("LDAP connection was successful");
    } catch (Exception e) {
        logger.debug("Cannot connect to LDAP server", e);
        return operr("Cannot connect to LDAP server, %s", e.toString());
    }

    return null;
}
 
开发者ID:zstackio,项目名称:zstack,代码行数:17,代码来源:LdapApiInterceptor.java

示例13: tokenFilter

import org.springframework.ldap.filter.AndFilter; //导入方法依赖的package包/类
public Filter tokenFilter(final String token) {
	AndFilter filter = new AndFilter();
	for (String tok : token.split("\\p{Blank}")) {
		if (tok.length() > 0)
			filter.and(new WhitespaceWildcardsFilter(searchAttribute, tok));
	}
	return filter;
}
 
开发者ID:EsupPortail,项目名称:esup-smsu,代码行数:9,代码来源:LdapUtilsHelpers.java

示例14: andPagerAndConditionsAndService

import org.springframework.ldap.filter.AndFilter; //导入方法依赖的package包/类
public void andPagerAndConditionsAndService(final AndFilter filter,
		final String cgKeyName, final String service) {
	filter.and(new WhitespaceWildcardsFilter(userPagerAttribute, " "));
	if (cgKeyName != null) {
	    filter.and(new EqualsFilter(userTermsOfUseAttribute, cgKeyName));
	}
	if (service != null) {
		filter.and(new EqualsFilter(userTermsOfUseAttribute, service));
	}
}
 
开发者ID:EsupPortail,项目名称:esup-smsu,代码行数:11,代码来源:LdapUtilsHelpers.java

示例15: getLdapUsersFromPhoneNumber

import org.springframework.ldap.filter.AndFilter; //导入方法依赖的package包/类
/**
 * Search an user by the pager attribute and a token.
 * @param token
 */
public List<LdapUser> getLdapUsersFromPhoneNumber(final String token) {
	final AndFilter filter = new AndFilter();
	
	//add the pager filter
	filter.and(new WhitespaceWildcardsFilter(userPagerAttribute, token));	
			
	return searchWithFilter(filter);
}
 
开发者ID:EsupPortail,项目名称:esup-smsu,代码行数:13,代码来源:LdapUtilsHelpers.java


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