Class ByteArray

java.lang.Object
com.yubico.webauthn.data.ByteArray
All Implemented Interfaces:
Comparable<ByteArray>

public final class ByteArray extends Object implements Comparable<ByteArray>
An immutable byte array with support for encoding/decoding to/from various encodings.
  • Constructor Details

    • ByteArray

      public ByteArray(@NonNull @lombok.NonNull byte[] bytes)
      Create a new instance by copying the contents of bytes.
  • Method Details

    • fromBase64

      public static ByteArray fromBase64(@NonNull @NonNull String base64)
      Create a new instance by decoding base64 as classic Base64 data.
    • fromBase64Url

      public static ByteArray fromBase64Url(@NonNull @NonNull String base64url) throws Base64UrlException
      Create a new instance by decoding base64url as Base64Url data.
      Throws:
      Base64UrlException - if base64url is not valid Base64Url data.
    • fromHex

      public static ByteArray fromHex(@NonNull @NonNull String hex) throws HexException
      Create a new instance by decoding hex as hexadecimal data.
      Throws:
      HexException - if hex is not valid hexadecimal data.
    • concat

      public ByteArray concat(@NonNull @NonNull ByteArray tail)
      Returns:
      a new instance containing a copy of this instance followed by a copy of tail .
    • isEmpty

      public boolean isEmpty()
    • size

      public int size()
    • getBytes

      public byte[] getBytes()
      Returns:
      a copy of the raw byte contents.
    • getBase64

      public String getBase64()
      Returns:
      the content bytes encoded as classic Base64 data.
    • getBase64Url

      public String getBase64Url()
      Returns:
      the content bytes encoded as Base64Url data, without padding.
    • getHex

      public String getHex()
      Returns:
      the content bytes encoded as hexadecimal data.
    • compareTo

      public int compareTo(ByteArray other)
      Specified by:
      compareTo in interface Comparable<ByteArray>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object