Package org.apache.directory.api.ldap.model.entry

Examples of org.apache.directory.api.ldap.model.entry.Attribute


        {
            Entry entry = session.lookup( config.getConfigEntryDn(), SchemaConstants.ADS_REPL_COOKIE );

            if ( entry != null )
            {
                Attribute attr = entry.get( REPL_COOKIE_AT );

                if ( attr != null )
                {
                    syncCookie = attr.getBytes();
                    lastSavedCookie = syncCookie;
                    String syncCookieString = Strings.utf8ToString( syncCookie );
                    CONSUMER_LOG.debug( "Loaded cookie {} for consumer {}", syncCookieString, config.getReplicaId() );
                }
                else
View Full Code Here


     */
    private void removeCookie()
    {
        try
        {
            Attribute cookieAttr = new DefaultAttribute( REPL_COOKIE_AT );
            Modification deleteCookieMod = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
                cookieAttr );
            session.modify( config.getConfigEntryDn(), deleteCookieMod );
            CONSUMER_LOG.info( "resetting sync cookie of the consumer with config entry Dn {}", config.getConfigEntryDn() );
        }
View Full Code Here

        List<Modification> mods = new ArrayList<Modification>();
        Iterator<Attribute> itr = localEntry.iterator();

        while ( itr.hasNext() )
        {
            Attribute localAttr = itr.next();
            String attrId = localAttr.getId();
            Modification mod;
            Attribute remoteAttr = remoteEntry.get( attrId );

            if ( remoteAttr != null ) // would be better if we compare the values also? or will it consume more time?
            {
                mod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, remoteAttr );
                remoteEntry.remove( remoteAttr );
View Full Code Here

        Entry clientEntry = new DefaultEntry( clonedEntry.getDn() );

        // Convert each attribute
        for ( Attribute clonedEntry : this )
        {
            Attribute clientAttribute = clonedEntry.clone();
            clientEntry.add( clientAttribute );
        }

        return clientEntry;
    }
View Full Code Here

                    req.getMessageId(), ResultCodeEnum.NO_SUCH_OBJECT, "Cannot find an entry for DN " + userDn ) );

                return;
            }
           
            Attribute at = userEntry.get( SchemaConstants.USER_PASSWORD_AT );
            if ( ( oldPassword != null ) && ( at != null ) )
            {
                for( Value<?> v : at )
                {
                    boolean equal = PasswordUtil.compareCredentials( oldPassword, v.getBytes() );
View Full Code Here

     * SyncState control.
     */
    private void sendSearchResultEntry( LdapSession session, SearchRequest req, Entry entry,
        SyncStateTypeEnum syncStateType ) throws Exception
    {
        Attribute uuid = entry.get( SchemaConstants.ENTRY_UUID_AT );

        // Create the SyncState control
        SyncStateValue syncStateControl = new SyncStateValueDecorator(
            ldapServer.getDirectoryService().getLdapCodecService() );
        syncStateControl.setSyncStateType( syncStateType );
        syncStateControl.setEntryUUID( Strings.uuidToBytes( uuid.getString() ) );

        if ( syncStateType == SyncStateTypeEnum.DELETE )
        {
            // clear the entry's all attributes except the Dn and entryUUID
            entry.clear();
View Full Code Here

    /**
     * Build the response to be sent to the client
     */
    private Response generateResponse( LdapSession session, SearchRequest req, Entry entry ) throws Exception
    {
        Attribute ref = entry.get( SchemaConstants.REF_AT );
        boolean hasManageDsaItControl = req.getControls().containsKey( ManageDsaIT.OID );

        if ( ( ref != null ) && !hasManageDsaItControl )
        {
            // The entry is a referral.
View Full Code Here

    }


    protected String getOid( Entry entry ) throws LdapException
    {
        Attribute oid = entry.get( m_oidAT );

        if ( oid == null )
        {
            return null;
        }

        return oid.getString();
    }
View Full Code Here

    private boolean hasCollectiveAttributes( List<Modification> mods ) throws LdapException
    {
        for ( Modification mod : mods )
        {
            // TODO: handle http://issues.apache.org/jira/browse/DIRSERVER-1198
            Attribute attr = mod.getAttribute();
            AttributeType attrType = attr.getAttributeType();

            // Defensive programming. Very unlikely to happen here...
            if ( attrType == null )
            {
                try
                {
                    attrType = schemaManager.lookupAttributeTypeRegistry( attr.getUpId() );
                }
                catch ( LdapException le )
                {
                    throw new LdapInvalidAttributeTypeException();
                }
View Full Code Here

    private void addCollectiveAttributes( FilteringOperationContext opContext, Entry entry )
        throws LdapException
    {
        CoreSession session = opContext.getSession();

        Attribute collectiveAttributeSubentries = ( ( ClonedServerEntry ) entry ).getOriginalEntry().get(
            COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT );

        /*
         * If there are no collective attribute subentries referenced then we
         * have no collective attributes to inject to this entry.
         */
        if ( collectiveAttributeSubentries == null )
        {
            return;
        }

        LOG.debug( "Filtering entry " + entry.getDn() );

        /*
         * Before we proceed we need to lookup the exclusions within the entry
         * and build a set of exclusions for rapid lookup.  We use OID values
         * in the exclusions set instead of regular names that may have case
         * variance.
         */
        Attribute collectiveExclusions = ( ( ClonedServerEntry ) entry ).getOriginalEntry().get(
            COLLECTIVE_EXCLUSIONS_AT );
        Set<AttributeType> exclusions = new HashSet<AttributeType>();

        if ( collectiveExclusions != null )
        {
            LOG.debug( "The entry has some exclusions : {}", collectiveExclusions );

            if ( collectiveExclusions.contains( SchemaConstants.EXCLUDE_ALL_COLLECTIVE_ATTRIBUTES_AT_OID )
                || collectiveExclusions.contains( SchemaConstants.EXCLUDE_ALL_COLLECTIVE_ATTRIBUTES_AT ) )
            {
                /*
                 * This entry does not allow any collective attributes
                 * to be injected into itself.
                 */
                LOG.debug( "The entry excludes all the collectiveAttributes" );

                return;
            }

            for ( Value<?> value : collectiveExclusions )
            {
                AttributeType attrType = schemaManager.lookupAttributeTypeRegistry( value.getString() );
                exclusions.add( attrType );
                LOG.debug( "Adding {} in the list of excluded collectiveAttributes", attrType.getName() );
            }
        }

        /*
         * For each collective subentry referenced by the entry we lookup the
         * attributes of the subentry and copy collective attributes from the
         * subentry into the entry.
         */
        for ( Value<?> value : collectiveAttributeSubentries )
        {
            String subentryDnStr = value.getString();
            Dn subentryDn = dnFactory.create( subentryDnStr );

            LOG.debug( "Applying subentries {}", subentryDn.getName() );

            /*
             * TODO - Instead of hitting disk here can't we leverage the
             * SubentryService to get us cached sub-entries so we're not
             * wasting time with a lookup here? It is ridiculous to waste
             * time looking up this sub-entry.
             */

            LookupOperationContext lookupContext = new LookupOperationContext( session, subentryDn,
                SchemaConstants.ALL_ATTRIBUTES_ARRAY );
            Entry subentry = directoryService.getPartitionNexus().lookup( lookupContext );

            //LOG.debug( "Fetched the subentry : {}", subentry.getDn().getName() );

            for ( Attribute attribute : subentry.getAttributes() )
            {
                AttributeType attributeType = attribute.getAttributeType();

                // Skip the attributes which are not collective
                if ( !attributeType.isCollective() )
                {
                    //LOG.debug( "The {} subentry attribute is not collective", attributeType.getName() );
                    continue;
                }

                /*
                 * Skip the addition of this collective attribute if it is excluded
                 * in the 'collectiveAttributes' attribute.
                 */
                if ( exclusions.contains( attributeType ) )
                {
                    LOG.debug( "The {} subentry attribute has been removed, it's in the exclusion list",
                        attributeType.getName() );
                    continue;
                }

                /*
                 * If not all attributes or this collective attribute requested specifically
                 * then bypass the inclusion process.
                 */
                if ( !opContext.isAllUserAttributes() && !opContext.contains( schemaManager, attributeType ) )
                {
                    LOG.debug( "The {} subentry attribute is not in the list of attributes to return",
                        attributeType.getName() );
                    continue;
                }

                Attribute subentryColAttr = subentry.get( attributeType );
                Attribute entryColAttr = entry.get( attributeType );

                /*
                 * If entry does not have attribute for collective attribute then create it.
                 */
                if ( entryColAttr == null )
                {
                    entryColAttr = new DefaultAttribute( attributeType );
                    entry.put( entryColAttr );
                }

                /*
                 *  Add all the collective attribute values in the subentry
                 *  to the currently processed collective attribute in the entry.
                 */
                for ( Value<?> subentryColVal : subentryColAttr )
                {
                    LOG.debug( "Adding the {} collective attribute into the entry", subentryColAttr );
                    entryColAttr.add( subentryColVal.getString() );
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.entry.Attribute

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.