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

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


        ObjectInputStream in = null;

        byte[] data = baos.toByteArray();
        in = new ObjectInputStream( new ByteArrayInputStream( data ) );

        BinaryValue bvDeser = BinaryValue.deserialize( userCertificate, in );

        assertEquals( bv2n, bvDeser );
    }
View Full Code Here


        ObjectInputStream in = null;

        byte[] data = baos.toByteArray();
        in = new ObjectInputStream( new ByteArrayInputStream( data ) );

        BinaryValue bvDeser = BinaryValue.deserialize( userCertificate, in );

        assertEquals( bv3n, bvDeser );
    }
View Full Code Here


    @Test
    public void testNormalizeByteValue() throws Exception
    {
        assertEquals( "TRUE", normalizer.normalize( new BinaryValue( "tRuE".getBytes() ) ).getString() );
        assertEquals( "TRUE", normalizer.normalize( new BinaryValue( "true".getBytes() ) ).getString() );
    }
View Full Code Here

        assertTrue( attr1.isHumanReadable() );
        assertEquals( NULL_STRING_VALUE, attr1.get() );

        Attribute attr2 = new DefaultAttribute( atPwd );

        nbAdded = attr2.add( new BinaryValue( atPwd, null ) );
        assertEquals( 1, nbAdded );
        assertFalse( attr2.isHumanReadable() );
        assertEquals( NULL_BINARY_VALUE, attr2.get() );

        Attribute attr3 = new DefaultAttribute( atCN );

        nbAdded = attr3.add( new StringValue( atCN, "a" ), new StringValue( atCN, "b" ) );
        assertEquals( 2, nbAdded );
        assertTrue( attr3.isHumanReadable() );
        assertTrue( attr3.contains( "a" ) );
        assertTrue( attr3.contains( "b" ) );

        Attribute attr4 = new DefaultAttribute( atCN );

        nbAdded = attr4.add( new BinaryValue( atPwd, BYTES1 ), new BinaryValue( atPwd, BYTES2 ) );
        assertEquals( 0, nbAdded );
        assertTrue( attr4.isHumanReadable() );
        assertFalse( attr4.contains( BYTES1 ) );
        assertFalse( attr4.contains( BYTES2 ) );

        Attribute attr5 = new DefaultAttribute( atCN );

        nbAdded = attr5.add( new StringValue( atCN, "c" ), new BinaryValue( atPwd, BYTES1 ) );
        assertEquals( 1, nbAdded );
        assertTrue( attr5.isHumanReadable() );
        assertFalse( attr5.contains( "ab" ) );
        assertTrue( attr5.contains( "c" ) );

        Attribute attr6 = new DefaultAttribute( atPwd );

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

        Attribute attr7 = new DefaultAttribute( atPwd );

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

        Attribute attr8 = new DefaultAttribute( atDC );

        nbAdded = attr8.add( new StringValue( atDC, null ), new BinaryValue( atPwd, BYTES1 ) );
        assertEquals( 1, nbAdded );
        assertTrue( attr8.isHumanReadable() );
        assertTrue( attr8.contains( NULL_STRING_VALUE ) );
        assertFalse( attr8.contains( "ab" ) );

        Attribute attr9 = new DefaultAttribute( atDC );

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

        Attribute attr10 = new DefaultAttribute( atPwd );

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

        if ( current != 0 )
        {
            byte[] result = new byte[ current ];
            System.arraycopy( value, 0, result, 0, current );
           
            return new BinaryValue( result );
        }
        else
        {
            return new BinaryValue( (byte[])null );
        }
    }
View Full Code Here

            {
                AttributeType attributeType = schemaManager.getAttributeType( attribute );
               
                if ( attributeType != null )
                {
                    return new EqualityNode( attributeType, new BinaryValue( (byte[])null ) );
                }
               
                else
                {
                    return null;
                }
            }
            else
            {
                return new EqualityNode( attribute, new BinaryValue( (byte[])null ) );
            }
        }
        else
        {
            // A substring or an equality node
View Full Code Here

                throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message, le );
            }
           
            try
            {
                createAva( schemaManager, upType, new BinaryValue( attributeType, upValue ) );
            }
            catch ( LdapInvalidAttributeValueException liave )
            {
                String message =  I18n.err( I18n.ERR_04188 );
                LOG.error( message );
                throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message, liave );
            }
        }
        else
        {
            createAva( upType, new BinaryValue( upValue ) );
        }
    }
View Full Code Here

                SimpleNode<?> node;
                String attributeType = attr.getID();

                if ( value instanceof byte[] )
                {
                    node = new EqualityNode<byte[]>( attributeType, new BinaryValue( ( byte[] ) value ) );
                }
                else
                {
                    node = new EqualityNode<String>( attributeType,
                        new org.apache.directory.shared.ldap.model.entry.StringValue( ( String ) value ) );
View Full Code Here

        }
        else
        {
            if ( value instanceof String )
            {
                val = new BinaryValue( attributeType, Strings.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

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

TOP

Related Classes of org.apache.directory.shared.ldap.model.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.