Package org.apache.directory.shared.ldap.name

Examples of org.apache.directory.shared.ldap.name.DN


    /* (non-Javadoc)
     * @see org.apache.directory.server.core.partition.PartitionNexus#search(org.apache.directory.server.core.interceptor.context.SearchOperationContext)
     */
    public EntryFilteringCursor search( SearchOperationContext opContext ) throws Exception
    {
        DN base = opContext.getDn();
        SearchControls searchCtls = opContext.getSearchControls();
        ExprNode filter = opContext.getFilter();
       
        // 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 )
        {
            // We are searching from the rootDSE. We have to distinguish three cases :
            // 1) The scope is OBJECT : we have to return the rootDSE entry, filtered
            // 2) The scope is ONELEVEL : we have to return all the Namin
            boolean isObjectScope = searchCtls.getSearchScope() == SearchControls.OBJECT_SCOPE;
           
            boolean isOnelevelScope = searchCtls.getSearchScope() == SearchControls.ONELEVEL_SCOPE;
           
            boolean isSublevelScope = searchCtls.getSearchScope() == SearchControls.SUBTREE_SCOPE;
           
            // test for (objectClass=*)
            boolean isSearchAll = false;
           
            // We have to be careful, as we may have a filter which is not a PresenceFilter
            if ( filter instanceof PresenceNode )
            {
                isSearchAll = ( ( PresenceNode ) filter ).getAttribute().equals( SchemaConstants.OBJECT_CLASS_AT_OID );
            }
   
            /*
             * if basedn is "", filter is "(objectclass=*)" and scope is object
             * then we have a request for the rootDSE
             */
            if ( ( filter instanceof PresenceNode&& isObjectScope && isSearchAll )
            {
                return searchRootDSE( opContext );
            }
            else if ( isObjectScope && ( ! isSearchAll ) )
            {
                return new BaseEntryFilteringCursor( new EmptyCursor<ServerEntry>(), opContext );
            }
            else if( isOnelevelScope )
            {
                List<EntryFilteringCursor> cursors = new ArrayList<EntryFilteringCursor>();
                for ( Partition p : partitions.values() )
                {
                    opContext.setDn( p.getSuffixDn() );
                    opContext.setScope( SearchScope.OBJECT );
                    cursors.add( p.search( opContext ) );
                }
               
                return new CursorList( cursors, opContext );
            }
            else if ( isSublevelScope )
            {
                List<EntryFilteringCursor> cursors = new ArrayList<EntryFilteringCursor>();
                for ( Partition p : partitions.values() )
                {
                    ClonedServerEntry entry = p.lookup( new LookupOperationContext( directoryService.getAdminSession(), p.getSuffixDn() ) );
                    if( entry != null )
                    {
                        Partition backend = getPartition( entry.getDn() );
                        opContext.setDn( entry.getDn() );
                        cursors.add( backend.search( opContext ) );
                    }
                }
               
                // don't feed the above Cursors' list to a BaseEntryFilteringCursor it is skipping the naming context entry of each partition
                return new CursorList( cursors, opContext );
            }
   
            // TODO : handle searches based on the RootDSE
            throw new LdapNameNotFoundException();
        }
   
        base.normalize( schemaManager.getNormalizerMapping() );
        Partition backend = getPartition( base );
        return backend.search( opContext );
    }
View Full Code Here


            partition.initialize( );
        }
       
        synchronized ( partitionLookupTree )
        {
            DN partitionSuffix = partition.getSuffixDn();
           
            if ( partitionSuffix == null )
            {
                throw new ConfigurationException( I18n.err( I18n.ERR_267, partition.getId() ) );
            }
           
            partitions.put( partitionSuffix.getNormName(), partition );
            partitionLookupTree.add( partition.getSuffixDn(), partition );

            EntryAttribute namingContexts = rootDSE.get( SchemaConstants.NAMING_CONTEXTS_AT );

            if ( namingContexts == null )
            {
                namingContexts = new DefaultServerAttribute(
                    schemaManager.lookupAttributeTypeRegistry( SchemaConstants.NAMING_CONTEXTS_AT ), partitionSuffix.getName() );
                rootDSE.put( namingContexts );
            }
            else
            {
                namingContexts.add( partitionSuffix.getName() );
            }
        }
    }
