Package org.apache.directory.shared.ldap.entry

Examples of org.apache.directory.shared.ldap.entry.EntryAttribute


        if ( !((ServerAttribute)objectClass).getAttributeType().equals( OBJECT_CLASS_AT ) )
        {
            return false;
        }
       
        EntryAttribute attribute = attributes.get( OBJECT_CLASS_AT );
       
        if ( attribute == null )
        {
            // The entry does not have an ObjectClass attribute
            return false;
        }
       
        for ( Value<?> value:objectClass )
        {
            // Loop on all the values, and check if they are present
            if ( !attribute.contains( value.getString() ) )
            {
                return false;
            }
        }
       
View Full Code Here


        if ( userEntry == null )
        {
            throw new LdapAuthenticationException( I18n.err( I18n.ERR_512, principalDn ) );
        }

        EntryAttribute objectClass = userEntry.getOriginalEntry().get( SchemaConstants.OBJECT_CLASS_AT );
       
        if ( !objectClass.contains( SchemaConstants.KRB5_PRINCIPAL_OC ) )
        {
            return;
        }
        else
        {
            subContext.isPrincipal( true );
            log.debug( "DN {} is a Kerberos principal.  Will attempt key derivation.", principalDn.getName() );
        }

        if ( subContext.getPrincipalName() == null )
        {
            EntryAttribute principalAttribute = userEntry.getOriginalEntry().get( KerberosAttribute.KRB5_PRINCIPAL_NAME_AT );
            String principalName = principalAttribute.getString();
            subContext.setPrincipalName( principalName );
            log.debug( "Found principal '{}' from lookup.", principalName );
        }

        EntryAttribute keyVersionNumberAttr = userEntry.getOriginalEntry().get( KerberosAttribute.KRB5_KEY_VERSION_NUMBER_AT );

        if ( keyVersionNumberAttr == null )
        {
            subContext.setNewKeyVersionNumber( 0 );
            log.debug( "Key version number was null, setting to 0." );
        }
        else
        {
            int oldKeyVersionNumber = Integer.valueOf( keyVersionNumberAttr.getString() );
            int newKeyVersionNumber = oldKeyVersionNumber + 1;
            subContext.setNewKeyVersionNumber( newKeyVersionNumber );
            log.debug( "Found key version number '{}', setting to '{}'.", oldKeyVersionNumber, newKeyVersionNumber );
        }
    }
View Full Code Here

        while ( list.next() )
        {
            ServerEntry result = list.get();

            String name = null;
            EntryAttribute attribute = result.get( ApacheSchemaConstants.APACHE_CATALOGUE_ENTRY_NAME_AT );
           
            if ( attribute != null )
            {
                name = attribute.getString();
            }
           
            String basedn = null;
            attribute = result.get( ApacheSchemaConstants.APACHE_CATALOGUE_ENTRY_BASE_DN_AT );
           
            if ( attribute != null )
            {
                basedn = attribute.getString();
            }
           

            catalog.put( name, basedn );
        }
