Java Code Examples for org.apache.directory.api.util.Strings#EMPTY_BYTES
The following examples show how to use
org.apache.directory.api.util.Strings#EMPTY_BYTES .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BinaryValueTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
@Test public void testGet() { Value bv = new Value( ( byte[] ) null ); assertEquals( "", bv.getString() ); bv = new Value( Strings.EMPTY_BYTES ); assertEquals( "", bv.getString() ); assertTrue( Arrays.equals( Strings.EMPTY_BYTES, bv.getBytes() ) ); bv = new Value( BYTES1 ); byte[] get = bv.getBytes(); assertTrue( Arrays.equals( BYTES1, get ) ); assertTrue( Arrays.equals( BYTES1, get ) ); }
Example 2
Source File: BinaryValueTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
@Test public void testNormalize() throws LdapException { Value bv = new Value( ( byte[] ) null ); bv = new Value( at, bv ); assertTrue( bv.isSchemaAware() ); assertEquals( null, bv.getBytes() ); bv = new Value( Strings.EMPTY_BYTES ); bv = new Value( at, bv ); assertTrue( bv.isSchemaAware() ); assertTrue( Arrays.equals( Strings.EMPTY_BYTES, bv.getBytes() ) ); bv = new Value( BYTES2 ); bv = new Value( at, bv ); assertTrue( bv.isSchemaAware() ); assertTrue( Arrays.equals( BYTES2, bv.getBytes() ) ); }
Example 3
Source File: BinaryValueAttributeTypeTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Test serialization of an empty Value */ @Test public void testEmptyBinaryValueSerialization() throws LdapException, IOException, ClassNotFoundException { // First check with a value which will be normalized Value sbv = new Value( at, Strings.EMPTY_BYTES ); byte[] normalized = sbv.getBytes(); assertTrue( Arrays.equals( Strings.EMPTY_BYTES, normalized ) ); assertTrue( Arrays.equals( Strings.EMPTY_BYTES, sbv.getBytes() ) ); Value sbvSer = deserializeValue( serializeValue( sbv ), at ); assertEquals( sbv, sbvSer ); }
Example 4
Source File: BinaryValueTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
@Test public void testNormalizeNormalizer() throws LdapException { Value bv = new Value( ( byte[] ) null ); bv = new Value( at, bv ); assertTrue( bv.isSchemaAware() ); assertNull( bv.getBytes() ); bv = new Value( Strings.EMPTY_BYTES ); bv = new Value( at, bv ); assertTrue( bv.isSchemaAware() ); assertTrue( Arrays.equals( Strings.EMPTY_BYTES, bv.getBytes() ) ); bv = new Value( BYTES1 ); bv = new Value( at, bv ); assertTrue( bv.isSchemaAware() ); assertTrue( Arrays.equals( BYTES1, bv.getBytes() ) ); bv = new Value( BYTES2 ); bv = new Value( at, bv ); assertTrue( bv.isSchemaAware() ); assertTrue( Arrays.equals( BYTES2, bv.getBytes() ) ); }
Example 5
Source File: BinaryValueTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
@Test public void testSet() throws LdapException { Value bv = new Value( ( byte[] ) null ); assertEquals( "", bv.getString() ); assertFalse( bv.isSchemaAware() ); assertTrue( bv.isValid( BINARY_CHECKER ) ); assertTrue( bv.isNull() ); bv = new Value( Strings.EMPTY_BYTES ); assertEquals( "", bv.getString() ); assertTrue( Arrays.equals( Strings.EMPTY_BYTES, bv.getBytes() ) ); assertFalse( bv.isSchemaAware() ); assertTrue( bv.isValid( BINARY_CHECKER ) ); assertFalse( bv.isNull() ); bv = new Value( BYTES1 ); assertNotNull( bv.getBytes() ); assertTrue( Arrays.equals( BYTES1, bv.getBytes() ) ); assertFalse( bv.isSchemaAware() ); assertTrue( bv.isValid( BINARY_CHECKER ) ); assertFalse( bv.isNull() ); }
Example 6
Source File: BinaryValueAttributeTypeTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Test the clone method */ @Test public void testClone() throws LdapException { AttributeType at1 = EntryUtils.getBytesAttributeType(); Value bv = new Value( at1, ( byte[] ) null ); Value bv1 = bv.clone(); assertEquals( bv, bv1 ); bv = new Value( Strings.EMPTY_BYTES ); assertNotSame( bv, bv1 ); assertTrue( Arrays.equals( Strings.EMPTY_BYTES, bv.getBytes() ) ); bv = new Value( at, BYTES2 ); bv1 = bv.clone(); assertEquals( bv, bv1 ); }
Example 7
Source File: BinaryValueAttributeTypeTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Test the getNormValue method */ @Test public void testGetNormalizedValue() throws LdapInvalidAttributeValueException { AttributeType attribute = EntryUtils.getBytesAttributeType(); Value value = new Value( attribute, ( byte[] ) null ); assertNull( value.getBytes() ); value = new Value( attribute, Strings.EMPTY_BYTES ); assertTrue( Arrays.equals( Strings.EMPTY_BYTES, value.getBytes() ) ); value = new Value( attribute, BYTES2 ); assertTrue( Arrays.equals( BYTES2, value.getBytes() ) ); }
Example 8
Source File: StoreServerSASLCreds.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public void action( LdapMessageContainer<BindResponse> container ) { // Get the Value and store it in the BindRequest TLV tlv = container.getCurrentTLV(); // We have to handle the special case of a 0 length server // sasl credentials byte[] serverSaslCreds; if ( tlv.getLength() == 0 ) { serverSaslCreds = Strings.EMPTY_BYTES; } else { serverSaslCreds = tlv.getValue().getData(); } BindResponse response = container.getMessage(); response.setServerSaslCreds( serverSaslCreds ); // We can have an END transition container.setGrammarEndAllowed( true ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_05168_SASL_CREDENTIALS_VALUE_STORED ) ); } }
Example 9
Source File: AdDirSyncRequestImpl.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void setCookie( byte[] cookie ) { if ( cookie != null ) { this.cookie = new byte[cookie.length]; System.arraycopy( cookie, 0, this.cookie, 0, cookie.length ); } else { this.cookie = Strings.EMPTY_BYTES; } }
Example 10
Source File: BinaryValueTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
@Test public void testToString() { Value bv = new Value( ( byte[] ) null ); assertEquals( "null", bv.toString() ); bv = new Value( Strings.EMPTY_BYTES ); assertEquals( "", bv.toString() ); bv = new Value( BYTES1 ); assertEquals( "0x01 0x02 0x03 0x04 ", bv.toString() ); }
Example 11
Source File: BinaryValueTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
@Test public void testHashCode() { Value bv = new Value( ( byte[] ) null ); assertEquals( 0, bv.hashCode() ); bv = new Value( Strings.EMPTY_BYTES ); int h = Arrays.hashCode( Strings.EMPTY_BYTES ); assertEquals( h, bv.hashCode() ); h = Arrays.hashCode( BYTES1 ); bv = new Value( BYTES1 ); assertEquals( h, bv.hashCode() ); }
Example 12
Source File: BinaryValueAttributeTypeTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Test the constructor with an empty value */ @Test public void testServerBinaryValueEmptyValue() throws LdapInvalidAttributeValueException { AttributeType attribute = EntryUtils.getBytesAttributeType(); Value value = new Value( attribute, Strings.EMPTY_BYTES ); assertTrue( Arrays.equals( Strings.EMPTY_BYTES, value.getBytes() ) ); assertFalse( value.isNull() ); }
Example 13
Source File: BinaryValueAttributeTypeTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Test the normalize method */ @Test public void testNormalize() throws LdapException { AttributeType attribute = EntryUtils.getBytesAttributeType(); Value bv = Value.createValue( attribute ); assertEquals( null, bv.getBytes() ); bv = new Value( attribute, Strings.EMPTY_BYTES ); assertTrue( Arrays.equals( Strings.EMPTY_BYTES, bv.getBytes() ) ); bv = new Value( attribute, BYTES2 ); assertTrue( Arrays.equals( BYTES2, bv.getBytes() ) ); }
Example 14
Source File: AbstractLdapConnection.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void bind( Dn name, String credentials ) throws LdapException { byte[] credBytes = credentials == null ? Strings.EMPTY_BYTES : Strings.getBytesUtf8( credentials ); BindRequest bindRequest = new BindRequestImpl(); bindRequest.setDn( name ); bindRequest.setCredentials( credBytes ); BindResponse bindResponse = bind( bindRequest ); processResponse( bindResponse ); }
Example 15
Source File: AbstractLdapConnection.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void bind( Dn name ) throws LdapException { byte[] credBytes = Strings.EMPTY_BYTES; BindRequest bindRequest = new BindRequestImpl(); bindRequest.setDn( name ); bindRequest.setCredentials( credBytes ); BindResponse bindResponse = bind( bindRequest ); processResponse( bindResponse ); }
Example 16
Source File: LdapUrl.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * From commons-codec. Decodes an array of URL safe 7-bit characters into an * array of original bytes. Escaped characters are converted back to their * original representation. * * @param bytes array of URL safe characters * @return array of original bytes * @throws UrlDecoderException Thrown if URL decoding is unsuccessful */ private static byte[] decodeUrl( byte[] bytes ) throws UrlDecoderException { if ( bytes == null ) { return Strings.EMPTY_BYTES; } ByteArrayOutputStream buffer = new ByteArrayOutputStream(); for ( int i = 0; i < bytes.length; i++ ) { int b = bytes[i]; if ( b == '%' ) { try { int u = Character.digit( ( char ) bytes[++i], 16 ); int l = Character.digit( ( char ) bytes[++i], 16 ); if ( ( u == -1 ) || ( l == -1 ) ) { throw new UrlDecoderException( I18n.err( I18n.ERR_13040_INVALID_URL_ENCODING ) ); } buffer.write( ( char ) ( ( u << 4 ) + l ) ); } catch ( ArrayIndexOutOfBoundsException aioobe ) { throw new UrlDecoderException( I18n.err( I18n.ERR_13040_INVALID_URL_ENCODING ), aioobe ); } } else { buffer.write( b ); } } return buffer.toByteArray(); }
Example 17
Source File: CompareNoDResponse.java From directory-ldap-api with Apache License 2.0 | 2 votes |
/** * Gets the reponse OID specific encoded response values. * * @return the response specific encoded response values. */ public byte[] getResponse() { return Strings.EMPTY_BYTES; }
Example 18
Source File: SearchNoDResponse.java From directory-ldap-api with Apache License 2.0 | 2 votes |
/** * Gets the reponse OID specific encoded response values. * * @return the response specific encoded response values. */ public byte[] getResponse() { return Strings.EMPTY_BYTES; }
Example 19
Source File: ModifyNoDResponse.java From directory-ldap-api with Apache License 2.0 | 2 votes |
/** * Gets the reponse OID specific encoded response values. * * @return the response specific encoded response values. */ public byte[] getResponse() { return Strings.EMPTY_BYTES; }
Example 20
Source File: DeleteNoDResponse.java From directory-ldap-api with Apache License 2.0 | 2 votes |
/** * Gets the reponse OID specific encoded response values. * * @return the response specific encoded response values. */ public byte[] getResponse() { return Strings.EMPTY_BYTES; }