View Full Code Here


    @Test
    public void testFreshStore() throws Exception
    {
        DN dn = new DN( "o=Good Times Co." );
        dn.normalize( schemaManager.getNormalizerMapping() );
        assertEquals( 1L, ( long ) store.getEntryId( dn.toNormName() ) );
        assertEquals( 11, store.count() );
        assertEquals( "o=Good Times Co.", store.getEntryUpdn( dn.toNormName() ) );
        assertEquals( dn.toNormName(), store.getEntryDn( 1L ) );
        assertEquals( dn.getName(), store.getEntryUpdn( 1L ) );

        // note that the suffix entry returns 0 for it's parent which does not exist
        assertEquals( 0L, ( long ) store.getParentId( dn.toNormName() ) );
        assertNull( store.getParentId( 0L ) );

        // should NOW be allowed
        store.delete( 1L );
    }
View Full Code Here

    /* (non-Javadoc)
     * @see org.apache.directory.server.core.partition.PartitionNexus#getMatchedName(org.apache.directory.server.core.interceptor.context.GetMatchedNameOperationContext)
     */
    public DN getMatchedName( GetMatchedNameOperationContext matchedNameContext ) throws Exception
    {
        DN dn = ( DN ) matchedNameContext.getDn().clone();
       
        while ( dn.size() > 0 )
        {
            if ( hasEntry( new EntryOperationContext( matchedNameContext.getSession(), dn ) ) )
            {
                return dn;
            }

            dn.remove( dn.size() - 1 );
        }

        return dn;
    }
View Full Code Here

     */
    private void checkIsValidMove( DN oldChildDn, DN newParentDn ) throws Exception
    {
        boolean invalid = false;

        DN newParentDNClone = ( DN ) newParentDn.clone();
        newParentDNClone.remove( newParentDNClone.size() - 1 );

        if ( newParentDn.size() >= oldChildDn.size() )
        {
            for ( int i = 0; i < oldChildDn.size(); i++ )
            {
View Full Code Here

            return;
        }
       
        try
        {
            DN newRdn = new DN( req.getNewRdn().toString() );
            newRdn.normalize( session.getCoreSession().getDirectoryService()
                .getSchemaManager().getNormalizerMapping() );
           
            DN oldRdn = new DN( req.getName().getRdn().toString() );
            oldRdn.normalize( session.getCoreSession().getDirectoryService()
                .getSchemaManager().getNormalizerMapping() );
           
            boolean rdnChanged = req.getNewRdn() != null &&
                ! newRdn.getNormName().equals( oldRdn.getNormName() );
           
            CoreSession coreSession = session.getCoreSession();
           
            if ( rdnChanged )
            {
View Full Code Here

            throw e;
        }
       
        CertGenerationObject certGenObj = container.getCertGenerationObject();
       
        ClonedServerEntry entry = session.getCoreSession().lookup( new DN( certGenObj.getTargetDN() ) );
        if( entry != null )
        {
            TlsKeyGenerator.addKeyPair( entry.getOriginalEntry(), certGenObj.getIssuerDN(), certGenObj.getSubjectDN(), certGenObj.getKeyAlgorithm() );
        }
    }
View Full Code Here

        if ( entry instanceof ClonedServerEntry )
        {
            throw new Exception( I18n.err( I18n.ERR_215 ) );
        }

        DN normName = entry.getDn();

        Long id;
        Long parentId;

        id = master.getNextId();

        //
        // Suffix entry cannot have a parent since it is the root so it is
        // capped off using the zero value which no entry can have since
        // entry sequences start at 1.
        //

        DN parentDn = null;

        if ( normName.getNormName().equals( suffixDn.getNormName() ) )
        {
            parentId = 0L;
        }
        else
        {
            parentDn = ( DN ) normName.clone();
            parentDn.remove( parentDn.size() - 1 );
            parentId = getEntryId( parentDn.getNormName() );
        }

        // don't keep going if we cannot find the parent Id
        if ( parentId == null )
        {
View Full Code Here

            return null;
        }

        try
        {
            return new DN( suffixDn.getNormName() );
        }
        catch ( InvalidNameException e )
        {
            // shouldn't happen
            LOG.error( "", e );
View Full Code Here

            return null;
        }

        try
        {
            return new DN( suffixDn.getName() );
        }
        catch ( InvalidNameException e )
        {
            // shouldn't happen
            LOG.error( "", e );
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.name.DN

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.