View Full Code Here

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

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

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

     * @return the response for the entry
     * @throws Exception if there are problems in generating the response
     */
    private InternalResponse generateResponse( LdapSession session, InternalSearchRequest req, ClonedServerEntry entry ) throws Exception
    {
        EntryAttribute ref = entry.getOriginalEntry().get( SchemaConstants.REF_AT );
        boolean hasManageDsaItControl = req.getControls().containsKey( ManageDsaITControl.CONTROL_OID );

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

        result.setReferral( referral );
        result.setResultCode( ResultCodeEnum.REFERRAL );
        result.setErrorMessage( "Encountered referral attempting to handle request." );
        result.setMatchedDn( req.getBase() );

        EntryAttribute refAttr = entry.getOriginalEntry().get( SchemaConstants.REF_AT );
       
        for ( Value<?> refval : refAttr )
        {
            String refstr = refval.getString();
           
View Full Code Here

    @Test
    public void testHasObjectClassEntryAttribute() throws Exception
    {
        ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
       
        EntryAttribute attrOC = new DefaultServerAttribute( atOC, "top", "person" );
       
        assertFalse( entry.contains( attrOC ) );
        assertFalse( entry.hasObjectClass( attrOC ) );
       
        entry.add( attrOC );
       
        assertTrue( entry.hasObjectClass( attrOC ) );

        EntryAttribute attrOC2 = new DefaultServerAttribute( atOC, "person" );
        assertTrue( entry.hasObjectClass( attrOC2 ) );

        EntryAttribute attrOC3 = new DefaultServerAttribute( atOC, "inetOrgPerson" );
        assertFalse( entry.hasObjectClass( attrOC3 ) );
        assertFalse( entry.hasObjectClass( (EntryAttribute)null ) );

        EntryAttribute attrCN = new DefaultServerAttribute( atCN, "top" );
        assertFalse( entry.hasObjectClass( attrCN ) );
    }
View Full Code Here

    @Test
    public void testIterator() throws Exception
    {
        Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
       
        EntryAttribute attrOC = new DefaultServerAttribute( atOC, "top", "person" );
        EntryAttribute attrCN = new DefaultServerAttribute( atCN, "test1", "test2" );
        EntryAttribute attrSN = new DefaultServerAttribute( atSN, "Test1", "Test2" );
        EntryAttribute attrPWD = new DefaultServerAttribute( atPwd, BYTES1, BYTES2 );
       
        entry.put( attrOC, attrCN, attrSN, attrPWD );
       
        Iterator<EntryAttribute> iterator = entry.iterator();
       
        assertTrue( iterator.hasNext() );
       
        Set<AttributeType> expectedIds = new HashSet<AttributeType>();
        expectedIds.add( atOC );
        expectedIds.add( atCN );
        expectedIds.add( atSN );
        expectedIds.add( atPwd );
       
        while ( iterator.hasNext() )
        {
            EntryAttribute attribute = iterator.next();
           
            AttributeType attributeType = ((ServerAttribute)attribute).getAttributeType();
            assertTrue( expectedIds.contains( attributeType ) );
            expectedIds.remove( attributeType );
        }
View Full Code Here

        entry.put( atPwd, (byte[])null );
        assertEquals( 1, entry.size() );
        assertTrue( entry.containsAttribute( atPwd ) );
        assertTrue( entry.contains( atPwd, (byte[])null ) );
       
        EntryAttribute replaced = entry.put( atPwd, BYTES1, BYTES2, BYTES1 );
        assertNotNull( replaced );
        assertEquals( atPwd, ((ServerAttribute)replaced).getAttributeType() );
        assertTrue( replaced.contains( (byte[])null ) );
        assertEquals( 1, entry.size() );
        assertTrue( entry.contains( atPwd, BYTES1, BYTES2 ) );
        assertFalse( entry.contains( atPwd, BYTES3 ) );
        assertEquals( 2, entry.get( atPwd ).size() );
       
        replaced = entry.put( atPwd, "test" );
        assertNotNull( replaced );
        assertTrue( replaced.contains( BYTES1, BYTES2 ) );
       
        EntryAttribute attribute = entry.get( atPwd );
        assertEquals( 0, attribute.size() );
    }
View Full Code Here

        entry.put( atCN, (String)null );
        assertEquals( 1, entry.size() );
        assertTrue( entry.containsAttribute( atCN) );
        assertTrue( entry.contains( atCN, (String)null ) );
       
        EntryAttribute replaced = entry.put( atCN, "test1", "test2", "test1" );
        assertNotNull( replaced );
        assertEquals( atCN, ((ServerAttribute)replaced).getAttributeType() );
        assertTrue( replaced.contains( (String)null ) );
        assertEquals( 1, entry.size() );
        assertTrue( entry.contains( atCN, "test1", "test2" ) );
        assertFalse( entry.contains( atCN, "test3" ) );
        assertEquals( 2, entry.get( atCN ).size() );
       
        replaced = entry.put( atCN, BYTES1 );
        assertNotNull( replaced );
        assertTrue( replaced.contains( "test1", "test2" ) );
       
        EntryAttribute attribute = entry.get( atCN );
        assertEquals( 0, attribute.size() );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.entry.EntryAttribute

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.