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

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


        {
            return ( K ) normalizer.normalize( ( String ) attrVal );
        }
        else
        {
            return ( K ) normalizer.normalize( new BinaryValue( ( byte[] ) attrVal ) ).get();
        }
    }
View Full Code Here


        if ( entry.get( SchemaConstants.USER_PASSWORD_AT ) != null )
        {
            String username = null;

            BinaryValue userPassword = (BinaryValue)entry.get( SchemaConstants.USER_PASSWORD_AT ).get();

            // The password is stored in a non H/R attribute, but it's a String
            String strUserPassword = userPassword.getString();

            if ( log.isDebugEnabled() )
            {
                StringBuffer sb = new StringBuffer();
                sb.append( "'" + strUserPassword + "' ( " );
View Full Code Here

                        log.debug( "{} Attribute id : 'userPassword',  Values : [ '{}' ]", operation, attr );
                        pwd = ((StringValue)userPassword).getString();
                    }
                    else if ( userPassword instanceof BinaryValue )
                    {
                        BinaryValue password = (BinaryValue)userPassword;
                       
                        String string = password.getString();

                        if ( log.isDebugEnabled() )
                        {
                            StringBuffer sb = new StringBuffer();
                            sb.append( "'" + string + "' ( " );
                            sb.append( StringTools.dumpBytes( password.getBytes() ).trim() );
                            sb.append( " )" );
                            log.debug( "{} Attribute id : 'userPassword',  Values : [ {} ]", operation, sb.toString() );
                        }

                        pwd = string;
View Full Code Here

                    for ( byte b:val )
                    {
                        newVal[i++] = (byte)(b & 0x007F);
                    }
                   
                    return new BinaryValue( StringTools.trim( newVal ) );
                }

                throw new IllegalStateException( I18n.err( I18n.ERR_474 ) );
            }
View Full Code Here

        if ( ( entry.get( SchemaConstants.USER_PASSWORD_AT ) != null ) &&
            ( entry.get( KerberosAttribute.KRB5_PRINCIPAL_NAME_AT ) != null ) )
        {
            log.debug( "Adding the entry '{}' for DN '{}'.", entry, normName.getName() );

            BinaryValue userPassword = (BinaryValue)entry.get( SchemaConstants.USER_PASSWORD_AT ).get();
            String strUserPassword = userPassword.getString();

            if ( log.isDebugEnabled() )
            {
                StringBuffer sb = new StringBuffer();
                sb.append( "'" + strUserPassword + "' ( " );
View Full Code Here

        }
        else
        {
            if ( value instanceof String )
            {
                val = new BinaryValue( attributeType, StringTools.getBytesUtf8( (String)value ) );
            }
            else if ( value instanceof byte[] )
            {
                val = new BinaryValue( attributeType, (byte[])value );
            }
            else
            {
                throw new LdapException( I18n.err( I18n.ERR_309, oid ) );
            }
View Full Code Here

                normalized = ( K ) attribute.getEquality().getNormalizer().normalize( ( String ) attrVal );
            }
            else
            {
                normalized = ( K ) attribute.getEquality().getNormalizer().normalize(
                    new BinaryValue( ( byte[] ) attrVal ) ).get();
            }

            // Double map it so if we use an already normalized
            // value we can get back the same normalized value.
            // and not have to regenerate a second time.
View Full Code Here

        assertTrue( attr1.isHR() );
        assertEquals( NULL_STRING_VALUE, attr1.get() );
       
        EntryAttribute attr2 = new DefaultServerAttribute( atPwd );
       
        nbAdded = attr2.add( new BinaryValue( atPwd, null ) );
        assertEquals( 1, nbAdded );
        assertFalse( attr2.isHR() );
        assertEquals( NULL_BINARY_VALUE, attr2.get() );
       
        EntryAttribute attr3 = new DefaultServerAttribute( atCN );
       
        nbAdded = attr3.add( new StringValue( atCN, "a" ), new StringValue( atCN, "b" ) );
        assertEquals( 2, nbAdded );
        assertTrue( attr3.isHR() );
        assertTrue( attr3.contains( "a" ) );
        assertTrue( attr3.contains( "b" ) );
       
        EntryAttribute attr4 = new DefaultServerAttribute( atCN );
       
        nbAdded = attr4.add( new BinaryValue( atPwd, BYTES1 ), new BinaryValue( atPwd, BYTES2 ) );
        assertEquals( 0, nbAdded );
        assertTrue( attr4.isHR() );
        assertFalse( attr4.contains( BYTES1 ) );
        assertFalse( attr4.contains( BYTES2 ) );
       
        EntryAttribute attr5 = new DefaultServerAttribute( atCN );
       
        nbAdded = attr5.add( new StringValue( atCN, "c" ), new BinaryValue( atPwd, BYTES1 ) );
        assertEquals( 1, nbAdded );
        assertTrue( attr5.isHR() );
        assertFalse( attr5.contains( "ab" ) );
        assertTrue( attr5.contains( "c" ) );

        EntryAttribute attr6 = new DefaultServerAttribute( atPwd );
       
        nbAdded = attr6.add( new BinaryValue( atPwd, BYTES1 ), new StringValue( atCN, "c" ) );
        assertEquals( 1, nbAdded );
        assertFalse( attr6.isHR() );
        assertTrue( attr6.contains( BYTES1 ) );
        assertFalse( attr6.contains( BYTES3 ) );

        EntryAttribute attr7 = new DefaultServerAttribute( atPwd );
       
        nbAdded = attr7.add( new BinaryValue( atPwd, null ), new StringValue( atCN, "c" ) );
        assertEquals( 1, nbAdded );
        assertFalse( attr7.isHR() );
        assertTrue( attr7.contains( NULL_BINARY_VALUE ) );
        assertFalse( attr7.contains( BYTES3 ) );

        EntryAttribute attr8 = new DefaultServerAttribute( atCN );
       
        nbAdded = attr8.add( new StringValue( atCN, null ), new BinaryValue( atPwd, BYTES1 ) );
        assertEquals( 1, nbAdded );
        assertTrue( attr8.isHR() );
        assertTrue( attr8.contains( NULL_STRING_VALUE ) );
        assertFalse( attr8.contains( "ab" ) );

   
        EntryAttribute attr9 = new DefaultServerAttribute( atCN );
       
        nbAdded = attr9.add( new StringValue( (String)null ), new StringValue( "ab" ) );
        assertEquals( 2, nbAdded );
        assertTrue( attr9.isHR() );
        assertTrue( attr9.contains( NULL_STRING_VALUE ) );
        assertTrue( attr9.contains( "ab" ) );

        EntryAttribute attr10 = new DefaultServerAttribute( atPwd );
       
        nbAdded = attr10.add( new BinaryValue( (byte[])null ), new BinaryValue( BYTES1 ) );
        assertEquals( 2, nbAdded );
        assertFalse( attr10.isHR() );
        assertTrue( attr10.contains( NULL_BINARY_VALUE ) );
        assertTrue( attr10.contains( BYTES1 ) );
    }
View Full Code Here

            {
                normalized = new StringValue( ( String ) ncn.normalizeByName( attribute, value.getString() ) );
            }
            else
            {
                normalized = new BinaryValue( ( byte[] ) ncn.normalizeByName( attribute, value.getBytes() ) );
            }

            return normalized;
        }
        catch ( LdapException ne )
View Full Code Here

TOP

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

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.