/** * * @param dn the distinguished name of the entry - may be either relative to the base * context or a complete DN including the name of the context (either is supported). * @param username the user whose roles are required. * @return the granted authorities returned by the group search */ @SuppressWarnings("unchecked") List<GrantedAuthority> getUserAuthorities(final DistinguishedName dn, final String username) { SearchExecutor se = new SearchExecutor() { public NamingEnumeration<SearchResult> executeSearch(DirContext ctx) throws NamingException { DistinguishedName fullDn = LdapUtils.getFullDn(dn, ctx); SearchControls ctrls = new SearchControls(); ctrls.setReturningAttributes(new String[] { groupRoleAttributeName }); return ctx.search(groupSearchBase, groupSearchFilter, new String[] { fullDn.toUrl(), username }, ctrls); } }; AttributesMapperCallbackHandler roleCollector = new AttributesMapperCallbackHandler( roleMapper); template.search(se, roleCollector); return roleCollector.getList(); }
/** * Checks for valid query and context source objects.<br> * Executes the search.<br> * Returns the attribute map results from the query.<br> * * @see org.jasig.services.persondir.support.AbstractQueryPersonAttributeDao#getUserAttributesIfNeeded(java.lang.Object[]) */ @SuppressWarnings("unchecked") @Override protected Map<String, List<Object>> getUserAttributesIfNeeded(Object[] args) { final SearchExecutor se = new QuerySearchExecutor(this.baseDN, this.query, args, this.searchControls); final CollectingNameClassPairCallbackHandler attributesMapperCallbackHandler = new AttributesMapperCallbackHandler(this.attributesMapper); this.ldapTemplate.search(se, attributesMapperCallbackHandler); final List<Map<String, List<Object>>> results = attributesMapperCallbackHandler.getList(); return (Map<String, List<Object>>)DataAccessUtils.uniqueResult(results); }
/** * {@inheritDoc} */ @Override public <T> List<T> search(Name base, String filter, SearchControls controls, AttributesMapper<T> mapper, DirContextProcessor processor) { AttributesMapperCallbackHandler<T> handler = new AttributesMapperCallbackHandler<T>(mapper); search(base, filter, controls, handler, processor); return handler.getList(); }
/** * {@inheritDoc} */ @Override public <T> List<T> search(String base, String filter, SearchControls controls, AttributesMapper<T> mapper, DirContextProcessor processor) { AttributesMapperCallbackHandler<T> handler = new AttributesMapperCallbackHandler<T>(mapper); search(base, filter, controls, handler, processor); return handler.getList(); }
/** * {@inheritDoc} */ @Override public <T> List<T> search(Name base, String filter, SearchControls controls, AttributesMapper<T> mapper, DirContextProcessor processor) { AttributesMapperCallbackHandler<T> handler = new AttributesMapperCallbackHandler<T>(mapper); search(base, filter, controls, handler, processor); return handler.getList(); }
/** * {@inheritDoc} */ @Override public <T> List<T> search(String base, String filter, SearchControls controls, AttributesMapper<T> mapper, DirContextProcessor processor) { AttributesMapperCallbackHandler<T> handler = new AttributesMapperCallbackHandler<T>(mapper); search(base, filter, controls, handler, processor); return handler.getList(); }
/** * {@inheritDoc} */ @Override public <T> List<T> search(Name base, String filter, SearchControls controls, AttributesMapper<T> mapper, DirContextProcessor processor) { AttributesMapperCallbackHandler<T> handler = new AttributesMapperCallbackHandler<T>(mapper); search(base, filter, controls, handler, processor); return handler.getList(); }
/** * {@inheritDoc} */ @Override public <T> List<T> search(String base, String filter, SearchControls controls, AttributesMapper<T> mapper, DirContextProcessor processor) { AttributesMapperCallbackHandler<T> handler = new AttributesMapperCallbackHandler<T>(mapper); search(base, filter, controls, handler, processor); return handler.getList(); }
/** * {@inheritDoc} */ @Override public <T> List<T> search(String base, String filter, SearchControls controls, AttributesMapper<T> mapper, DirContextProcessor processor) { AttributesMapperCallbackHandler<T> handler = new AttributesMapperCallbackHandler<T>(mapper); search(base, filter, controls, handler, processor); return handler.getList(); }
/** * {@inheritDoc} */ @Override public <T> List<T> search(Name base, String filter, SearchControls controls, AttributesMapper<T> mapper, DirContextProcessor processor) { AttributesMapperCallbackHandler<T> handler = new AttributesMapperCallbackHandler<T>(mapper); search(base, filter, controls, handler, processor); return handler.getList(); }
/** * * @param dn the distinguished name of the entry - may be either relative to the base context * or a complete DN including the name of the context (either is supported). * @param username the user whose roles are required. * @return the granted authorities returned by the group search */ @SuppressWarnings("unchecked") List<GrantedAuthority> getUserAuthorities(final DistinguishedName dn, final String username) { SearchExecutor se = new SearchExecutor() { public NamingEnumeration<SearchResult> executeSearch(DirContext ctx) throws NamingException { DistinguishedName fullDn = LdapUtils.getFullDn(dn, ctx); SearchControls ctrls = new SearchControls(); ctrls.setReturningAttributes(new String[] {groupRoleAttributeName}); return ctx.search(groupSearchBase, groupSearchFilter, new String[] {fullDn.toUrl(), username}, ctrls); } }; AttributesMapperCallbackHandler roleCollector = new AttributesMapperCallbackHandler(roleMapper); template.search(se, roleCollector); return roleCollector.getList(); }
/** * * @param dn the distinguished name of the entry - may be either relative to the base * context or a complete DN including the name of the context (either is supported). * @param username the user whose roles are required. * @return the granted authorities returned by the group search */ @SuppressWarnings("unchecked") List<GrantedAuthority> getUserAuthorities(final DistinguishedName dn, final String username) { SearchExecutor se = new SearchExecutor() { public NamingEnumeration<SearchResult> executeSearch(DirContext ctx) throws NamingException { DistinguishedName fullDn = LdapUtils.getFullDn(dn, ctx); SearchControls ctrls = new SearchControls(); ctrls.setReturningAttributes(new String[] { groupRoleAttributeName }); return ctx.search(groupSearchBase, groupSearchFilter, new String[] { fullDn.toUrl(), username }, ctrls); } }; AttributesMapperCallbackHandler roleCollector = new AttributesMapperCallbackHandler( roleMapper); template.search(se, roleCollector); return roleCollector.getList(); }