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


Java AndFilter类代码示例

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


AndFilter类属于org.springframework.ldap.filter包,在下文中一共展示了AndFilter类的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: getUserGroups

import org.springframework.ldap.filter.AndFilter; //导入依赖的package包/类
/**
 *
 * @param realm
 *            The realm under which the user exists
 * @param userId
 *            The id of the user
 * @return List of roles assigned to this user
 */
public List<String> getUserGroups(String realm, String userId) {
    DistinguishedName dn = new DistinguishedName("ou=" + realm);
    AndFilter filter = new AndFilter();
    filter.and(new EqualsFilter("objectclass", groupObjectClass)).and(
            new EqualsFilter(groupSearchAttribute, userId));
    @SuppressWarnings("unchecked")
    List<String> groups = ldapTemplate.search(dn, filter.toString(), new GroupContextMapper());

    // map the roles in LDAP which are better suited for Posix systems to
    // the roles used by the API
    List<String> result = new LinkedList<String>();
    for (String group : groups) {
        result.add(LDAP_ROLE_MAPPING.containsKey(group) ? LDAP_ROLE_MAPPING.get(group) : group);
    }
    return result;
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:25,代码来源:UserService.java

示例5: getUser

import org.springframework.ldap.filter.AndFilter; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public User getUser(String realm, String uid) {
    AndFilter filter = new AndFilter();
    filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)).and(new EqualsFilter(userSearchAttribute, uid));
    DistinguishedName dn = new DistinguishedName("ou=" + realm);
    User user;
    try {
        List userList = ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] {
                "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper());
        if (userList == null || userList.size() == 0) {
            throw new EmptyResultDataAccessException(1);
        } else if (userList.size() > 1) {
            throw new IncorrectResultSizeDataAccessException("User must be unique", 1);
        }
        user = (User) userList.get(0);
        user.setUid(uid);
        user.setGroups(getGroupNames(getUserGroups(realm, uid)));
    } catch (EmptyResultDataAccessException e) {
        return null;
    }
    return user;
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:24,代码来源:LdapServiceImpl.java

示例6: testAuthenticateWithLookupOperationPerformedOnAuthenticatedContext

import org.springframework.ldap.filter.AndFilter; //导入依赖的package包/类
@Test
   @Category(NoAdTest.class)
public void testAuthenticateWithLookupOperationPerformedOnAuthenticatedContext() {
	AndFilter filter = new AndFilter();
	filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
	AuthenticatedLdapEntryContextCallback contextCallback = new AuthenticatedLdapEntryContextCallback() {
		public void executeWithContext(DirContext ctx, LdapEntryIdentification ldapEntryIdentification) {
			try {
				DirContextAdapter adapter = (DirContextAdapter) ctx.lookup(ldapEntryIdentification.getRelativeDn());
				assertThat(adapter.getStringAttribute("cn")).isEqualTo("Some Person3");
			}
			catch (NamingException e) {
				throw new RuntimeException("Failed to lookup " + ldapEntryIdentification.getRelativeDn(), e);
			}
		}
	};
	assertThat(tested.authenticate("", filter.toString(), "password", contextCallback)).isTrue();
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:19,代码来源:LdapTemplateAuthenticationITest.java

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

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

示例9: authenticate

import org.springframework.ldap.filter.AndFilter; //导入依赖的package包/类
@Override
public boolean authenticate(final String name, final String password) {
	log.info("Authenticating {} ...", name);
	final String property = getAuthenticateProperty(name);
	final AndFilter filter = new AndFilter().and(new EqualsFilter("objectclass", peopleClass)).and(new EqualsFilter(property, name));
	final boolean result = template.authenticate(peopleBaseDn, filter.encode(), password);
	log.info("Authenticate {} : {}", name, result);
	return result;
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:10,代码来源:UserLdapRepository.java

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

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

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

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

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

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


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