Class CBORUtility

java.lang.Object
com.tivoli.am.fim.cbor.CBORUtility

public final class CBORUtility extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Object
    canonicalDecode(byte[] cborData)
    Decode a CBOR byte array according to the CTAP2 canonical CBOR encoding form.
    static byte[]
    Encode CBOR data according to the CTAP2 canonical CBOR encoding form.
    static Object
    decode(byte[] cborData, String expectedDataType)
    Decode a CBOR byte array to a Java primitive.
    static byte[]
    encode(Object toEncode)
    Encode the given primitive java Object to a CBOR byte array.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CBORUtility

      public CBORUtility()
  • Method Details

    • canonicalDecode

      public static Object canonicalDecode(byte[] cborData)
      Decode a CBOR byte array according to the CTAP2 canonical CBOR encoding form. The exact CTAP2 canonical rule set can be found in the FIDO Alliance CTAP2 specification.
    • canonicalEncode

      public static byte[] canonicalEncode(Object toEncode)
      Encode CBOR data according to the CTAP2 canonical CBOR encoding form. The exact CTAP2 canonical rule set can be found in the FIDO Alliance CTAP2 specification.
    • decode

      public static Object decode(byte[] cborData, String expectedDataType)
      Decode a CBOR byte array to a Java primitive. Valid primitive types include: String, Integer, Double, Boolean, Array, Map. If the data cannot be decoded or read into the given primitive, then this method will return null.
      Parameters:
      cborData - CBOR bytes to be decoded.
      expectedDataType - Data type of resulting decoded CBOR
      Returns:
      decode CBOR Object if the encoded data is valid; else null.
    • encode

      public static byte[] encode(Object toEncode)
      Encode the given primitive java Object to a CBOR byte array. Valid java primitives include: String, Integer, Double, Boolean, Array, Map. If the given object cannot be serialized and/or CBOR encoded then this method will return null.
      Parameters:
      toEncode - Object to be CBOR encoded.
      Returns:
      A CBOR encoded byte array of the given object if the Object is valid; else null.