Class CBOREncodeOptions


  • public final class CBOREncodeOptions
    extends java.lang.Object
    Specifies options for encoding and decoding CBOR objects.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean getAllowDuplicateKeys()
      Gets a value indicating whether to allow duplicate keys when reading CBOR objects from a data stream.
      boolean getAllowEmpty()
      Gets a value indicating whether decoding a CBOR object will return null instead of a CBOR object if the stream has no content or the end of the stream is reached before decoding begins.
      boolean getCtap2Canonical()
      Gets a value indicating whether CBOR objects: When encoding, are written out using the CTAP2 canonical CBOR encoding form, which is useful for implementing Web Authentication. When decoding, are checked for compliance with the CTAP2 canonical encoding form. In this form, CBOR tags are not used, map keys are written out in a canonical order, a maximum depth of four levels of arrays and/or maps is allowed, duplicate map keys are not allowed when decoding, and floating-point numbers are written out in their 64-bit encoding form regardless of whether their value can be encoded without loss in a smaller form.
      boolean getResolveReferences()
      Gets a value indicating whether to resolve references to sharable objects and sharable strings in the process of decoding a CBOR object.
      boolean getUseIndefLengthStrings()
      Gets a value indicating whether to encode strings with an indefinite-length encoding under certain circumstances.
      java.lang.String toString()
      Gets the values of this options object's properties in text form.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • Default

        public static final CBOREncodeOptions Default
        Default options for CBOR objects. Disallow duplicate keys, and always encode strings using definite-length encoding.
      • DefaultCtap2Canonical

        public static final CBOREncodeOptions DefaultCtap2Canonical
        Default options for CBOR objects serialized using the CTAP2 canonicalization (used in Web Authentication, among other specifications). Disallow duplicate keys, and always encode strings using definite-length encoding.
    • Constructor Detail

      • CBOREncodeOptions

        public CBOREncodeOptions()
        Initializes a new instance of the CBOREncodeOptions class.
      • CBOREncodeOptions

        public CBOREncodeOptions​(boolean useIndefLengthStrings,
                                 boolean allowDuplicateKeys)
        Initializes a new instance of the CBOREncodeOptions class.
        Parameters:
        useIndefLengthStrings - A value indicating whether to always encode strings with a definite-length encoding.
        allowDuplicateKeys - A value indicating whether to disallow duplicate keys when reading CBOR objects from a data stream.
      • CBOREncodeOptions

        public CBOREncodeOptions​(boolean useIndefLengthStrings,
                                 boolean allowDuplicateKeys,
                                 boolean ctap2Canonical)
        Initializes a new instance of the CBOREncodeOptions class.
        Parameters:
        useIndefLengthStrings - A value indicating whether to encode strings with a definite-length encoding in certain cases.
        allowDuplicateKeys - A value indicating whether to allow duplicate keys when reading CBOR objects from a data stream.
        ctap2Canonical - A value indicating whether CBOR objects are written out using the CTAP2 canonical CBOR encoding form, which is useful for implementing Web Authentication.
      • CBOREncodeOptions

        public CBOREncodeOptions​(java.lang.String paramString)
        Initializes a new instance of the CBOREncodeOptions class.
        Parameters:
        paramString - A string setting forth the options to use. This is a semicolon-separated list of options, each of which has a key and a value separated by an equal sign ("="). Whitespace and line separators are not allowed to appear between the semicolons or between the equal signs, nor may the string begin or end with whitespace. The string can be empty, but cannot be null. The following is an example of this parameter: allowduplicatekeys = true;ctap2Canonical = true. The key can be any one of the following in any combination of case: allowduplicatekeys, ctap2canonical, resolvereferences, useindeflengthstrings, allowempty. Keys other than these are ignored. (Keys are compared using a basic case-insensitive comparison, in which two strings are equal if they match after converting the basic upper-case letters A to Z (U+0041 to U+005A) in both strings to basic lower-case letters.) If two or more key/value pairs have equal keys (in a basic case-insensitive comparison), the value given for the last such key is used. The four keys just given can have a value of 1, true, yes, or on (in any combination of case), which means true, and any other value meaning false. For example, allowduplicatekeys = Yes and allowduplicatekeys = 1 both set the AllowDuplicateKeys property to true.
        Throws:
        java.lang.NullPointerException - The parameter paramString is null.
    • Method Detail

      • toString

        public java.lang.String toString()
        Gets the values of this options object's properties in text form.
        Overrides:
        toString in class java.lang.Object
        Returns:
        A text string containing the values of this options object's properties. The format of the string is the same as the one described in the string constructor for this class.
      • getResolveReferences

        public final boolean getResolveReferences()
        Gets a value indicating whether to resolve references to sharable objects and sharable strings in the process of decoding a CBOR object.

        Sharable objects are marked with tag 28, and references to those objects are marked with tag 29 (where a reference of 0 means the first sharable object in the CBOR stream, a reference of 1 means the second, and so on). Sharable strings (byte strings and text strings) appear within an enclosing object marked with tag 256, and references to them are marked with tag 25; in general, a string is sharable only if storing its reference rather than the string would save space.

        Note that unlike most other tags, these tags generally care about the relative order in which objects appear in a CBOR stream; thus they are not interoperable with CBOR implementations that follow the generic CBOR data model (since they may list map keys in an unspecified order). Interoperability problems with these tags can be reduced by not using them to mark keys or values of a map or to mark objects within those keys or values.

        Returns:
        A value indicating whether to resolve references to sharable objects and sharable strings. The default is false.
      • getUseIndefLengthStrings

        public final boolean getUseIndefLengthStrings()
        Gets a value indicating whether to encode strings with an indefinite-length encoding under certain circumstances.
        Returns:
        A value indicating whether to encode strings with an indefinite-length encoding under certain circumstances. The default is false.
      • getAllowEmpty

        public final boolean getAllowEmpty()
        Gets a value indicating whether decoding a CBOR object will return null instead of a CBOR object if the stream has no content or the end of the stream is reached before decoding begins. Used only when decoding CBOR objects.
        Returns:
        A value indicating whether decoding a CBOR object will return null instead of a CBOR object if the stream has no content or the end of the stream is reached before decoding begins. The default is false.
      • getAllowDuplicateKeys

        public final boolean getAllowDuplicateKeys()
        Gets a value indicating whether to allow duplicate keys when reading CBOR objects from a data stream. Used only when decoding CBOR objects.
        Returns:
        A value indicating whether to allow duplicate keys when reading CBOR objects from a data stream. The default is false.
      • getCtap2Canonical

        public final boolean getCtap2Canonical()
        Gets a value indicating whether CBOR objects:
        • When encoding, are written out using the CTAP2 canonical CBOR encoding form, which is useful for implementing Web Authentication.
        • When decoding, are checked for compliance with the CTAP2 canonical encoding form.
        In this form, CBOR tags are not used, map keys are written out in a canonical order, a maximum depth of four levels of arrays and/or maps is allowed, duplicate map keys are not allowed when decoding, and floating-point numbers are written out in their 64-bit encoding form regardless of whether their value can be encoded without loss in a smaller form. This implementation allows CBOR objects whose canonical form exceeds 1024 bytes, the default maximum size for CBOR objects in that form according to the FIDO Client-to-Authenticator Protocol 2 specification.
        Returns:
        true if CBOR objects are written out using the CTAP2 canonical CBOR encoding form; otherwise, false.