protected char[] toChars(byte[] bytes) {
    if (bytes == null) {
      return null;
    } else {
      ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
      CharBuffer charBuffer = Charset.forName("UTF-8").decode(byteBuffer);

      char[] chars = Arrays.copyOfRange(charBuffer.array(), charBuffer.position(), charBuffer.limit());

      // Clear sensitive data
      Arrays.fill(charBuffer.array(), '\u0000');
      Arrays.fill(byteBuffer.array(), (byte) 0);

      return chars;
    }
  }
Converts an array of bytes to an array of character by decoding the bytes using the UTF-8
character set.
<p/>
An attempt is made to clear out sensitive data by filling any buffers with 0's

@param bytes the array of bytes to convert
@return an array of chars, or null if the original array was null
ambari-server/src/main/java/org/apache/ambari/server/security/encryption/AbstractCredentialStore.java