Package org.springframework.ldap.filter

Examples of org.springframework.ldap.filter.AndFilter


            String user = props.getProperty("claimUser");
            Assert.notNull(user, "Property 'claimUser' not configured");

            String dn = null;

            AndFilter filter = new AndFilter();
            filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("cn", user));

            //find DN of user
            AttributesMapper mapper =
                new AttributesMapper() {
                    public Object mapFromAttributes(Attributes attrs) throws NamingException {
                        return attrs.get("distinguishedName").get();
                    }
                };
            @SuppressWarnings("rawtypes")
            List users =
                ldap.search(
                            "OU=users,DC=emea,DC=mycompany,DC=com",
                            filter.toString(),
                            SearchControls.SUBTREE_SCOPE,
                            mapper
                );

            Assert.isTrue(users.size() == 1, "Only one user expected");
View Full Code Here


            String user = props.getProperty("claimUser");
            Assert.notNull(user, "Property 'claimUser' not configured");

            String dn = null;

            AndFilter filter = new AndFilter();
            filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("cn", user));

            //find DN of user
            AttributesMapper mapper =
                new AttributesMapper() {
                    public Object mapFromAttributes(Attributes attrs) throws NamingException {
                        return attrs.get("distinguishedName").get();
                    }
                };
            @SuppressWarnings("rawtypes")
            List users =
                ldap.search(
                            "OU=users,DC=emea,DC=mycompany,DC=com",
                            filter.toString(),
                            SearchControls.SUBTREE_SCOPE,
                            mapper
                );

            Assert.isTrue(users.size() == 1, "Only one user expected");
View Full Code Here

    }


    private String getDnOfPrincipal(String principal) {
        String dn = null;
        AndFilter filter = new AndFilter();
        filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("cn", principal));

        //find DN of user
        AttributesMapper mapper =
            new AttributesMapper() {
                public Object mapFromAttributes(Attributes attrs) throws NamingException {
                    return attrs.get("distinguishedName").get();
                }
            };
        @SuppressWarnings("rawtypes")
        List users =
            ldap.search(this.userBaseDn, filter.toString(), SearchControls.SUBTREE_SCOPE, mapper);
        if (users.size() == 1) {
            dn = (String)users.get(0);
        }
        return dn;
    }
View Full Code Here

        dn.add(this.namingAttribute, service.getName());
        return new DirContextAdapter(dn);
    }

    protected Filter getSearchFilter(final Long id) {
        return new AndFilter().and(getLoadFilter()).and(new EqualsFilter(this.idAttribute, String.valueOf(id)));
    }
View Full Code Here

            if (LOG.isLoggable(Level.FINEST)) {
                LOG.finest("Retrieve claims for user " + user);
            }
        }
       
        AndFilter filter = new AndFilter();
        filter.and(
                new EqualsFilter("objectclass", this.getObjectClass())).and(
                        new EqualsFilter(this.getUserNameAttribute(), user));

        List<String> searchAttributeList = new ArrayList<String>();
        for (RequestClaim claim : claims) {
            if (getClaimsLdapAttributeMapping().keySet().contains(claim.getClaimType().toString())) {
                searchAttributeList.add(
                    getClaimsLdapAttributeMapping().get(claim.getClaimType().toString())
                );
            } else {
                if (LOG.isLoggable(Level.FINER)) {
                    LOG.finer("Unsupported claim: " + claim.getClaimType());
                }
            }
        }

        String[] searchAttributes = null;
        searchAttributes = searchAttributeList.toArray(new String[] {});

        AttributesMapper mapper =
            new AttributesMapper() {
                public Object mapFromAttributes(Attributes attrs) throws NamingException {
                    Map<String, Attribute> map = new HashMap<String, Attribute>();
                    NamingEnumeration<? extends Attribute> attrEnum = attrs.getAll();
                    while (attrEnum.hasMore()) {
                        Attribute att = attrEnum.next();
                        map.put(att.getID(), att);
                    }
                    return map;
                }
            };
       
       
        List<?> result = ldap.search((this.userBaseDn == null) ? "" : this.userBaseDn, filter.toString(),
                SearchControls.SUBTREE_SCOPE, searchAttributes, mapper);
     
        Map<String, Attribute> ldapAttributes = null;
        if (result != null && result.size() > 0) {
            ldapAttributes = CastUtils.cast((Map<?, ?>)result.get(0));
View Full Code Here

                    return map;
                }
            };
       
        List<?> result = null;
        AndFilter filter = new AndFilter();
        filter.and(
                new EqualsFilter("objectclass", objectClass)).and(
                        new EqualsFilter(filterAttributeName, filterAttributeValue));
       
        result = ldapTemplate.search((baseDN == null) ? "" : baseDN, filter.toString(),
            SearchControls.SUBTREE_SCOPE, searchAttributes, mapper);
        if (result != null && result.size() > 0) {
            ldapAttributes = CastUtils.cast((Map<?, ?>)result.get(0));
        }
       
View Full Code Here

            };
       
        String[] searchAttributes = new String[] {searchAttribute}
       
        List<?> result = null;
        AndFilter filter = new AndFilter();
        filter.and(
            new EqualsFilter("objectclass", objectClass)).and(
                new EqualsFilter(filterAttributeName, filterAttributeValue));

        result = ldapTemplate.search((baseDN == null) ? "" : baseDN, filter.toString(),
            SearchControls.SUBTREE_SCOPE, searchAttributes, mapper);
        if (result != null && result.size() > 0) {
            ldapAttributes = CastUtils.cast((List<?>)result);
        }
View Full Code Here

                public Object doMapFromContext(DirContextOperations ctx) {
                    return ctx.getDn();
                }
            };
       
        AndFilter filter = new AndFilter();
        filter.and(
            new EqualsFilter("objectclass", objectClass)).and(
                new EqualsFilter(filterAttributeName, filterAttributeValue));

        List<?> result = ldapTemplate.search((baseDN == null) ? "" : baseDN, filter.toString(),
            SearchControls.SUBTREE_SCOPE, mapper);
       
        if (result != null && result.size() > 0) {
            //not only the first one....
            return (Name)result.get(0);
View Full Code Here

            String user = props.getProperty("claimUser");
            Assert.notNull(user, "Property 'claimUser' not configured");

            String dn = null;

            AndFilter filter = new AndFilter();
            filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("cn", user));

            //find DN of user
            AttributesMapper mapper =
                new AttributesMapper() {
                    public Object mapFromAttributes(Attributes attrs) throws NamingException {
                        return attrs.get("distinguishedName").get();
                    }
                };
            @SuppressWarnings("rawtypes")
            List users =
                ldap.search(
                            "OU=users,DC=emea,DC=mycompany,DC=com",
                            filter.toString(),
                            SearchControls.SUBTREE_SCOPE,
                            mapper
                );

            Assert.isTrue(users.size() == 1, "Only one user expected");
View Full Code Here

    }


    private String getDnOfPrincipal(String principal) {
        String dn = null;
        AndFilter filter = new AndFilter();
        filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("cn", principal));

        //find DN of user
        AttributesMapper mapper =
            new AttributesMapper() {
                public Object mapFromAttributes(Attributes attrs) throws NamingException {
                    return attrs.get("distinguishedName").get();
                }
            };
        @SuppressWarnings("rawtypes")
        List users =
            ldap.search(this.userBaseDn, filter.toString(), SearchControls.SUBTREE_SCOPE, mapper);
        if (users.size() == 1) {
            dn = (String)users.get(0);
        }
        return dn;
    }
View Full Code Here

TOP

Related Classes of org.springframework.ldap.filter.AndFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.