You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Emmanuel Lécharny <el...@gmail.com> on 2019/07/10 07:30:12 UTC

Re: [directory-server] branch master updated: DIRSERVER-2097: Use Strings.getBytesUtf8()

Side note:

for strings that are known to be pure ASCII (like Attribute names), 
there is a faster function : Strings.getBytesUtf8Ascii().

No need ,to use that in tests, it's really for use in the server or the API.

On 10/07/2019 08:41, seelmann@apache.org wrote:
> This is an automated email from the ASF dual-hosted git repository.
>
> seelmann pushed a commit to branch master
> in repository https://gitbox.apache.org/repos/asf/directory-server.git
>
>
> The following commit(s) were added to refs/heads/master by this push:
>       new 738c06a  DIRSERVER-2097: Use Strings.getBytesUtf8()
> 738c06a is described below
>
> commit 738c06a9f7a7b01d0eabaceaf01fc637fde809af
> Author: Stefan Seelmann <ma...@stefan-seelmann.de>
> AuthorDate: Wed Jul 10 08:32:28 2019 +0200
>
>      DIRSERVER-2097: Use Strings.getBytesUtf8()
> ---
>   .../factory/DirectoryServiceAnnotationTest.java    |  5 +-
>   .../core/api/entry/SchemaAwareEntryTest.java       |  3 +-
>   .../server/core/integ/IntegrationUtils.java        |  4 +-
>   .../server/core/changelog/DefaultChangeLogIT.java  |  4 +-
>   .../add/PasswordHashingInterceptorTest.java        | 11 ++---
>   .../server/core/operations/modify/ModifyAddIT.java |  9 ++--
>   .../btree/jdbm/BTreeRedirectMarshallerTest.java    |  4 +-
>   .../directory/kerberos/client/KdcConnection.java   |  3 +-
>   .../credentials/cache/CacheOutputStream.java       |  6 +--
>   .../shared/kerberos/components/AdKdcIssued.java    |  3 +-
>   .../shared/kerberos/components/EncKdcRepPart.java  |  3 +-
>   .../shared/crypto/encryption/KeyTypeTest.java      | 15 +++---
>   .../shared/crypto/encryption/NFoldTest.java        | 55 +++++++++++-----------
>   .../codec/ChangePasswdDataDecoderTest.java         |  9 ++--
>   .../kerberos/codec/KdcReqBodyDecoderTest.java      | 11 ++---
>   .../api/operations/ClientCompareRequestTest.java   |  4 +-
>   .../io/decoder/MailExchangeRecordDecoderTest.java  | 11 ++---
>   .../io/decoder/NameServerRecordDecoderTest.java    | 11 ++---
>   .../encoder/AbstractResourceRecordEncoderTest.java | 11 +++--
>   .../io/encoder/CanonicalNameRecordEncoderTest.java |  7 ++-
>   .../io/encoder/MailExchangeRecordEncoderTest.java  |  7 ++-
>   .../io/encoder/NameServerRecordEncoderTest.java    |  9 ++--
>   .../dns/io/encoder/PointerRecordEncoderTest.java   |  7 ++-
>   .../dns/io/encoder/QuestionRecordEncoderTest.java  | 12 ++---
>   .../encoder/ServerSelectionRecordEncoderTest.java  |  7 ++-
>   .../encoder/StartOfAuthorityRecordEncoderTest.java | 13 +++--
>   .../dns/io/encoder/TextRecordEncoderTest.java      |  3 +-
>   .../kerberos/kdc/DirectoryPrincipalStore.java      |  4 +-
>   .../server/operations/bind/BogusNtlmProvider.java  |  5 +-
>   .../server/operations/bind/SaslBindIT.java         | 22 ++++-----
>   .../server/operations/extended/PwdModifyIT.java    |  4 +-
>   .../directory/server/ppolicy/PasswordPolicyIT.java | 16 +++----
>   .../server/replication/ClientInitialRefreshIT.java | 11 ++---
>   .../replication/StaleEventLogDetectionIT.java      |  6 +--
>   34 files changed, 144 insertions(+), 171 deletions(-)
>
> diff --git a/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java b/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java
> index 485b5b2..3393cfb 100644
> --- a/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java
> +++ b/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java
> @@ -24,7 +24,6 @@ package org.apache.directory.server.core.factory;
>   import static org.junit.Assert.assertEquals;
>   import static org.junit.Assert.assertTrue;
>   
> -import java.nio.charset.StandardCharsets;
>   import java.util.HashSet;
>   import java.util.Set;
>   
> @@ -32,6 +31,7 @@ import org.apache.directory.api.ldap.model.constants.AuthenticationLevel;
>   import org.apache.directory.api.ldap.model.exception.LdapException;
>   import org.apache.directory.api.ldap.model.name.Dn;
>   import org.apache.directory.api.util.FileUtils;
> +import org.apache.directory.api.util.Strings;
>   import org.apache.directory.server.core.annotations.ContextEntry;
>   import org.apache.directory.server.core.annotations.CreateAuthenticator;
>   import org.apache.directory.server.core.annotations.CreateDS;
> @@ -213,8 +213,7 @@ public class DirectoryServiceAnnotationTest
>               "Expected the only interceptor to be the dummy interceptor",
>               DummyAuthenticator.class,
>               authenticators.iterator().next().getClass() );
> -        service.getSession( new Dn( "uid=non-existant-user,ou=system" ),
> -            "wrong-password".getBytes( StandardCharsets.UTF_8 ) );
> +        service.getSession( new Dn( "uid=non-existant-user,ou=system" ), Strings.getBytesUtf8( "wrong-password" ) );
>           assertTrue( "Expected dummy authenticator to have been invoked", dummyAuthenticatorCalled );
>           service.shutdown();
>           FileUtils.deleteDirectory( service.getInstanceLayout().getInstanceDirectory() );
> diff --git a/core-api/src/test/java/org/apache/directory/server/core/api/entry/SchemaAwareEntryTest.java b/core-api/src/test/java/org/apache/directory/server/core/api/entry/SchemaAwareEntryTest.java
> index 1355799..2f3d5a4 100644
> --- a/core-api/src/test/java/org/apache/directory/server/core/api/entry/SchemaAwareEntryTest.java
> +++ b/core-api/src/test/java/org/apache/directory/server/core/api/entry/SchemaAwareEntryTest.java
> @@ -29,7 +29,6 @@ import static org.junit.Assert.assertTrue;
>   import static org.junit.Assert.fail;
>   
>   import java.io.File;
> -import java.nio.charset.StandardCharsets;
>   import java.util.Arrays;
>   import java.util.Collection;
>   import java.util.HashSet;
> @@ -1968,7 +1967,7 @@ public class SchemaAwareEntryTest
>   
>           Attribute attribute = entry.get( atPwd );
>           assertEquals( 1, attribute.size() );
> -        assertTrue( attribute.contains( "test".getBytes( StandardCharsets.UTF_8 ) ) );
> +        assertTrue( attribute.contains( Strings.getBytesUtf8( "test" ) ) );
>       }
>   
>   
> diff --git a/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java b/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java
> index ed2d283..afa5dd5 100644
> --- a/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java
> +++ b/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java
> @@ -21,7 +21,6 @@ package org.apache.directory.server.core.integ;
>   
>   import java.io.File;
>   import java.io.IOException;
> -import java.nio.charset.StandardCharsets;
>   import java.util.ArrayList;
>   import java.util.List;
>   
> @@ -46,6 +45,7 @@ import org.apache.directory.api.ldap.model.name.Rdn;
>   import org.apache.directory.api.ldap.model.schema.registries.Schema;
>   import org.apache.directory.api.util.FileUtils;
>   import org.apache.directory.api.util.Network;
> +import org.apache.directory.api.util.Strings;
>   import org.apache.directory.ldap.client.api.LdapConnection;
>   import org.apache.directory.ldap.client.api.LdapNetworkConnection;
>   import org.apache.directory.server.constants.ServerDNConstants;
> @@ -138,7 +138,7 @@ public class IntegrationUtils
>   
>       public static LdifEntry getUserAddLdif() throws LdapException
>       {
> -        return getUserAddLdif( "uid=akarasulu,ou=users,ou=system", "test".getBytes( StandardCharsets.UTF_8 ),
> +        return getUserAddLdif( "uid=akarasulu,ou=users,ou=system", Strings.getBytesUtf8( "test" ),
>               "Alex Karasulu", "Karasulu" );
>       }
>   
> diff --git a/core-integ/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogIT.java b/core-integ/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogIT.java
> index d01722c..a50e668 100644
> --- a/core-integ/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogIT.java
> +++ b/core-integ/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogIT.java
> @@ -25,7 +25,6 @@ import static org.junit.Assert.assertNotNull;
>   import static org.junit.Assert.assertNull;
>   import static org.junit.Assert.assertTrue;
>   
> -import java.nio.charset.StandardCharsets;
>   import java.util.Arrays;
>   
>   import org.apache.directory.api.ldap.model.entry.Attribute;
> @@ -34,6 +33,7 @@ import org.apache.directory.api.ldap.model.entry.Entry;
>   import org.apache.directory.api.ldap.model.exception.LdapException;
>   import org.apache.directory.api.ldap.model.message.ModifyRequest;
>   import org.apache.directory.api.ldap.model.message.ModifyRequestImpl;
> +import org.apache.directory.api.util.Strings;
>   import org.apache.directory.ldap.client.api.LdapConnection;
>   import org.apache.directory.server.core.annotations.CreateDS;
>   import org.apache.directory.server.core.api.changelog.Tag;
> @@ -424,7 +424,7 @@ public class DefaultChangeLogIT extends AbstractLdapTestUnit
>       {
>           Attribute userPassword = entry.get( "userPassword" );
>           assertNotNull( userPassword );
> -        assertTrue( Arrays.equals( password.getBytes( StandardCharsets.UTF_8 ), userPassword.getBytes() ) );
> +        assertTrue( Arrays.equals( Strings.getBytesUtf8( password ), userPassword.getBytes() ) );
>       }
>   
>   
> diff --git a/core-integ/src/test/java/org/apache/directory/server/core/operations/add/PasswordHashingInterceptorTest.java b/core-integ/src/test/java/org/apache/directory/server/core/operations/add/PasswordHashingInterceptorTest.java
> index 4505e1f..e4026d5 100644
> --- a/core-integ/src/test/java/org/apache/directory/server/core/operations/add/PasswordHashingInterceptorTest.java
> +++ b/core-integ/src/test/java/org/apache/directory/server/core/operations/add/PasswordHashingInterceptorTest.java
> @@ -25,12 +25,10 @@ import static org.junit.Assert.assertFalse;
>   import static org.junit.Assert.assertNull;
>   import static org.junit.Assert.assertTrue;
>   
> -import java.nio.charset.StandardCharsets;
>   import java.util.ArrayList;
>   import java.util.Arrays;
>   import java.util.List;
>   
> -
>   import org.apache.directory.api.ldap.model.constants.LdapSecurityConstants;
>   import org.apache.directory.api.ldap.model.constants.SchemaConstants;
>   import org.apache.directory.api.ldap.model.entry.Attribute;
> @@ -43,6 +41,7 @@ import org.apache.directory.api.ldap.model.entry.ModificationOperation;
>   import org.apache.directory.api.ldap.model.name.Dn;
>   import org.apache.directory.api.ldap.model.password.PasswordUtil;
>   import org.apache.directory.api.ldap.model.schema.AttributeType;
> +import org.apache.directory.api.util.Strings;
>   import org.apache.directory.ldap.client.api.LdapConnection;
>   import org.apache.directory.server.config.beans.HashInterceptorBean;
>   import org.apache.directory.server.core.annotations.CreateDS;
> @@ -151,7 +150,7 @@ public class PasswordHashingInterceptorTest extends AbstractLdapTestUnit
>       {
>           LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );
>   
> -        byte[] plainPwd = "secret".getBytes( StandardCharsets.UTF_8 );
> +        byte[] plainPwd = Strings.getBytesUtf8( "secret" );
>           Dn dn = new Dn( "cn=test,ou=system" );
>   
>           Entry entry = connection.lookup( dn );
> @@ -166,7 +165,7 @@ public class PasswordHashingInterceptorTest extends AbstractLdapTestUnit
>       {
>           LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );
>   
> -        byte[] plainPwd = "newsecret".getBytes( StandardCharsets.UTF_8 );
> +        byte[] plainPwd = Strings.getBytesUtf8( "newsecret" );
>           Dn dn = new Dn( "cn=test,ou=system" );
>   
>           AttributeType pwdAtType = getService().getSchemaManager().lookupAttributeTypeRegistry(
> @@ -212,7 +211,7 @@ public class PasswordHashingInterceptorTest extends AbstractLdapTestUnit
>       {
>           LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );
>   
> -        byte[] plainPwd = "secret".getBytes( StandardCharsets.UTF_8 );
> +        byte[] plainPwd = Strings.getBytesUtf8( "secret" );
>           byte[] hashedPwd = PasswordUtil.createStoragePassword( plainPwd, LdapSecurityConstants.HASH_METHOD_SSHA );
>   
>           Dn dn = new Dn( "cn=testHash,ou=system" );
> @@ -237,7 +236,7 @@ public class PasswordHashingInterceptorTest extends AbstractLdapTestUnit
>       {
>           LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );
>   
> -        byte[] plainPwd = "xyzsecret".getBytes( StandardCharsets.UTF_8 );
> +        byte[] plainPwd = Strings.getBytesUtf8( "xyzsecret" );
>           byte[] hashedPwd = PasswordUtil.createStoragePassword( plainPwd, LdapSecurityConstants.HASH_METHOD_SSHA256 );
>   
>           Dn dn = new Dn( "cn=test,ou=system" );
> diff --git a/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyAddIT.java b/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyAddIT.java
> index db25110..4912b36 100644
> --- a/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyAddIT.java
> +++ b/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyAddIT.java
> @@ -26,8 +26,6 @@ import static org.junit.Assert.assertEquals;
>   import static org.junit.Assert.assertNotNull;
>   import static org.junit.Assert.assertTrue;
>   
> -import java.nio.charset.StandardCharsets;
> -
>   import javax.naming.NameNotFoundException;
>   import javax.naming.NoPermissionException;
>   import javax.naming.directory.Attribute;
> @@ -339,7 +337,7 @@ public class ModifyAddIT extends AbstractLdapTestUnit
>           attrs = sysRoot.getAttributes( "ou=testing01" );
>           Attribute attr = attrs.get( "crossCertificatePair" );
>           assertNotNull( attr );
> -        assertTrue( attr.contains( "12345".getBytes(StandardCharsets.UTF_8) ) );
> +        assertTrue( attr.contains( Strings.getBytesUtf8( "12345" ) ) );
>           assertEquals( 1, attr.size() );
>       }
>   
> @@ -544,8 +542,7 @@ public class ModifyAddIT extends AbstractLdapTestUnit
>           LdapContext sysRoot = getSystemContext( getService() );
>           createData( sysRoot );
>   
> -        Attributes attrs = new BasicAttributes( "crossCertificatePair", "12345".getBytes( StandardCharsets.UTF_8 ),
> -            true );
> +        Attributes attrs = new BasicAttributes( "crossCertificatePair", Strings.getBytesUtf8( "12345" ), true );
>   
>           // Add the first Ava
>           sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs );
> @@ -559,7 +556,7 @@ public class ModifyAddIT extends AbstractLdapTestUnit
>           attrs = sysRoot.getAttributes( "ou=testing01" );
>           Attribute attr = attrs.get( "crossCertificatePair" );
>           assertNotNull( attr );
> -        assertTrue( attr.contains( "12345".getBytes( StandardCharsets.UTF_8 ) ) );
> +        assertTrue( attr.contains( Strings.getBytesUtf8( "12345" ) ) );
>           assertTrue( attr.contains( Strings.EMPTY_BYTES ) );
>           assertEquals( 2, attr.size() );
>       }
> diff --git a/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeRedirectMarshallerTest.java b/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeRedirectMarshallerTest.java
> index ea463c5..0a68c01 100644
> --- a/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeRedirectMarshallerTest.java
> +++ b/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeRedirectMarshallerTest.java
> @@ -27,10 +27,10 @@ import static org.junit.Assert.assertTrue;
>   import static org.junit.Assert.fail;
>   
>   import java.io.IOException;
> -import java.nio.charset.StandardCharsets;
>   import java.util.Objects;
>   import java.util.Random;
>   
> +import org.apache.directory.api.util.Strings;
>   import org.junit.Test;
>   import org.junit.runner.RunWith;
>   
> @@ -153,7 +153,7 @@ public class BTreeRedirectMarshallerTest
>   
>           try
>           {
> -            marshaller.deserialize( "bogus".getBytes( StandardCharsets.UTF_8 ) );
> +            marshaller.deserialize( Strings.getBytesUtf8( "bogus" ) );
>               fail( "Should not get here." );
>           }
>           catch ( IOException e )
> diff --git a/kerberos-client/src/main/java/org/apache/directory/kerberos/client/KdcConnection.java b/kerberos-client/src/main/java/org/apache/directory/kerberos/client/KdcConnection.java
> index 9081632..d5febf6 100644
> --- a/kerberos-client/src/main/java/org/apache/directory/kerberos/client/KdcConnection.java
> +++ b/kerberos-client/src/main/java/org/apache/directory/kerberos/client/KdcConnection.java
> @@ -22,7 +22,6 @@ package org.apache.directory.kerberos.client;
>   
>   import java.io.IOException;
>   import java.nio.ByteBuffer;
> -import java.nio.charset.StandardCharsets;
>   import java.security.SecureRandom;
>   import java.text.ParseException;
>   import java.util.List;
> @@ -116,7 +115,7 @@ public class KdcConnection
>           this.config = config;
>   
>           nonceGenerator = new SecureRandom(
> -            String.valueOf( System.currentTimeMillis() ).getBytes( StandardCharsets.UTF_8 ) );
> +            Strings.getBytesUtf8( String.valueOf( System.currentTimeMillis() ) ) );
>           cipherTextHandler = new CipherTextHandler();
>           channel = new KerberosChannel();
>       }
> diff --git a/kerberos-client/src/main/java/org/apache/directory/kerberos/credentials/cache/CacheOutputStream.java b/kerberos-client/src/main/java/org/apache/directory/kerberos/credentials/cache/CacheOutputStream.java
> index ae7a290..40d5a7e 100644
> --- a/kerberos-client/src/main/java/org/apache/directory/kerberos/credentials/cache/CacheOutputStream.java
> +++ b/kerberos-client/src/main/java/org/apache/directory/kerberos/credentials/cache/CacheOutputStream.java
> @@ -23,9 +23,9 @@ package org.apache.directory.kerberos.credentials.cache;
>   import java.io.DataOutputStream;
>   import java.io.IOException;
>   import java.io.OutputStream;
> -import java.nio.charset.StandardCharsets;
>   import java.util.List;
>   
> +import org.apache.directory.api.util.Strings;
>   import org.apache.directory.shared.kerberos.KerberosTime;
>   import org.apache.directory.shared.kerberos.codec.KerberosEncoder;
>   import org.apache.directory.shared.kerberos.components.AuthorizationData;
> @@ -145,7 +145,7 @@ public class CacheOutputStream extends DataOutputStream
>           if ( pname.getRealm() != null )
>           {
>               byte[] realmBytes = null;
> -            realmBytes = pname.getRealm().getBytes( StandardCharsets.UTF_8 );
> +            realmBytes = Strings.getBytesUtf8( pname.getRealm() );
>               writeInt( realmBytes.length );
>               write( realmBytes );
>           }
> @@ -157,7 +157,7 @@ public class CacheOutputStream extends DataOutputStream
>           byte[] bytes = null;
>           for ( int i = 0; i < pname.getNames().size(); i++ )
>           {
> -            bytes = pname.getNames().get( i ).getBytes( StandardCharsets.UTF_8 );
> +            bytes = Strings.getBytesUtf8( pname.getNames().get( i ) );
>               writeInt( bytes.length );
>               write( bytes );
>           }
> diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AdKdcIssued.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AdKdcIssued.java
> index 5c08fe0..b222408 100644
> --- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AdKdcIssued.java
> +++ b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AdKdcIssued.java
> @@ -22,7 +22,6 @@ package org.apache.directory.shared.kerberos.components;
>   
>   import java.nio.BufferOverflowException;
>   import java.nio.ByteBuffer;
> -import java.nio.charset.StandardCharsets;
>   
>   import org.apache.directory.api.asn1.Asn1Object;
>   import org.apache.directory.api.asn1.EncoderException;
> @@ -190,7 +189,7 @@ public class AdKdcIssued implements Asn1Object
>           // Compute the i-realm length, if any
>           if ( irealm != null )
>           {
> -            irealmBytes = irealm.getBytes( StandardCharsets.UTF_8 );
> +            irealmBytes = Strings.getBytesUtf8( irealm );
>               irealmTagLength = 1 + TLV.getNbBytes( irealmBytes.length ) + irealmBytes.length;
>               adKdcIssuedSeqLength += 1 + TLV.getNbBytes( irealmTagLength ) + irealmTagLength;
>           }
> diff --git a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKdcRepPart.java b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKdcRepPart.java
> index d8449d3..1d37f8a 100644
> --- a/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKdcRepPart.java
> +++ b/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKdcRepPart.java
> @@ -22,7 +22,6 @@ package org.apache.directory.shared.kerberos.components;
>   
>   import java.nio.BufferOverflowException;
>   import java.nio.ByteBuffer;
> -import java.nio.charset.StandardCharsets;
>   
>   import org.apache.directory.api.asn1.Asn1Object;
>   import org.apache.directory.api.asn1.EncoderException;
> @@ -489,7 +488,7 @@ public class EncKdcRepPart implements Asn1Object
>           }
>   
>           // The srealm
> -        srealmBytes = srealm.getBytes( StandardCharsets.UTF_8 );
> +        srealmBytes = Strings.getBytesUtf8( srealm );
>           srealmLength = 1 + TLV.getNbBytes( srealmBytes.length ) + srealmBytes.length;
>           encKdcRepPartSeqLength += 1 + TLV.getNbBytes( srealmLength ) + srealmLength;
>   
> diff --git a/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/KeyTypeTest.java b/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/KeyTypeTest.java
> index 5799950..4e2229c 100644
> --- a/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/KeyTypeTest.java
> +++ b/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/KeyTypeTest.java
> @@ -20,7 +20,9 @@
>   package org.apache.directory.server.kerberos.shared.crypto.encryption;
>   
>   
> -import java.nio.charset.StandardCharsets;
> +import static org.junit.Assert.assertEquals;
> +import static org.junit.Assert.assertTrue;
> +
>   import java.security.InvalidKeyException;
>   import java.security.NoSuchAlgorithmException;
>   import java.security.Provider;
> @@ -37,13 +39,12 @@ import javax.crypto.SecretKey;
>   import javax.crypto.SecretKeyFactory;
>   import javax.crypto.spec.DESKeySpec;
>   
> -import com.mycila.junit.concurrent.Concurrency;
> -import com.mycila.junit.concurrent.ConcurrentJunitRunner;
> +import org.apache.directory.api.util.Strings;
>   import org.junit.Test;
>   import org.junit.runner.RunWith;
>   
> -import static org.junit.Assert.assertEquals;
> -import static org.junit.Assert.assertTrue;
> +import com.mycila.junit.concurrent.Concurrency;
> +import com.mycila.junit.concurrent.ConcurrentJunitRunner;
>   
>   
>   /**
> @@ -257,7 +258,7 @@ public class KeyTypeTest
>   
>           Mac mac = Mac.getInstance( "HmacMD5" );
>           mac.init( sk );
> -        byte[] result = mac.doFinal( "Hello world!".getBytes( StandardCharsets.UTF_8 ) );
> +        byte[] result = mac.doFinal( Strings.getBytesUtf8( "Hello world!" ) );
>   
>           assertEquals( "HmacMD5 size", 16, result.length );
>       }
> @@ -276,7 +277,7 @@ public class KeyTypeTest
>   
>           Mac mac = Mac.getInstance( "HmacSHA1" );
>           mac.init( sk );
> -        byte[] result = mac.doFinal( "Hi There".getBytes( StandardCharsets.UTF_8 ) );
> +        byte[] result = mac.doFinal( Strings.getBytesUtf8( "Hi There" ) );
>   
>           assertEquals( "HmacSHA1 size", 20, result.length );
>       }
> diff --git a/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/NFoldTest.java b/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/NFoldTest.java
> index a48f501..4a5466c 100644
> --- a/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/NFoldTest.java
> +++ b/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/crypto/encryption/NFoldTest.java
> @@ -20,16 +20,17 @@
>   package org.apache.directory.server.kerberos.shared.crypto.encryption;
>   
>   
> -import java.nio.charset.StandardCharsets;
> +import static org.junit.Assert.assertEquals;
> +import static org.junit.Assert.assertTrue;
> +
>   import java.util.Arrays;
>   
> -import com.mycila.junit.concurrent.Concurrency;
> -import com.mycila.junit.concurrent.ConcurrentJunitRunner;
> +import org.apache.directory.api.util.Strings;
>   import org.junit.Test;
>   import org.junit.runner.RunWith;
>   
> -import static org.junit.Assert.assertEquals;
> -import static org.junit.Assert.assertTrue;
> +import com.mycila.junit.concurrent.Concurrency;
> +import com.mycila.junit.concurrent.ConcurrentJunitRunner;
>   
>   
>   /**
> @@ -51,11 +52,11 @@ public class NFoldTest
>           int n = 64;
>           String passPhrase = "012345";
>   
> -        int k = passPhrase.getBytes( StandardCharsets.UTF_8 ).length * 8;
> +        int k = Strings.getBytesUtf8( passPhrase ).length * 8;
>           int lcm = NFold.getLcm( n, k );
>           assertEquals( "LCM", 192, lcm );
>   
> -        byte[] nFoldValue = NFold.nFold( n, passPhrase.getBytes( StandardCharsets.UTF_8 ) );
> +        byte[] nFoldValue = NFold.nFold( n, Strings.getBytesUtf8( passPhrase ) );
>   
>           byte[] testVector =
>               { ( byte ) 0xbe, ( byte ) 0x07, ( byte ) 0x26, ( byte ) 0x31, ( byte ) 0x27, ( byte ) 0x6b, ( byte ) 0x19,
> @@ -73,11 +74,11 @@ public class NFoldTest
>           int n = 56;
>           String passPhrase = "password";
>   
> -        int k = passPhrase.getBytes( StandardCharsets.UTF_8 ).length * 8;
> +        int k = Strings.getBytesUtf8( passPhrase ).length * 8;
>           int lcm = NFold.getLcm( n, k );
>           assertEquals( "LCM", 448, lcm );
>   
> -        byte[] nFoldValue = NFold.nFold( n, passPhrase.getBytes( StandardCharsets.UTF_8 ) );
> +        byte[] nFoldValue = NFold.nFold( n, Strings.getBytesUtf8( passPhrase ) );
>   
>           byte[] testVector =
>               { ( byte ) 0x78, ( byte ) 0xa0, ( byte ) 0x7b, ( byte ) 0x6c, ( byte ) 0xaf, ( byte ) 0x85, ( byte ) 0xfa };
> @@ -94,11 +95,11 @@ public class NFoldTest
>           int n = 64;
>           String passPhrase = "Rough Consensus, and Running Code";
>   
> -        int k = passPhrase.getBytes( StandardCharsets.UTF_8 ).length * 8;
> +        int k = Strings.getBytesUtf8( passPhrase ).length * 8;
>           int lcm = NFold.getLcm( n, k );
>           assertEquals( "LCM", 2112, lcm );
>   
> -        byte[] nFoldValue = NFold.nFold( n, passPhrase.getBytes( StandardCharsets.UTF_8 ) );
> +        byte[] nFoldValue = NFold.nFold( n, Strings.getBytesUtf8( passPhrase ) );
>   
>           byte[] testVector =
>               { ( byte ) 0xbb, ( byte ) 0x6e, ( byte ) 0xd3, ( byte ) 0x08, ( byte ) 0x70, ( byte ) 0xb7, ( byte ) 0xf0,
> @@ -116,11 +117,11 @@ public class NFoldTest
>           int n = 168;
>           String passPhrase = "password";
>   
> -        int k = passPhrase.getBytes( StandardCharsets.UTF_8 ).length * 8;
> +        int k = Strings.getBytesUtf8( passPhrase ).length * 8;
>           int lcm = NFold.getLcm( n, k );
>           assertEquals( "LCM", 1344, lcm );
>   
> -        byte[] nFoldValue = NFold.nFold( n, passPhrase.getBytes( StandardCharsets.UTF_8 ) );
> +        byte[] nFoldValue = NFold.nFold( n, Strings.getBytesUtf8( passPhrase ) );
>   
>           byte[] testVector =
>               { ( byte ) 0x59, ( byte ) 0xe4, ( byte ) 0xa8, ( byte ) 0xca, ( byte ) 0x7c, ( byte ) 0x03, ( byte ) 0x85,
> @@ -140,11 +141,11 @@ public class NFoldTest
>           int n = 192;
>           String passPhrase = "MASSACHVSETTS INSTITVTE OF TECHNOLOGY";
>   
> -        int k = passPhrase.getBytes( StandardCharsets.UTF_8 ).length * 8;
> +        int k = Strings.getBytesUtf8( passPhrase ).length * 8;
>           int lcm = NFold.getLcm( n, k );
>           assertEquals( "LCM", 7104, lcm );
>   
> -        byte[] nFoldValue = NFold.nFold( n, passPhrase.getBytes( StandardCharsets.UTF_8 ) );
> +        byte[] nFoldValue = NFold.nFold( n, Strings.getBytesUtf8( passPhrase ) );
>   
>           byte[] testVector =
>               { ( byte ) 0xdb, ( byte ) 0x3b, ( byte ) 0x0d, ( byte ) 0x8f, ( byte ) 0x0b, ( byte ) 0x06, ( byte ) 0x1e,
> @@ -165,11 +166,11 @@ public class NFoldTest
>           int n = 168;
>           String passPhrase = "Q";
>   
> -        int k = passPhrase.getBytes( StandardCharsets.UTF_8 ).length * 8;
> +        int k = Strings.getBytesUtf8( passPhrase ).length * 8;
>           int lcm = NFold.getLcm( n, k );
>           assertEquals( "LCM", 168, lcm );
>   
> -        byte[] nFoldValue = NFold.nFold( n, passPhrase.getBytes( StandardCharsets.UTF_8 ) );
> +        byte[] nFoldValue = NFold.nFold( n, Strings.getBytesUtf8( passPhrase ) );
>   
>           byte[] testVector =
>               { ( byte ) 0x51, ( byte ) 0x8a, ( byte ) 0x54, ( byte ) 0xa2, ( byte ) 0x15, ( byte ) 0xa8, ( byte ) 0x45,
> @@ -189,11 +190,11 @@ public class NFoldTest
>           int n = 168;
>           String passPhrase = "ba";
>   
> -        int k = passPhrase.getBytes( StandardCharsets.UTF_8 ).length * 8;
> +        int k = Strings.getBytesUtf8( passPhrase ).length * 8;
>           int lcm = NFold.getLcm( n, k );
>           assertEquals( "LCM", 336, lcm );
>   
> -        byte[] nFoldValue = NFold.nFold( n, passPhrase.getBytes( StandardCharsets.UTF_8 ) );
> +        byte[] nFoldValue = NFold.nFold( n, Strings.getBytesUtf8( passPhrase ) );
>   
>           byte[] testVector =
>               { ( byte ) 0xfb, ( byte ) 0x25, ( byte ) 0xd5, ( byte ) 0x31, ( byte ) 0xae, ( byte ) 0x89, ( byte ) 0x74,
> @@ -213,11 +214,11 @@ public class NFoldTest
>           int n = 64;
>           String passPhrase = "kerberos";
>   
> -        int k = passPhrase.getBytes( StandardCharsets.UTF_8 ).length * 8;
> +        int k = Strings.getBytesUtf8( passPhrase ).length * 8;
>           int lcm = NFold.getLcm( n, k );
>           assertEquals( "LCM", 64, lcm );
>   
> -        byte[] nFoldValue = NFold.nFold( n, passPhrase.getBytes( StandardCharsets.UTF_8 ) );
> +        byte[] nFoldValue = NFold.nFold( n, Strings.getBytesUtf8( passPhrase ) );
>   
>           byte[] testVector =
>               { ( byte ) 0x6b, ( byte ) 0x65, ( byte ) 0x72, ( byte ) 0x62, ( byte ) 0x65, ( byte ) 0x72, ( byte ) 0x6f,
> @@ -235,11 +236,11 @@ public class NFoldTest
>           int n = 128;
>           String passPhrase = "kerberos";
>   
> -        int k = passPhrase.getBytes( StandardCharsets.UTF_8 ).length * 8;
> +        int k = Strings.getBytesUtf8( passPhrase ).length * 8;
>           int lcm = NFold.getLcm( n, k );
>           assertEquals( "LCM", 128, lcm );
>   
> -        byte[] nFoldValue = NFold.nFold( n, passPhrase.getBytes( StandardCharsets.UTF_8 ) );
> +        byte[] nFoldValue = NFold.nFold( n, Strings.getBytesUtf8( passPhrase ) );
>   
>           byte[] testVector =
>               { ( byte ) 0x6b, ( byte ) 0x65, ( byte ) 0x72, ( byte ) 0x62, ( byte ) 0x65, ( byte ) 0x72, ( byte ) 0x6f,
> @@ -258,11 +259,11 @@ public class NFoldTest
>           int n = 168;
>           String passPhrase = "kerberos";
>   
> -        int k = passPhrase.getBytes( StandardCharsets.UTF_8 ).length * 8;
> +        int k = Strings.getBytesUtf8( passPhrase ).length * 8;
>           int lcm = NFold.getLcm( n, k );
>           assertEquals( "LCM", 1344, lcm );
>   
> -        byte[] nFoldValue = NFold.nFold( n, passPhrase.getBytes( StandardCharsets.UTF_8 ) );
> +        byte[] nFoldValue = NFold.nFold( n, Strings.getBytesUtf8( passPhrase ) );
>   
>           byte[] testVector =
>               { ( byte ) 0x83, ( byte ) 0x72, ( byte ) 0xc2, ( byte ) 0x36, ( byte ) 0x34, ( byte ) 0x4e, ( byte ) 0x5f,
> @@ -282,11 +283,11 @@ public class NFoldTest
>           int n = 256;
>           String passPhrase = "kerberos";
>   
> -        int k = passPhrase.getBytes( StandardCharsets.UTF_8 ).length * 8;
> +        int k = Strings.getBytesUtf8( passPhrase ).length * 8;
>           int lcm = NFold.getLcm( n, k );
>           assertEquals( "LCM", 256, lcm );
>   
> -        byte[] nFoldValue = NFold.nFold( n, passPhrase.getBytes( StandardCharsets.UTF_8 ) );
> +        byte[] nFoldValue = NFold.nFold( n, Strings.getBytesUtf8( passPhrase ) );
>   
>           byte[] testVector =
>               { ( byte ) 0x6b, ( byte ) 0x65, ( byte ) 0x72, ( byte ) 0x62, ( byte ) 0x65, ( byte ) 0x72, ( byte ) 0x6f,
> diff --git a/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/ChangePasswdDataDecoderTest.java b/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/ChangePasswdDataDecoderTest.java
> index 42cc138..48c3629 100644
> --- a/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/ChangePasswdDataDecoderTest.java
> +++ b/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/ChangePasswdDataDecoderTest.java
> @@ -24,7 +24,6 @@ import static org.junit.Assert.assertArrayEquals;
>   import static org.junit.Assert.assertEquals;
>   
>   import java.nio.ByteBuffer;
> -import java.nio.charset.StandardCharsets;
>   
>   import org.apache.directory.api.asn1.ber.Asn1Decoder;
>   import org.apache.directory.api.util.Strings;
> @@ -104,7 +103,7 @@ public class ChangePasswdDataDecoderTest
>   
>           ChangePasswdData chngPwdData = container.getChngPwdData();
>   
> -        assertArrayEquals( "secret".getBytes( StandardCharsets.UTF_8 ), chngPwdData.getNewPasswd() );
> +        assertArrayEquals( Strings.getBytesUtf8( "secret" ), chngPwdData.getNewPasswd() );
>           assertEquals( "krbtgt", chngPwdData.getTargName().getNameString() );
>           assertEquals( "EXAMPLE.COM", chngPwdData.getTargRealm() );
>   
> @@ -157,7 +156,7 @@ public class ChangePasswdDataDecoderTest
>   
>           ChangePasswdData chngPwdData = container.getChngPwdData();
>   
> -        assertArrayEquals( "secret".getBytes( StandardCharsets.UTF_8 ), chngPwdData.getNewPasswd() );
> +        assertArrayEquals( Strings.getBytesUtf8( "secret" ), chngPwdData.getNewPasswd() );
>           assertEquals( "EXAMPLE.COM", chngPwdData.getTargRealm() );
>   
>           String encodedPdu = Strings.dumpBytes( chngPwdData.encode( null ).array() );
> @@ -214,7 +213,7 @@ public class ChangePasswdDataDecoderTest
>   
>           ChangePasswdData chngPwdData = container.getChngPwdData();
>   
> -        assertArrayEquals( "secret".getBytes( StandardCharsets.UTF_8 ), chngPwdData.getNewPasswd() );
> +        assertArrayEquals( Strings.getBytesUtf8( "secret" ), chngPwdData.getNewPasswd() );
>           assertEquals( "krbtgt", chngPwdData.getTargName().getNameString() );
>   
>           String encodedPdu = Strings.dumpBytes( chngPwdData.encode( null ).array() );
> @@ -250,7 +249,7 @@ public class ChangePasswdDataDecoderTest
>   
>           ChangePasswdData chngPwdData = container.getChngPwdData();
>   
> -        assertArrayEquals( "secret".getBytes( StandardCharsets.UTF_8 ), chngPwdData.getNewPasswd() );
> +        assertArrayEquals( Strings.getBytesUtf8( "secret" ), chngPwdData.getNewPasswd() );
>   
>           String encodedPdu = Strings.dumpBytes( chngPwdData.encode( null ).array() );
>           assertEquals( decodedPdu, encodedPdu );
> diff --git a/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KdcReqBodyDecoderTest.java b/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KdcReqBodyDecoderTest.java
> index 2f93bd2..766952a 100644
> --- a/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KdcReqBodyDecoderTest.java
> +++ b/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KdcReqBodyDecoderTest.java
> @@ -25,7 +25,6 @@ import static org.junit.Assert.assertNotNull;
>   import static org.junit.Assert.fail;
>   
>   import java.nio.ByteBuffer;
> -import java.nio.charset.StandardCharsets;
>   
>   import org.apache.directory.api.asn1.DecoderException;
>   import org.apache.directory.api.asn1.EncoderException;
> @@ -213,13 +212,13 @@ public class KdcReqBodyDecoderTest
>   
>           HostAddresses addresses = new HostAddresses();
>           addresses.addHostAddress(
> -            new HostAddress( HostAddrType.ADDRTYPE_INET, "192.168.0.1".getBytes( StandardCharsets.UTF_8 ) ) );
> +            new HostAddress( HostAddrType.ADDRTYPE_INET, Strings.getBytesUtf8( "192.168.0.1" ) ) );
>           addresses.addHostAddress(
> -            new HostAddress( HostAddrType.ADDRTYPE_INET, "192.168.0.2".getBytes( StandardCharsets.UTF_8 ) ) );
> +            new HostAddress( HostAddrType.ADDRTYPE_INET, Strings.getBytesUtf8( "192.168.0.2" ) ) );
>           body.setAddresses( addresses );
>   
>           EncryptedData encAuthorizationData = new EncryptedData( EncryptionType.AES128_CTS_HMAC_SHA1_96,
> -            "abcdef".getBytes( StandardCharsets.UTF_8 ) );
> +            Strings.getBytesUtf8( "abcdef" ) );
>           body.setEncAuthorizationData( encAuthorizationData );
>   
>           Ticket ticket1 = new Ticket();
> @@ -227,7 +226,7 @@ public class KdcReqBodyDecoderTest
>           ticket1.setRealm( "EXAMPLE.COM" );
>           ticket1.setSName( new PrincipalName( "client", PrincipalNameType.KRB_NT_PRINCIPAL ) );
>           ticket1.setEncPart(
> -            new EncryptedData( EncryptionType.AES128_CTS_HMAC_SHA1_96, "abcdef".getBytes( StandardCharsets.UTF_8 ) ) );
> +            new EncryptedData( EncryptionType.AES128_CTS_HMAC_SHA1_96, Strings.getBytesUtf8( "abcdef" ) ) );
>   
>           body.addAdditionalTicket( ticket1 );
>   
> @@ -236,7 +235,7 @@ public class KdcReqBodyDecoderTest
>           ticket2.setRealm( "EXAMPLE.COM" );
>           ticket2.setSName( new PrincipalName( "server", PrincipalNameType.KRB_NT_PRINCIPAL ) );
>           ticket2.setEncPart(
> -            new EncryptedData( EncryptionType.AES128_CTS_HMAC_SHA1_96, "abcdef".getBytes( StandardCharsets.UTF_8 ) ) );
> +            new EncryptedData( EncryptionType.AES128_CTS_HMAC_SHA1_96, Strings.getBytesUtf8( "abcdef" ) ) );
>   
>           body.addAdditionalTicket( ticket2 );
>   
> diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java
> index b464074..ad845fc 100644
> --- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java
> +++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java
> @@ -24,7 +24,6 @@ import static org.junit.Assert.assertEquals;
>   import static org.junit.Assert.assertNotNull;
>   import static org.junit.Assert.assertTrue;
>   
> -import java.nio.charset.StandardCharsets;
>   import java.util.concurrent.TimeUnit;
>   
>   import org.apache.directory.api.ldap.model.constants.SchemaConstants;
> @@ -33,6 +32,7 @@ import org.apache.directory.api.ldap.model.message.CompareRequestImpl;
>   import org.apache.directory.api.ldap.model.message.CompareResponse;
>   import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
>   import org.apache.directory.api.ldap.model.name.Dn;
> +import org.apache.directory.api.util.Strings;
>   import org.apache.directory.ldap.client.api.LdapNetworkConnection;
>   import org.apache.directory.ldap.client.api.future.CompareFuture;
>   import org.apache.directory.server.annotations.CreateLdapServer;
> @@ -85,7 +85,7 @@ public class ClientCompareRequestTest extends AbstractLdapTestUnit
>           assertTrue( response );
>   
>           response = connection.compare( dn.getName(), SchemaConstants.USER_PASSWORD_AT,
> -            "secret".getBytes( StandardCharsets.UTF_8 ) );
> +            Strings.getBytesUtf8( "secret" ) );
>           assertNotNull( response );
>           assertTrue( response );
>       }
> diff --git a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/MailExchangeRecordDecoderTest.java b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/MailExchangeRecordDecoderTest.java
> index 58741d7..30efca1 100644
> --- a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/MailExchangeRecordDecoderTest.java
> +++ b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/MailExchangeRecordDecoderTest.java
> @@ -21,7 +21,8 @@
>   package org.apache.directory.server.dns.io.decoder;
>   
>   
> -import java.nio.charset.StandardCharsets;
> +import static org.junit.Assert.assertEquals;
> +
>   import java.util.Map;
>   
>   import org.apache.directory.api.util.Strings;
> @@ -30,8 +31,6 @@ import org.apache.mina.core.buffer.IoBuffer;
>   import org.junit.Before;
>   import org.junit.Test;
>   
> -import static org.junit.Assert.assertEquals;
> -
>   
>   /**
>    * Tests for the MX resource record decoder.
> @@ -56,11 +55,11 @@ public class MailExchangeRecordDecoderTest
>           inputBuffer = IoBuffer.allocate( 128 );
>           inputBuffer.putShort( preference );
>           inputBuffer.put( ( byte ) domainNameParts[0].length() );
> -        inputBuffer.put( domainNameParts[0].getBytes( StandardCharsets.UTF_8 ) );
> +        inputBuffer.put( Strings.getBytesUtf8( domainNameParts[0] ) );
>           inputBuffer.put( ( byte ) domainNameParts[1].length() );
> -        inputBuffer.put( domainNameParts[1].getBytes( StandardCharsets.UTF_8 ) );
> +        inputBuffer.put( Strings.getBytesUtf8( domainNameParts[1] ) );
>           inputBuffer.put( ( byte ) domainNameParts[2].length() );
> -        inputBuffer.put( domainNameParts[2].getBytes( StandardCharsets.UTF_8 ) );
> +        inputBuffer.put( Strings.getBytesUtf8( domainNameParts[2] ) );
>           inputBuffer.put( ( byte ) 0x00 );
>           inputBuffer.flip();
>   
> diff --git a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/NameServerRecordDecoderTest.java b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/NameServerRecordDecoderTest.java
> index 2cf9915..04fd9cd 100644
> --- a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/NameServerRecordDecoderTest.java
> +++ b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/NameServerRecordDecoderTest.java
> @@ -21,7 +21,8 @@
>   package org.apache.directory.server.dns.io.decoder;
>   
>   
> -import java.nio.charset.StandardCharsets;
> +import static org.junit.Assert.assertEquals;
> +
>   import java.util.Map;
>   
>   import org.apache.directory.api.util.Strings;
> @@ -30,8 +31,6 @@ import org.apache.mina.core.buffer.IoBuffer;
>   import org.junit.Before;
>   import org.junit.Test;
>   
> -import static org.junit.Assert.assertEquals;
> -
>   
>   /**
>    * Tests for the NS resource record decoder.
> @@ -54,11 +53,11 @@ public class NameServerRecordDecoderTest
>       {
>           inputBuffer = IoBuffer.allocate( 128 );
>           inputBuffer.put( ( byte ) domainNameParts[0].length() );
> -        inputBuffer.put( domainNameParts[0].getBytes( StandardCharsets.UTF_8 ) );
> +        inputBuffer.put( Strings.getBytesUtf8( domainNameParts[0] ) );
>           inputBuffer.put( ( byte ) domainNameParts[1].length() );
> -        inputBuffer.put( domainNameParts[1].getBytes( StandardCharsets.UTF_8 ) );
> +        inputBuffer.put( Strings.getBytesUtf8( domainNameParts[1] ) );
>           inputBuffer.put( ( byte ) domainNameParts[2].length() );
> -        inputBuffer.put( domainNameParts[2].getBytes( StandardCharsets.UTF_8 ) );
> +        inputBuffer.put( Strings.getBytesUtf8( domainNameParts[2] ) );
>           inputBuffer.put( ( byte ) 0x00 );
>           inputBuffer.flip();
>   
> diff --git a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AbstractResourceRecordEncoderTest.java b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AbstractResourceRecordEncoderTest.java
> index 15f5c47..6dcb488 100644
> --- a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AbstractResourceRecordEncoderTest.java
> +++ b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AbstractResourceRecordEncoderTest.java
> @@ -20,11 +20,13 @@
>   package org.apache.directory.server.dns.io.encoder;
>   
>   
> +import static org.junit.Assert.assertEquals;
> +
>   import java.io.IOException;
>   import java.net.UnknownHostException;
> -import java.nio.charset.StandardCharsets;
>   import java.util.Map;
>   
> +import org.apache.directory.api.util.Strings;
>   import org.apache.directory.server.dns.messages.RecordClass;
>   import org.apache.directory.server.dns.messages.RecordType;
>   import org.apache.directory.server.dns.messages.ResourceRecord;
> @@ -32,7 +34,6 @@ import org.apache.directory.server.dns.messages.ResourceRecordImpl;
>   import org.apache.mina.core.buffer.IoBuffer;
>   import org.junit.Before;
>   import org.junit.Test;
> -import static org.junit.Assert.assertEquals;
>   
>   
>   /**
> @@ -60,11 +61,11 @@ public abstract class AbstractResourceRecordEncoderTest
>           expectedData = IoBuffer.allocate( 128 );
>           expectedData.put( ( byte ) 18 );
>           expectedData.put( ( byte ) domainNameParts[0].length() ); // 1
> -        expectedData.put( domainNameParts[0].getBytes( StandardCharsets.UTF_8 ) ); // + 5
> +        expectedData.put( Strings.getBytesUtf8( domainNameParts[0] ) ); // + 5
>           expectedData.put( ( byte ) domainNameParts[1].length() ); // + 1
> -        expectedData.put( domainNameParts[1].getBytes( StandardCharsets.UTF_8 ) ); // + 6
> +        expectedData.put( Strings.getBytesUtf8( domainNameParts[1] ) ); // + 6
>           expectedData.put( ( byte ) domainNameParts[2].length() ); // + 1
> -        expectedData.put( domainNameParts[2].getBytes( StandardCharsets.UTF_8 ) ); // + 3
> +        expectedData.put( Strings.getBytesUtf8( domainNameParts[2] ) ); // + 3
>           expectedData.put( ( byte ) 0x00 ); // + 1 = 18
>           expectedData.putShort( RecordType.A.convert() );
>           expectedData.putShort( RecordClass.IN.convert() );
> diff --git a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/CanonicalNameRecordEncoderTest.java b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/CanonicalNameRecordEncoderTest.java
> index c9e22c3..8fe6971 100644
> --- a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/CanonicalNameRecordEncoderTest.java
> +++ b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/CanonicalNameRecordEncoderTest.java
> @@ -41,7 +41,6 @@
>   package org.apache.directory.server.dns.io.encoder;
>   
>   
> -import java.nio.charset.StandardCharsets;
>   import java.util.HashMap;
>   import java.util.Map;
>   
> @@ -82,11 +81,11 @@ public class CanonicalNameRecordEncoderTest extends AbstractResourceRecordEncode
>       {
>           expectedData.put( ( byte ) 18 );
>           expectedData.put( ( byte ) cnameParts[0].length() ); // 1
> -        expectedData.put( cnameParts[0].getBytes( StandardCharsets.UTF_8 ) ); // + 5
> +        expectedData.put( Strings.getBytesUtf8( cnameParts[0] ) ); // + 5
>           expectedData.put( ( byte ) cnameParts[1].length() ); // + 1
> -        expectedData.put( cnameParts[1].getBytes( StandardCharsets.UTF_8 ) ); // + 6
> +        expectedData.put( Strings.getBytesUtf8( cnameParts[1] ) ); // + 6
>           expectedData.put( ( byte ) cnameParts[2].length() ); // + 1
> -        expectedData.put( cnameParts[2].getBytes( StandardCharsets.UTF_8 ) ); // + 3
> +        expectedData.put( Strings.getBytesUtf8( cnameParts[2] ) ); // + 3
>           expectedData.put( ( byte ) 0x00 ); // + 1 = 18
>       }
>   }
> diff --git a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/MailExchangeRecordEncoderTest.java b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/MailExchangeRecordEncoderTest.java
> index 6761712..31c9185 100644
> --- a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/MailExchangeRecordEncoderTest.java
> +++ b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/MailExchangeRecordEncoderTest.java
> @@ -21,7 +21,6 @@
>   package org.apache.directory.server.dns.io.encoder;
>   
>   
> -import java.nio.charset.StandardCharsets;
>   import java.util.HashMap;
>   import java.util.Map;
>   
> @@ -65,11 +64,11 @@ public class MailExchangeRecordEncoderTest extends AbstractResourceRecordEncoder
>           expectedData.put( ( byte ) 20 );
>           expectedData.putShort( Short.parseShort( mxPreference ) );
>           expectedData.put( ( byte ) mxParts[0].length() ); // 1
> -        expectedData.put( mxParts[0].getBytes( StandardCharsets.UTF_8 ) ); // + 4
> +        expectedData.put( Strings.getBytesUtf8( mxParts[0] ) ); // + 4
>           expectedData.put( ( byte ) mxParts[1].length() ); // + 1
> -        expectedData.put( mxParts[1].getBytes( StandardCharsets.UTF_8 ) ); // + 6
> +        expectedData.put( Strings.getBytesUtf8( mxParts[1] ) ); // + 6
>           expectedData.put( ( byte ) mxParts[2].length() ); // + 1
> -        expectedData.put( mxParts[2].getBytes( StandardCharsets.UTF_8 ) ); // + 3
> +        expectedData.put( Strings.getBytesUtf8( mxParts[2] ) ); // + 3
>           expectedData.put( ( byte ) 0x00 ); // + 1 = 17
>       }
>   }
> diff --git a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/NameServerRecordEncoderTest.java b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/NameServerRecordEncoderTest.java
> index 3463df1..d2f51f6 100644
> --- a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/NameServerRecordEncoderTest.java
> +++ b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/NameServerRecordEncoderTest.java
> @@ -21,7 +21,6 @@
>   package org.apache.directory.server.dns.io.encoder;
>   
>   
> -import java.nio.charset.StandardCharsets;
>   import java.util.HashMap;
>   import java.util.Map;
>   
> @@ -62,13 +61,13 @@ public class NameServerRecordEncoderTest extends AbstractResourceRecordEncoderTe
>       {
>           expectedData.put( ( byte ) 19 );
>           expectedData.put( ( byte ) nsParts[0].length() ); // 1
> -        expectedData.put( nsParts[0].getBytes( StandardCharsets.UTF_8 ) ); // + 3
> +        expectedData.put( Strings.getBytesUtf8( nsParts[0] ) ); // + 3
>           expectedData.put( ( byte ) nsParts[1].length() ); // + 1
> -        expectedData.put( nsParts[1].getBytes( StandardCharsets.UTF_8 ) ); // + 2
> +        expectedData.put( Strings.getBytesUtf8( nsParts[1] ) ); // + 2
>           expectedData.put( ( byte ) nsParts[2].length() ); // + 1
> -        expectedData.put( nsParts[2].getBytes( StandardCharsets.UTF_8 ) ); // + 7
> +        expectedData.put( Strings.getBytesUtf8( nsParts[2] ) ); // + 7
>           expectedData.put( ( byte ) nsParts[3].length() ); // + 1
> -        expectedData.put( nsParts[3].getBytes( StandardCharsets.UTF_8 ) ); // + 3
> +        expectedData.put( Strings.getBytesUtf8( nsParts[3] ) ); // + 3
>           expectedData.put( ( byte ) 0x00 ); // + 1 = 19
>       }
>   }
> diff --git a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/PointerRecordEncoderTest.java b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/PointerRecordEncoderTest.java
> index ebf1684..a13e00e 100644
> --- a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/PointerRecordEncoderTest.java
> +++ b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/PointerRecordEncoderTest.java
> @@ -21,7 +21,6 @@
>   package org.apache.directory.server.dns.io.encoder;
>   
>   
> -import java.nio.charset.StandardCharsets;
>   import java.util.HashMap;
>   import java.util.Map;
>   
> @@ -62,11 +61,11 @@ public class PointerRecordEncoderTest extends AbstractResourceRecordEncoderTest
>       {
>           expectedData.put( ( byte ) 15 );
>           expectedData.put( ( byte ) ptrParts[0].length() ); // 1
> -        expectedData.put( ptrParts[0].getBytes( StandardCharsets.UTF_8 ) ); // + 3
> +        expectedData.put( Strings.getBytesUtf8( ptrParts[0] ) ); // + 3
>           expectedData.put( ( byte ) ptrParts[1].length() ); // + 1
> -        expectedData.put( ptrParts[1].getBytes( StandardCharsets.UTF_8 ) ); // + 6
> +        expectedData.put( Strings.getBytesUtf8( ptrParts[1] ) ); // + 6
>           expectedData.put( ( byte ) ptrParts[2].length() ); // + 1
> -        expectedData.put( ptrParts[2].getBytes( StandardCharsets.UTF_8 ) ); // + 3
> +        expectedData.put( Strings.getBytesUtf8( ptrParts[2] ) ); // + 3
>           expectedData.put( ( byte ) 0x00 ); // + 1 = 15
>       }
>   }
> diff --git a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/QuestionRecordEncoderTest.java b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/QuestionRecordEncoderTest.java
> index c367c86..0a03140 100644
> --- a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/QuestionRecordEncoderTest.java
> +++ b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/QuestionRecordEncoderTest.java
> @@ -21,15 +21,15 @@
>   package org.apache.directory.server.dns.io.encoder;
>   
>   
> +import static org.junit.Assert.assertEquals;
> +
> +import org.apache.directory.api.util.Strings;
>   import org.apache.directory.server.dns.messages.QuestionRecord;
>   import org.apache.directory.server.dns.messages.RecordClass;
>   import org.apache.directory.server.dns.messages.RecordType;
>   import org.apache.mina.core.buffer.IoBuffer;
>   import org.junit.Before;
>   import org.junit.Test;
> -import static org.junit.Assert.assertEquals;
> -
> -import java.nio.charset.StandardCharsets;
>   
>   
>   /**
> @@ -58,11 +58,11 @@ public class QuestionRecordEncoderTest
>   
>           expectedData = IoBuffer.allocate( 128 );
>           expectedData.put( ( byte ) nameParts[0].length() ); // 1
> -        expectedData.put( nameParts[0].getBytes( StandardCharsets.UTF_8 ) ); // + 3
> +        expectedData.put( Strings.getBytesUtf8( nameParts[0] ) ); // + 3
>           expectedData.put( ( byte ) nameParts[1].length() ); // + 1
> -        expectedData.put( nameParts[1].getBytes( StandardCharsets.UTF_8 ) ); // + 6
> +        expectedData.put( Strings.getBytesUtf8( nameParts[1] ) ); // + 6
>           expectedData.put( ( byte ) nameParts[2].length() ); // + 1
> -        expectedData.put( nameParts[2].getBytes( StandardCharsets.UTF_8 ) ); // + 3
> +        expectedData.put( Strings.getBytesUtf8( nameParts[2] ) ); // + 3
>           expectedData.put( ( byte ) 0x00 ); // + 1 = 16
>           expectedData.putShort( type.convert() );
>           expectedData.putShort( rClass.convert() );
> diff --git a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java
> index 58e6203..23f218e 100644
> --- a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java
> +++ b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java
> @@ -21,7 +21,6 @@
>   package org.apache.directory.server.dns.io.encoder;
>   
>   
> -import java.nio.charset.StandardCharsets;
>   import java.util.HashMap;
>   import java.util.Map;
>   
> @@ -71,11 +70,11 @@ public class ServerSelectionRecordEncoderTest extends AbstractResourceRecordEnco
>           expectedData.putShort( Short.parseShort( weight ) );
>           expectedData.putShort( Short.parseShort( port ) );
>           expectedData.put( ( byte ) srvParts[0].length() ); // 1
> -        expectedData.put( srvParts[0].getBytes( StandardCharsets.UTF_8 ) ); // + 3
> +        expectedData.put( Strings.getBytesUtf8( srvParts[0] ) ); // + 3
>           expectedData.put( ( byte ) srvParts[1].length() ); // + 1
> -        expectedData.put( srvParts[1].getBytes( StandardCharsets.UTF_8 ) ); // + 6
> +        expectedData.put( Strings.getBytesUtf8( srvParts[1] ) ); // + 6
>           expectedData.put( ( byte ) srvParts[2].length() ); // + 1
> -        expectedData.put( srvParts[2].getBytes( StandardCharsets.UTF_8 ) ); // + 3
> +        expectedData.put( Strings.getBytesUtf8( srvParts[2] ) ); // + 3
>           expectedData.put( ( byte ) 0x00 ); // + 1 = 16
>       }
>   }
> diff --git a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java
> index be4787f..3ac8182 100644
> --- a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java
> +++ b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java
> @@ -21,7 +21,6 @@
>   package org.apache.directory.server.dns.io.encoder;
>   
>   
> -import java.nio.charset.StandardCharsets;
>   import java.util.HashMap;
>   import java.util.Map;
>   
> @@ -76,18 +75,18 @@ public class StartOfAuthorityRecordEncoderTest extends AbstractResourceRecordEnc
>       {
>           expectedData.put( ( byte ) 60 ); // 1 + 18 + 1 + 20 + 4 + 4 + 4 + 4 + 4
>           expectedData.put( ( byte ) mNameParts[0].length() ); // 1
> -        expectedData.put( mNameParts[0].getBytes( StandardCharsets.UTF_8 ) ); // + 2
> +        expectedData.put( Strings.getBytesUtf8( mNameParts[0] ) ); // + 2
>           expectedData.put( ( byte ) mNameParts[1].length() ); // + 1
> -        expectedData.put( mNameParts[1].getBytes( StandardCharsets.UTF_8 ) ); // + 9
> +        expectedData.put( Strings.getBytesUtf8( mNameParts[1] ) ); // + 9
>           expectedData.put( ( byte ) mNameParts[2].length() ); // + 1
> -        expectedData.put( mNameParts[2].getBytes( StandardCharsets.UTF_8 ) ); // + 3
> +        expectedData.put( Strings.getBytesUtf8( mNameParts[2] ) ); // + 3
>           expectedData.put( ( byte ) 0x00 ); // + 1 = 18
>           expectedData.put( ( byte ) rNameParts[0].length() ); // 1
> -        expectedData.put( rNameParts[0].getBytes( StandardCharsets.UTF_8 ) ); // + 4
> +        expectedData.put( Strings.getBytesUtf8( rNameParts[0] ) ); // + 4
>           expectedData.put( ( byte ) rNameParts[1].length() ); // + 1
> -        expectedData.put( rNameParts[1].getBytes( StandardCharsets.UTF_8 ) ); // + 9
> +        expectedData.put( Strings.getBytesUtf8( rNameParts[1] ) ); // + 9
>           expectedData.put( ( byte ) rNameParts[2].length() ); // + 1
> -        expectedData.put( rNameParts[2].getBytes( StandardCharsets.UTF_8 ) ); // + 3
> +        expectedData.put( Strings.getBytesUtf8( rNameParts[2] ) ); // + 3
>           expectedData.put( ( byte ) 0x00 ); // + 1 = 20
>           expectedData.putInt( ( int ) Long.parseLong( serial ) );
>           expectedData.putInt( Integer.parseInt( refresh ) );
> diff --git a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/TextRecordEncoderTest.java b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/TextRecordEncoderTest.java
> index a7a2e3f..306dd56 100644
> --- a/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/TextRecordEncoderTest.java
> +++ b/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/TextRecordEncoderTest.java
> @@ -21,7 +21,6 @@
>   package org.apache.directory.server.dns.io.encoder;
>   
>   
> -import java.nio.charset.StandardCharsets;
>   import java.util.HashMap;
>   import java.util.Map;
>   
> @@ -61,6 +60,6 @@ public class TextRecordEncoderTest extends AbstractResourceRecordEncoderTest
>       {
>           expectedData.put( ( byte ) ( characterString.length() + 1 ) );
>           expectedData.put( ( byte ) characterString.length() );
> -        expectedData.put( characterString.getBytes( StandardCharsets.UTF_8 ) );
> +        expectedData.put( Strings.getBytesUtf8( characterString ) );
>       }
>   }
> diff --git a/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/DirectoryPrincipalStore.java b/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/DirectoryPrincipalStore.java
> index 7054195..e9307bc 100644
> --- a/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/DirectoryPrincipalStore.java
> +++ b/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/DirectoryPrincipalStore.java
> @@ -20,8 +20,6 @@
>   package org.apache.directory.server.kerberos.kdc;
>   
>   
> -import java.nio.charset.StandardCharsets;
> -
>   import javax.security.auth.kerberos.KerberosPrincipal;
>   
>   import org.apache.directory.api.ldap.model.constants.AuthenticationLevel;
> @@ -94,7 +92,7 @@ public class DirectoryPrincipalStore implements PrincipalStore
>               if ( ebyPrincipalEntry == null )
>               {
>                   throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_HARDERROR,
> -                    ( "No such principal " + byPrincipal ).getBytes( StandardCharsets.UTF_8 ) );
> +                    Strings.getBytesUtf8( ( "No such principal " + byPrincipal ) ) );
>               }
>   
>               SchemaManager schemaManager = directoryService.getSchemaManager();
> diff --git a/server-integ/src/test/java/org/apache/directory/server/operations/bind/BogusNtlmProvider.java b/server-integ/src/test/java/org/apache/directory/server/operations/bind/BogusNtlmProvider.java
> index 7bc8593..d39758b 100644
> --- a/server-integ/src/test/java/org/apache/directory/server/operations/bind/BogusNtlmProvider.java
> +++ b/server-integ/src/test/java/org/apache/directory/server/operations/bind/BogusNtlmProvider.java
> @@ -21,8 +21,7 @@
>   package org.apache.directory.server.operations.bind;
>   
>   
> -import java.nio.charset.StandardCharsets;
> -
> +import org.apache.directory.api.util.Strings;
>   import org.apache.directory.server.ldap.handlers.sasl.ntlm.NtlmProvider;
>   import org.apache.mina.core.session.IoSession;
>   
> @@ -49,7 +48,7 @@ public class BogusNtlmProvider implements NtlmProvider
>       public byte[] generateChallenge( IoSession session, byte[] type1reponse ) throws Exception
>       {
>           this.type1response = type1reponse;
> -        return "challenge".getBytes( StandardCharsets.UTF_8 );
> +        return Strings.getBytesUtf8( "challenge" );
>       }
>   
>   
> diff --git a/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java b/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
> index 61d7170..97348bb 100644
> --- a/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
> +++ b/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
> @@ -26,7 +26,6 @@ import static org.junit.Assert.fail;
>   
>   import java.lang.reflect.Field;
>   import java.nio.ByteBuffer;
> -import java.nio.charset.StandardCharsets;
>   import java.util.Locale;
>   import java.util.Objects;
>   
> @@ -54,6 +53,7 @@ import org.apache.directory.api.ldap.model.message.Message;
>   import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
>   import org.apache.directory.api.ldap.model.name.Dn;
>   import org.apache.directory.api.util.Network;
> +import org.apache.directory.api.util.Strings;
>   import org.apache.directory.ldap.client.api.LdapConnection;
>   import org.apache.directory.ldap.client.api.LdapNetworkConnection;
>   import org.apache.directory.ldap.client.api.SaslCramMd5Request;
> @@ -568,19 +568,19 @@ public class SaslBindIT extends AbstractLdapTestUnit
>           BogusNtlmProvider provider = getNtlmProviderUsingReflection();
>   
>           NtlmSaslBindClient client = new NtlmSaslBindClient( SupportedSaslMechanisms.NTLM );
> -        BindResponse type2response = client.bindType1( "type1_test".getBytes( StandardCharsets.UTF_8 ) );
> +        BindResponse type2response = client.bindType1( Strings.getBytesUtf8( "type1_test" ) );
>           assertEquals( 1, type2response.getMessageId() );
>           assertEquals( ResultCodeEnum.SASL_BIND_IN_PROGRESS, type2response.getLdapResult().getResultCode() );
>           assertTrue(
> -            Objects.deepEquals( "type1_test".getBytes( StandardCharsets.UTF_8 ), provider.getType1Response() ) );
> +            Objects.deepEquals( Strings.getBytesUtf8( "type1_test" ), provider.getType1Response() ) );
>           assertTrue(
> -            Objects.deepEquals( "challenge".getBytes( StandardCharsets.UTF_8 ), type2response.getServerSaslCreds() ) );
> +            Objects.deepEquals( Strings.getBytesUtf8( "challenge" ), type2response.getServerSaslCreds() ) );
>   
> -        BindResponse finalResponse = client.bindType3( "type3_test".getBytes( StandardCharsets.UTF_8 ) );
> +        BindResponse finalResponse = client.bindType3( Strings.getBytesUtf8( "type3_test" ) );
>           assertEquals( 2, finalResponse.getMessageId() );
>           assertEquals( ResultCodeEnum.SUCCESS, finalResponse.getLdapResult().getResultCode() );
>           assertTrue(
> -            Objects.deepEquals( "type3_test".getBytes( StandardCharsets.UTF_8 ), provider.getType3Response() ) );
> +            Objects.deepEquals( Strings.getBytesUtf8( "type3_test" ), provider.getType3Response() ) );
>       }
>   
>   
> @@ -600,16 +600,16 @@ public class SaslBindIT extends AbstractLdapTestUnit
>           ntlmHandler.setNtlmProvider( provider );
>   
>           NtlmSaslBindClient client = new NtlmSaslBindClient( SupportedSaslMechanisms.GSS_SPNEGO );
> -        BindResponse type2response = client.bindType1( "type1_test".getBytes( StandardCharsets.UTF_8 ) );
> +        BindResponse type2response = client.bindType1( Strings.getBytesUtf8( "type1_test" ) );
>           assertEquals( 1, type2response.getMessageId() );
>           assertEquals( ResultCodeEnum.SASL_BIND_IN_PROGRESS, type2response.getLdapResult().getResultCode() );
> -        assertTrue( Objects.deepEquals( "type1_test".getBytes( StandardCharsets.UTF_8 ), provider.getType1Response() ) );
> -        assertTrue( Objects.deepEquals( "challenge".getBytes( StandardCharsets.UTF_8 ), type2response.getServerSaslCreds() ) );
> +        assertTrue( Objects.deepEquals( Strings.getBytesUtf8( "type1_test" ), provider.getType1Response() ) );
> +        assertTrue( Objects.deepEquals( Strings.getBytesUtf8( "challenge" ), type2response.getServerSaslCreds() ) );
>   
> -        BindResponse finalResponse = client.bindType3( "type3_test".getBytes( StandardCharsets.UTF_8 ) );
> +        BindResponse finalResponse = client.bindType3( Strings.getBytesUtf8( "type3_test" ) );
>           assertEquals( 2, finalResponse.getMessageId() );
>           assertEquals( ResultCodeEnum.SUCCESS, finalResponse.getLdapResult().getResultCode() );
> -        assertTrue( Objects.deepEquals( "type3_test".getBytes( StandardCharsets.UTF_8 ), provider.getType3Response() ) );
> +        assertTrue( Objects.deepEquals( Strings.getBytesUtf8( "type3_test" ), provider.getType3Response() ) );
>       }
>   
>   
> diff --git a/server-integ/src/test/java/org/apache/directory/server/operations/extended/PwdModifyIT.java b/server-integ/src/test/java/org/apache/directory/server/operations/extended/PwdModifyIT.java
> index f6920c4..82d48f2 100644
> --- a/server-integ/src/test/java/org/apache/directory/server/operations/extended/PwdModifyIT.java
> +++ b/server-integ/src/test/java/org/apache/directory/server/operations/extended/PwdModifyIT.java
> @@ -28,8 +28,6 @@ import static org.junit.Assert.assertNotEquals;
>   import static org.junit.Assert.assertNotNull;
>   import static org.junit.Assert.assertNull;
>   
> -import java.nio.charset.StandardCharsets;
> -
>   import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyErrorEnum;
>   import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyResponse;
>   import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyResponseImpl;
> @@ -552,7 +550,7 @@ public class PwdModifyIT extends AbstractLdapTestUnit
>       {
>           LdapConnection adminConnection = getAdminNetworkConnection( getLdapServer() );
>   
> -        byte[] password = "secret1".getBytes( StandardCharsets.UTF_8 );
> +        byte[] password = Strings.getBytesUtf8( "secret1" );
>           byte[] credHash = PasswordUtil.createStoragePassword( password, LdapSecurityConstants.HASH_METHOD_SHA256 );
>           addUser( adminConnection, "User11", credHash );
>   
> diff --git a/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java b/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java
> index 67560e5..c3af378 100644
> --- a/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java
> +++ b/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java
> @@ -37,13 +37,12 @@ import static org.junit.Assert.assertNull;
>   import static org.junit.Assert.assertTrue;
>   
>   import java.nio.charset.Charset;
> -import java.nio.charset.StandardCharsets;
>   import java.util.ArrayList;
>   import java.util.Date;
>   import java.util.List;
>   
> -import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyRequest;
>   import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyErrorEnum;
> +import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyRequest;
>   import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyRequestImpl;
>   import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyResponse;
>   import org.apache.directory.api.ldap.model.constants.LdapSecurityConstants;
> @@ -68,10 +67,11 @@ import org.apache.directory.api.ldap.model.message.Response;
>   import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
>   import org.apache.directory.api.ldap.model.name.Dn;
>   import org.apache.directory.api.ldap.model.password.PasswordUtil;
> -import org.apache.directory.api.util.MockTimeProvider;
> -import org.apache.directory.api.util.TimeProvider;
>   import org.apache.directory.api.util.DateUtils;
> +import org.apache.directory.api.util.MockTimeProvider;
>   import org.apache.directory.api.util.Network;
> +import org.apache.directory.api.util.Strings;
> +import org.apache.directory.api.util.TimeProvider;
>   import org.apache.directory.ldap.client.api.LdapConnection;
>   import org.apache.directory.ldap.client.api.LdapNetworkConnection;
>   import org.apache.directory.server.annotations.CreateLdapServer;
> @@ -772,7 +772,7 @@ public class PasswordPolicyIT extends AbstractLdapTestUnit
>   
>           BindRequest bindReq = new BindRequestImpl();
>           bindReq.setDn( userDn );
> -        bindReq.setCredentials( password.getBytes( StandardCharsets.UTF_8 ) );
> +        bindReq.setCredentials( Strings.getBytesUtf8( password ) );
>           bindReq.addControl( PP_REQ_CTRL );
>   
>           try (LdapConnection userCon = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() ))
> @@ -819,7 +819,7 @@ public class PasswordPolicyIT extends AbstractLdapTestUnit
>   
>           BindRequest bindReq = new BindRequestImpl();
>           bindReq.setDn( userDn );
> -        bindReq.setCredentials( password.getBytes( StandardCharsets.UTF_8 ) );
> +        bindReq.setCredentials( Strings.getBytesUtf8( password ) );
>           bindReq.addControl( PP_REQ_CTRL );
>   
>           try (LdapConnection userCon = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() ))
> @@ -884,7 +884,7 @@ public class PasswordPolicyIT extends AbstractLdapTestUnit
>   
>           BindRequest bindReq = new BindRequestImpl();
>           bindReq.setDn( userDn );
> -        bindReq.setCredentials( password.getBytes( StandardCharsets.UTF_8 ) );
> +        bindReq.setCredentials( Strings.getBytesUtf8( password ) );
>           bindReq.addControl( PP_REQ_CTRL );
>   
>           try (LdapConnection userCon = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() ))
> @@ -948,7 +948,7 @@ public class PasswordPolicyIT extends AbstractLdapTestUnit
>   
>           BindRequest bindReq = new BindRequestImpl();
>           bindReq.setDn( userDn );
> -        bindReq.setCredentials( password.getBytes( StandardCharsets.UTF_8 ) );
> +        bindReq.setCredentials( Strings.getBytesUtf8( password ) );
>           bindReq.addControl( PP_REQ_CTRL );
>   
>           try (LdapConnection userCon = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() ))
> diff --git a/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java b/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java
> index cb2e10a..b9a6d39 100644
> --- a/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java
> +++ b/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java
> @@ -25,23 +25,19 @@ import static org.junit.Assert.assertTrue;
>   
>   import java.io.File;
>   import java.io.IOException;
> -import java.nio.charset.StandardCharsets;
>   import java.util.ArrayList;
>   import java.util.List;
>   import java.util.concurrent.atomic.AtomicInteger;
>   
> -import org.apache.directory.api.util.FileUtils;
> -import org.apache.directory.api.ldap.codec.api.LdapApiService;
> -import org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncDoneValueFactory;
> -import org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncRequestValueFactory;
> -import org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncStateValueFactory;
>   import org.apache.directory.api.ldap.model.entry.DefaultEntry;
>   import org.apache.directory.api.ldap.model.entry.Entry;
>   import org.apache.directory.api.ldap.model.message.SearchRequest;
>   import org.apache.directory.api.ldap.model.message.SearchRequestImpl;
>   import org.apache.directory.api.ldap.model.name.Dn;
>   import org.apache.directory.api.ldap.model.schema.SchemaManager;
> +import org.apache.directory.api.util.FileUtils;
>   import org.apache.directory.api.util.Network;
> +import org.apache.directory.api.util.Strings;
>   import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
>   import org.apache.directory.server.annotations.CreateLdapServer;
>   import org.apache.directory.server.annotations.CreateTransport;
> @@ -63,7 +59,6 @@ import org.junit.After;
>   import org.junit.AfterClass;
>   import org.junit.Before;
>   import org.junit.BeforeClass;
> -import org.junit.Ignore;
>   import org.junit.Rule;
>   import org.junit.Test;
>   
> @@ -244,7 +239,7 @@ public class ClientInitialRefreshIT
>           config.setRemoteHost( Network.LOOPBACK_HOSTNAME );
>           config.setRemotePort( 16000 );
>           config.setReplUserDn( "uid=admin,ou=system" );
> -        config.setReplUserPassword( "secret".getBytes( StandardCharsets.UTF_8 ) );
> +        config.setReplUserPassword( Strings.getBytesUtf8( "secret" ) );
>           config.setUseTls( false );
>           config.setBaseDn( "dc=example,dc=com" );
>   
> diff --git a/server-integ/src/test/java/org/apache/directory/server/replication/StaleEventLogDetectionIT.java b/server-integ/src/test/java/org/apache/directory/server/replication/StaleEventLogDetectionIT.java
> index 7d2c988..0139e61 100644
> --- a/server-integ/src/test/java/org/apache/directory/server/replication/StaleEventLogDetectionIT.java
> +++ b/server-integ/src/test/java/org/apache/directory/server/replication/StaleEventLogDetectionIT.java
> @@ -26,10 +26,8 @@ import static org.junit.Assert.assertTrue;
>   
>   import java.io.File;
>   import java.io.IOException;
> -import java.nio.charset.StandardCharsets;
>   import java.util.concurrent.atomic.AtomicInteger;
>   
> -import org.apache.directory.api.util.FileUtils;
>   import org.apache.directory.api.ldap.codec.api.LdapApiService;
>   import org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncDoneValueFactory;
>   import org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncRequestValueFactory;
> @@ -40,7 +38,9 @@ import org.apache.directory.api.ldap.model.message.SearchRequest;
>   import org.apache.directory.api.ldap.model.message.SearchRequestImpl;
>   import org.apache.directory.api.ldap.model.name.Dn;
>   import org.apache.directory.api.ldap.model.schema.SchemaManager;
> +import org.apache.directory.api.util.FileUtils;
>   import org.apache.directory.api.util.Network;
> +import org.apache.directory.api.util.Strings;
>   import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
>   import org.apache.directory.server.annotations.CreateLdapServer;
>   import org.apache.directory.server.annotations.CreateTransport;
> @@ -246,7 +246,7 @@ public class StaleEventLogDetectionIT
>           config.setRemoteHost( Network.LOOPBACK_HOSTNAME );
>           config.setRemotePort( 16000 );
>           config.setReplUserDn( "uid=admin,ou=system" );
> -        config.setReplUserPassword( "secret".getBytes( StandardCharsets.UTF_8 ) );
> +        config.setReplUserPassword( Strings.getBytesUtf8( "secret" ) );
>           config.setUseTls( false );
>           config.setBaseDn( "dc=example,dc=com" );
>           config.setRefreshInterval( 1000 );
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@directory.apache.org
For additional commands, e-mail: dev-help@directory.apache.org