org.apache.directory.server.core.api.interceptor.context.SearchOperationContext Java Examples
The following examples show how to use
org.apache.directory.server.core.api.interceptor.context.SearchOperationContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultCoreSession.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public EntryFilteringCursor search( Dn dn, String filter, boolean ignoreReferrals ) throws LdapException { OperationManager operationManager = directoryService.getOperationManager(); ExprNode filterNode = null; try { filterNode = FilterParser.parse( directoryService.getSchemaManager(), filter ); } catch ( ParseException pe ) { throw new LdapInvalidSearchFilterException( pe.getMessage() ); } SearchOperationContext searchContext = new SearchOperationContext( this, dn, SearchScope.OBJECT, filterNode, ( String ) null ); searchContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS ); setReferralHandling( searchContext, ignoreReferrals ); return operationManager.search( searchContext ); }
Example #2
Source File: LDAPIAMPoller.java From aws-iam-ldap-bridge with Apache License 2.0 | 6 votes |
private Collection<Entry> getAllEntries(String rootDN, String className) { try { Dn dn = directory.getDnFactory().create(rootDN); dn.apply(directory.getSchemaManager()); ExprNode filter = FilterParser.parse(directory.getSchemaManager(), String.format("(ObjectClass=%s)", className)); NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( directory.getSchemaManager() ); FilterNormalizingVisitor visitor = new FilterNormalizingVisitor( ncn, directory.getSchemaManager() ); filter.accept(visitor); SearchOperationContext context = new SearchOperationContext(directory.getAdminSession(), dn, SearchScope.SUBTREE, filter, SchemaConstants.ALL_USER_ATTRIBUTES, SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES); EntryFilteringCursor cursor = directory.getPartitionNexus().search(context); cursor.beforeFirst(); Collection<Entry> entries = new ArrayList<Entry>(); while (cursor.next()) { Entry ent = cursor.get(); if (ent.getDn().equals(dn)) continue; entries.add(ent); } cursor.close(); return entries; } catch (Throwable e) { return Collections.emptyList(); } }
Example #3
Source File: DefaultCoreSession.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
public EntryFilteringCursor search( SearchRequest searchRequest ) throws LdapException { SearchOperationContext searchContext = new SearchOperationContext( this, searchRequest ); searchContext.setSyncreplSearch( searchRequest.getControls().containsKey( SyncRequestValue.OID ) ); OperationManager operationManager = directoryService.getOperationManager(); EntryFilteringCursor cursor = null; try { cursor = operationManager.search( searchContext ); } catch ( LdapException e ) { searchRequest.getResultResponse().addAllControls( searchContext.getResponseControls() ); throw e; } searchRequest.getResultResponse().addAllControls( searchContext.getResponseControls() ); return cursor; }
Example #4
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public EntryFilteringCursor search( SearchOperationContext searchContext ) throws LdapException { Dn base = searchContext.getDn(); // TODO since we're handling the *, and + in the EntryFilteringCursor // we may not need this code: we need see if this is actually the // case and remove this code. if ( base.size() == 0 ) { return searchFromRoot( searchContext ); } // Not sure we need this code... base.apply( schemaManager ); // Normal case : do a search on the specific partition Partition backend = getPartition( base ); return backend.search( searchContext ); }
Example #5
Source File: LDAPIAMPoller.java From aws-iam-ldap-bridge with Apache License 2.0 | 6 votes |
private void clearDN(String dnStr) throws LdapException, ParseException, IOException, CursorException { Dn dn = directory.getDnFactory().create(dnStr); dn.apply(directory.getSchemaManager()); ExprNode filter = FilterParser.parse(directory.getSchemaManager(), "(ObjectClass=*)"); NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( directory.getSchemaManager() ); FilterNormalizingVisitor visitor = new FilterNormalizingVisitor( ncn, directory.getSchemaManager() ); filter.accept(visitor); SearchOperationContext context = new SearchOperationContext(directory.getAdminSession(), dn, SearchScope.SUBTREE, filter, SchemaConstants.ALL_USER_ATTRIBUTES, SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES); EntryFilteringCursor cursor = directory.getPartitionNexus().search(context); cursor.beforeFirst(); Collection<Dn> dns = new ArrayList<Dn>(); while (cursor.next()) { Entry ent = cursor.get(); if (ent.getDn().equals(dn)) continue; dns.add(ent.getDn()); } cursor.close(); LOG.debug("Deleting " + dns.size() + " items from under " + dnStr); for (Dn deleteDn: dns) { directory.getAdminSession().delete(deleteDn); } }
Example #6
Source File: MyVDBaseCursor.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * Creates a new entry filtering Cursor over an existing Cursor using a * list of filters initially: more can be added later after creation. * * @param wrapped the underlying wrapped Cursor whose entries are filtered * @param operationContext the operation context that created this Cursor * @param invocation the search operation invocation creating this Cursor * @param filters a list of filters to be used */ public MyVDBaseCursor( Cursor<Entry> wrapped, SearchOperationContext operationContext, SchemaManager schemaManager, List<EntryFilter> filters ) { if ( IS_DEBUG ) { LOG_CURSOR.debug( "Creating MyVDBaseCursor {}", this ); } this.wrapped = wrapped; this.operationContext = operationContext; this.filters = new ArrayList<EntryFilter>(); this.filters.addAll( filters ); this.schemaManager = schemaManager; }
Example #7
Source File: MyVDBaseCursor.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * Creates a new entry filtering Cursor over an existing Cursor using a * list of filters initially: more can be added later after creation. * * @param wrapped the underlying wrapped Cursor whose entries are filtered * @param operationContext the operation context that created this Cursor * @param invocation the search operation invocation creating this Cursor * @param filters a list of filters to be used */ public MyVDBaseCursor( Cursor<Entry> wrapped, SearchOperationContext operationContext, SchemaManager schemaManager, List<EntryFilter> filters ) { if ( IS_DEBUG ) { LOG_CURSOR.debug( "Creating MyVDBaseCursor {}", this ); } this.wrapped = wrapped; this.operationContext = operationContext; this.filters = new ArrayList<EntryFilter>(); this.filters.addAll( filters ); this.schemaManager = schemaManager; }
Example #8
Source File: DefaultCoreSession.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public Cursor<Entry> search( Dn dn, String filter, boolean ignoreReferrals ) throws LdapException { OperationManager operationManager = directoryService.getOperationManager(); ExprNode filterNode = null; try { filterNode = FilterParser.parse( directoryService.getSchemaManager(), filter ); } catch ( ParseException pe ) { throw new LdapInvalidSearchFilterException( pe.getMessage() ); } SearchOperationContext searchContext = new SearchOperationContext( this, dn, SearchScope.OBJECT, filterNode, ( String ) null ); searchContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS ); setReferralHandling( searchContext, ignoreReferrals ); return operationManager.search( searchContext ); }
Example #9
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public EntryFilteringCursor search( SearchOperationContext searchContext ) throws LdapException { Dn base = searchContext.getDn(); // TODO since we're handling the *, and + in the EntryFilteringCursor // we may not need this code: we need see if this is actually the // case and remove this code. if ( base.size() == 0 ) { return searchFromRoot( searchContext ); } // Not sure we need this code... base.apply( schemaManager ); // Normal case : do a search on the specific partition Partition backend = getPartition( base ); return backend.search( searchContext ); }
Example #10
Source File: DefaultCoreSession.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
public Cursor<Entry> search( Dn dn, SearchScope scope, ExprNode filter, AliasDerefMode aliasDerefMode, String... returningAttributes ) throws LdapException { OperationManager operationManager = directoryService.getOperationManager(); SearchOperationContext searchContext = new SearchOperationContext( this, dn, scope, filter, returningAttributes ); searchContext.setAliasDerefMode( aliasDerefMode ); return operationManager.search( searchContext ); }
Example #11
Source File: NormalizationInterceptor.java From syncope with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public EntryFilteringCursor search( SearchOperationContext searchContext ) throws LdapException { Dn dn = searchContext.getDn(); if ( !dn.isSchemaAware() ) { searchContext.setDn( new Dn( schemaManager, dn ) ); } ExprNode filter = searchContext.getFilter(); if ( filter == null ) { LOG.warn( "undefined filter based on undefined attributeType not evaluted at all. Returning empty enumeration." ); return new EntryFilteringCursorImpl( new EmptyCursor<Entry>(), searchContext, schemaManager ); } // Normalize the filter filter = ( ExprNode ) filter.accept( normVisitor ); if ( filter == null ) { LOG.warn( "undefined filter based on undefined attributeType not evaluted at all. Returning empty enumeration." ); return new EntryFilteringCursorImpl( new EmptyCursor<Entry>(), searchContext, schemaManager ); } // We now have to remove the (ObjectClass=*) filter if it's present, and to add the scope filter ExprNode modifiedFilter = removeObjectClass( filter ); searchContext.setFilter( modifiedFilter ); // TODO Normalize the returned Attributes, storing the UP attributes to format the returned values. return next( searchContext ); }
Example #12
Source File: MyVDBaseCursor.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * Creates a new entry filtering Cursor over an existing Cursor using a * no filter initially: more can be added later after creation. * * @param wrapped the underlying wrapped Cursor whose entries are filtered * @param searchControls the controls of search that created this Cursor * @param invocation the search operation invocation creating this Cursor * @param filter a single filter to be used */ public MyVDBaseCursor( Cursor<Entry> wrapped, SearchOperationContext operationContext, SchemaManager schemaManager ) { if ( IS_DEBUG ) { LOG_CURSOR.debug( "Creating MyVDBaseCursor {}", this ); } this.wrapped = wrapped; this.operationContext = operationContext; this.filters = new ArrayList<EntryFilter>(); this.schemaManager = schemaManager; }
Example #13
Source File: SchemaInterceptor.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public boolean accept( SearchOperationContext operationContext, Entry entry ) throws LdapException { ServerEntryUtils.filterContents( schemaManager, operationContext, entry ); return true; }
Example #14
Source File: DefaultCoreSession.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
public EntryFilteringCursor list( Dn dn, AliasDerefMode aliasDerefMode, String... returningAttributes ) throws LdapException { OperationManager operationManager = directoryService.getOperationManager(); PresenceNode filter = new PresenceNode( OBJECT_CLASS_AT ); SearchOperationContext searchContext = new SearchOperationContext( this, dn, SearchScope.ONELEVEL, filter, returningAttributes ); searchContext.setAliasDerefMode( aliasDerefMode ); return operationManager.search( searchContext ); }
Example #15
Source File: DefaultCoreSession.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
public Cursor<Entry> list( Dn dn, AliasDerefMode aliasDerefMode, String... returningAttributes ) throws LdapException { OperationManager operationManager = directoryService.getOperationManager(); PresenceNode filter = new PresenceNode( OBJECT_CLASS_AT ); SearchOperationContext searchContext = new SearchOperationContext( this, dn, SearchScope.ONELEVEL, filter, returningAttributes ); searchContext.setAliasDerefMode( aliasDerefMode ); return operationManager.search( searchContext ); }
Example #16
Source File: MyVDBaseCursor.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * Creates a new entry filtering Cursor over an existing Cursor using a * no filter initially: more can be added later after creation. * * @param wrapped the underlying wrapped Cursor whose entries are filtered * @param searchControls the controls of search that created this Cursor * @param invocation the search operation invocation creating this Cursor * @param filter a single filter to be used */ public MyVDBaseCursor( Cursor<Entry> wrapped, SearchOperationContext operationContext, SchemaManager schemaManager ) { if ( IS_DEBUG ) { LOG_CURSOR.debug( "Creating MyVDBaseCursor {}", this ); } this.wrapped = wrapped; this.operationContext = operationContext; this.filters = new ArrayList<EntryFilter>(); this.schemaManager = schemaManager; }
Example #17
Source File: SchemaInterceptor.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public boolean accept( SearchOperationContext operationContext, Entry entry ) throws LdapException { ServerEntryUtils.filterContents( operationContext.getSession().getDirectoryService().getSchemaManager(), operationContext, entry ); return true; }
Example #18
Source File: DefaultCoreSession.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
public EntryFilteringCursor search( Dn dn, SearchScope scope, ExprNode filter, AliasDerefMode aliasDerefMode, String... returningAttributes ) throws LdapException { OperationManager operationManager = directoryService.getOperationManager(); SearchOperationContext searchContext = new SearchOperationContext( this, dn, scope, filter, returningAttributes ); searchContext.setAliasDerefMode( aliasDerefMode ); return operationManager.search( searchContext ); }
Example #19
Source File: MyVDBaseCursor.java From MyVirtualDirectory with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ public SearchOperationContext getOperationContext() { return operationContext; }
Example #20
Source File: MyVDBaseCursor.java From MyVirtualDirectory with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ public SearchOperationContext getOperationContext() { return operationContext; }
Example #21
Source File: RangedAttributeInterceptor.java From keycloak with Apache License 2.0 | 4 votes |
@Override public SearchOperationContext getOperationContext() { return c.getOperationContext(); }
Example #22
Source File: RangedAttributeInterceptor.java From keycloak with Apache License 2.0 | 4 votes |
@Override public EntryFilteringCursor search(SearchOperationContext sc) throws LdapException { Set<AttributeTypeOptions> attrs = sc.getReturningAttributes(); Integer lmin = null, lmax = max; if (attrs != null) { for (AttributeTypeOptions attr : attrs) { if (attr.getAttributeType().getName().equalsIgnoreCase(name)) { if (attr.getOptions() != null) { for (String option : attr.getOptions()) { if (option.startsWith("range=")) { String[] ranges = option.substring(6).split("-"); if (ranges.length == 2) { try { lmin = Integer.parseInt(ranges[0]); if (lmin < 0) { lmin = 0; } if ("*".equals(ranges[1])) { lmax = lmin + max; } else { lmax = Integer.parseInt(ranges[1]); if (lmax < lmin) { lmax = lmin; } else if (lmax > lmin + max) { lmax = lmin + max; } } } catch (NumberFormatException e) { lmin = null; lmax = max; } } } } } break; } } } return new RangedEntryFilteringCursor(super.next(sc), name, lmin, lmax); }
Example #23
Source File: MyVDBaseCursor.java From MyVirtualDirectory with Apache License 2.0 | 2 votes |
/** * Creates a new entry filtering Cursor over an existing Cursor using a * single filter initially: more can be added later after creation. * * @param wrapped the underlying wrapped Cursor whose entries are filtered * @param searchControls the controls of search that created this Cursor * @param invocation the search operation invocation creating this Cursor * @param filter a single filter to be used */ public MyVDBaseCursor( Cursor<Entry> wrapped, SearchOperationContext operationContext, SchemaManager schemaManager, EntryFilter filter ) { this( wrapped, operationContext, schemaManager, Collections.singletonList( filter ) ); }
Example #24
Source File: MyVDBaseCursor.java From MyVirtualDirectory with Apache License 2.0 | 2 votes |
/** * Creates a new entry filtering Cursor over an existing Cursor using a * single filter initially: more can be added later after creation. * * @param wrapped the underlying wrapped Cursor whose entries are filtered * @param searchControls the controls of search that created this Cursor * @param invocation the search operation invocation creating this Cursor * @param filter a single filter to be used */ public MyVDBaseCursor( Cursor<Entry> wrapped, SearchOperationContext operationContext, SchemaManager schemaManager, EntryFilter filter ) { this( wrapped, operationContext, schemaManager, Collections.singletonList( filter ) ); }