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

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


            return;
        }

        Entry entry = addContext.getEntry();

        Attribute pwdAt = entry.get( SchemaConstants.USER_PASSWORD_AT );

        Attribute hashedPwdAt = includeHashedPassword( pwdAt );
       
        if ( hashedPwdAt != null )
        {
            entry.remove( pwdAt );
            entry.add( hashedPwdAt );
View Full Code Here


                if ( mod.getOperation() == ModificationOperation.REMOVE_ATTRIBUTE )
                {
                   continue;
                }
               
                Attribute newPwd = includeHashedPassword( mod.getAttribute() );

                if ( newPwd != null )
                {
                    mod.setAttribute( newPwd );
                }
View Full Code Here

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

        Attribute newPwd = new DefaultAttribute( pwdAt.getAttributeType() );

        // Special case : deal with a potential empty value. We may have more than one
        for ( Value<?> userPassword : pwdAt )
        {
            if ( userPassword.getValue() == null )
            {
                continue;
            }

            // check if the given password is already hashed
            LdapSecurityConstants existingAlgo = PasswordUtil.findAlgorithm( ( ( BinaryValue ) userPassword )
                .getValue() );

            // if there exists NO algorithm, then hash the password
            if ( existingAlgo == null )
            {
                byte[] hashedPassword = PasswordUtil.createStoragePassword(
                    ( ( BinaryValue ) userPassword ).getValue(), algorithm );

                newPwd.add( hashedPassword );
            }
            else
            {
                newPwd.add( ( ( BinaryValue ) userPassword ).getValue() );
            }
        }

        return newPwd;
    }
View Full Code Here

            }

            if ( configEntry != null )
            {
                List<Dn> searchContexts = new ArrayList<Dn>();
                Attribute attr = configEntry.get( "classLoaderDefaultSearchContext" );

                for ( Value<?> val : attr )
                {
                    Dn dn = directoryService.getDnFactory().create( val.getString() );
                    searchContexts.add( dn );
View Full Code Here

        Attributes attributes = new BasicAttributes( true );

        for ( Attribute attribute : entry.getAttributes() )
        {
            AttributeType attributeType = attribute.getAttributeType();
            Attribute attr = entry.get( attributeType );

            // Deal with a special case : an entry without any ObjectClass
            if ( attributeType.getOid().equals( SchemaConstants.OBJECT_CLASS_AT_OID ) && attr.size() == 0 )
            {
                // We don't have any objectClass, just dismiss this element
                continue;
            }
View Full Code Here

            return null;
        }

        try
        {
            Attribute serverAttribute = new DefaultAttribute( attributeType );

            for ( NamingEnumeration<?> values = attribute.getAll(); values.hasMoreElements(); )
            {
                Object value = values.nextElement();
                int nbAdded = 0;

                if ( value == null )
                {
                    continue;
                }

                if ( serverAttribute.isHumanReadable() )
                {
                    if ( value instanceof String )
                    {
                        nbAdded = serverAttribute.add( ( String ) value );
                    }
                    else if ( value instanceof byte[] )
                    {
                        nbAdded = serverAttribute.add( Strings.utf8ToString( ( byte[] ) value ) );
                    }
                    else
                    {
                        throw new LdapInvalidAttributeTypeException();
                    }
                }
                else
                {
                    if ( value instanceof String )
                    {
                        nbAdded = serverAttribute.add( Strings.getBytesUtf8( ( String ) value ) );
                    }
                    else if ( value instanceof byte[] )
                    {
                        nbAdded = serverAttribute.add( ( byte[] ) value );
                    }
                    else
                    {
                        throw new LdapInvalidAttributeTypeException();
                    }
View Full Code Here

                    String attributeId = attr.getID();
                    String id = SchemaUtils.stripOptions( attributeId );
                    Set<String> options = SchemaUtils.getOptions( attributeId );
                    // TODO : handle options.
                    AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id );
                    Attribute serverAttribute = ServerEntryUtils.toServerAttribute( attr, attributeType );

                    if ( serverAttribute != null )
                    {
                        entry.put( serverAttribute );
                    }
View Full Code Here

            case REPLACE_ATTRIBUTE:
                targetEntry.put( mod.getAttribute() );
                break;

            case REMOVE_ATTRIBUTE:
                Attribute toBeRemoved = mod.getAttribute();

                if ( toBeRemoved.size() == 0 )
                {
                    targetEntry.removeAttributes( id );
                }
                else
                {
                    Attribute existing = targetEntry.get( id );

                    if ( existing != null )
                    {
                        for ( Value<?> value : toBeRemoved )
                        {
                            existing.remove( value );
                        }
                    }
                }
                break;

            case ADD_ATTRIBUTE:
                Attribute combined = new DefaultAttribute( id, attributeType );
                Attribute toBeAdded = mod.getAttribute();
                Attribute existing = entry.get( id );

                if ( existing != null )
                {
                    for ( Value<?> value : existing )
                    {
View Full Code Here

        else if ( !attr0.getAttributeType().equals( attr1.getAttributeType() ) )
        {
            throw new IllegalArgumentException( I18n.err( I18n.ERR_466 ) );
        }

        Attribute attr = attr0.clone();

        for ( Value<?> value : attr1 )
        {
            attr.add( value );
        }

        return attr;
    }
View Full Code Here

     */
    public static final Modification getModificationItem( List<Modification> mods, AttributeType type )
    {
        for ( Modification modification : mods )
        {
            Attribute attribute = modification.getAttribute();

            if ( attribute.getAttributeType() == type )
            {
                return modification;
            }
        }

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.