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

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


                                                          filter,
                                                          SearchScope.SUBTREE,
                                                          "*");
        final Iterator<Entry> it = entryCursor.iterator();
        if (it.hasNext()) {
            final Entry e = it.next();
            // for generic LDAP use the dn of the entry for the subsequent bind, active directory needs the userPrincipalName attribute (set below)
            if (!activeDirectory) {
                ldapEntry.setDn(e.getDn().getName());
            }

            for (Attribute attribute : e.getAttributes()) {
                if (activeDirectory && attribute.getId().equalsIgnoreCase("userPrincipalName")) {
                    ldapEntry.setDn(attribute.getString());
                }
                if (attribute.isHumanReadable()) {
                    ldapEntry.put(attribute.getId(), attribute.getString());
View Full Code Here


        {
            next( addContext );
            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 );
        }

        next( addContext );
    }
View Full Code Here

                    cursor.beforeFirst();
                    if ( cursor.next() ) // there should be only one!
                    {
                        LOG.debug( "Class {} found under {} search context.", name, base );
                        Entry classEntry = cursor.get();

                        if ( cursor.next() )
                        {
                            Entry other = cursor.get();
                            LOG.warn( "More than one class found on classpath at locations: {} \n\tand {}",
                                classEntry, other );
                        }

                        return classEntry.get( "javaClassByteCode" ).getBytes();
View Full Code Here

            // TODO we should cache this information and register with the event
            // service to get notified if this changes so we can update the cached
            // copy - there's absolutely no reason why we should be performing this
            // lookup every time!!!

            Entry configEntry = null;

            try
            {
                configEntry = directoryService.getAdminSession().lookup( defaultSearchDn );
            }
            catch ( LdapException e )
            {
                LOG.debug( "No configuration data found for class loader default search contexts." );
            }

            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

        assertEquals( SchemaConstants.STREET_AT_OID, evaluator.getAttributeType().getOid() );
        assertNotNull( evaluator.getNormalizer() );
        assertNotNull( evaluator.getComparator() );

        Dn dn = new Dn( schemaManager, "cn=jane doe,o=good times co." );
        Entry attrs = new DefaultEntry( schemaManager, dn );
        attrs.add( "objectClass", "person" );
        attrs.add( "c-street", "1" );
        attrs.add( "cn", "jane doe" );
        attrs.add( "sn", "doe" );
        attrs.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
        attrs.add( "entryUUID", Strings.getUUID( 12L ).toString() );

        AddOperationContext addContext = new AddOperationContext( null, attrs );
        ( ( Partition ) store ).add( addContext );

        indexEntry.setId( Strings.getUUID( 12L ) );
View Full Code Here

        Cursor<Entry> results = session.search( dn, SearchScope.SUBTREE, filter,
            AliasDerefMode.DEREF_ALWAYS );
       
        if ( results.first() )
        {
            Entry entry = results.get();
            results.close();

            return entry;
        }
View Full Code Here

    {
        if ( attributes instanceof BasicAttributes )
        {
            try
            {
                Entry entry = new DefaultEntry( schemaManager, dn );

                for ( NamingEnumeration<? extends javax.naming.directory.Attribute> attrs = attributes.getAll(); attrs
                    .hasMoreElements(); )
                {
                    javax.naming.directory.Attribute attr = attrs.nextElement();

                    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 );
                    }
                }

                return entry;
            }
View Full Code Here

     * @throws LdapException if there are problems accessing attributes
     */
    public static Entry getTargetEntry( Modification mod, Entry entry, SchemaManager schemaManager )
        throws LdapException
    {
        Entry targetEntry = entry.clone();
        ModificationOperation modOp = mod.getOperation();
        String id = mod.getAttribute().getUpId();
        AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id );

        switch ( modOp )
        {
            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 )
                    {
                        combined.add( value );
                    }
                }

                for ( Value<?> value : toBeAdded )
                {
                    combined.add( value );
                }

                targetEntry.put( combined );
                break;

            default:
                throw new IllegalStateException( I18n.err( I18n.ERR_464, modOp ) );
        }
View Full Code Here

        {
            return;
        }

        // for special handling of entryDN attribute, see DIRSERVER-1902
        Entry originalEntry = ( ( ClonedServerEntry ) entry ).getOriginalEntry();

        AttributeType entryDnType = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_DN_AT_OID );
       
        // First, remove all the attributes if we have the NoAtribute flag set to true
        if ( operationContext.isNoAttributes() )
View Full Code Here

    @Test
    @Ignore
    public void testAddPerf() throws Exception
    {
        Dn dn = new Dn( "cn=test,ou=system" );
        Entry entry = new DefaultEntry( getService().getSchemaManager(), dn,
            "ObjectClass: top",
            "ObjectClass: person",
            "sn: TEST",
            "cn: test" );

        connection.add( entry );

        int nbIterations = 8000;

        //BufferedWriter out = new BufferedWriter( new FileWriter("/tmp/out.txt") );

        long t0 = System.currentTimeMillis();
        long t00 = 0L;
        long tt0 = System.currentTimeMillis();

        for ( int i = 0; i < nbIterations; i++ )
        {
            if ( i % 1000 == 0 )
            {
                long tt1 = System.currentTimeMillis();

                System.out.println( i + ", " + ( tt1 - tt0 ) );
                tt0 = tt1;
            }

            if ( i == 500 )
            {
                t00 = System.currentTimeMillis();
            }

            dn = new Dn( "uid=" + i + ",dc=example,dc=com" );
            entry = new DefaultEntry(
                getService().getSchemaManager(),
                dn,
                "objectClass: top",
                "objectClass: person",
                "objectClass: organizationalPerson",
                "objectClass: inetOrgPerson",
                "uid",
                Integer.toString( i ),
                "mail: A-A-R.Awg-Rosli@acme.com",
                "title: Snr Operations Technician (D)",
                "sn: Awg-Rosli",
                "departmentNumber: SMDS - UIA/G/MMO52D",
                "cn: Awg-Rosli, Awg-Abd-Rahim SMDS-UIA/G/MMO52D",
                "description: UI - S",
                "telephoneNumber: 555-1212",
                "givenName: Awg-Abd-Rahim",
                "businessCategory: Ops MDS (Malaysia) Sdn Bhd",
                "displayName",
                i + "Awg-Rosli, Awg-Abd-Rahim SMDS-UIA/G/MMO52D",
                "employeeNumber: A-A-R.Awg-Rosli",
                "pwdPolicySubEntry: ads-pwdId=cproint,ou=passwordPolicies,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config" );

            //out.write( LdifUtils.convertToLdif( entry ) );
            connection.add( entry );
        }

        //out.flush();
        //out.close();

        long t1 = System.currentTimeMillis();

        Long deltaWarmed = ( t1 - t00 );
        System.out.println( "Delta : " + deltaWarmed + "( " + ( ( ( nbIterations - 500 ) * 1000 ) / deltaWarmed )
            + " per s ) /" + ( t1 - t0 ) );

        Entry entry1 = null;
        Entry entry2 = null;
        Entry entry3 = null;

        long ns0 = System.currentTimeMillis();
        EntryCursor results = connection.search( "dc=example,dc=com",
            "(displayName=1234Awg-Rosli, Awg-Abd-Rahim SMDS-UIA/G/MMO52D)", SearchScope.SUBTREE, "*" );

View Full Code Here

TOP

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

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.