Class COSEProtectedHeader


public class COSEProtectedHeader extends CBORByteArray
COSE Protected Header
Since:
1.1
See Also:
  • Constructor Details

    • COSEProtectedHeader

      public COSEProtectedHeader(byte[] value)
      A constructor with the content of the header.

      This constructor is an alias of this(value, null).

      Parameters:
      value - The content of the header.
    • COSEProtectedHeader

      public COSEProtectedHeader(byte[] value, List<? extends CBORPair> pairs) throws IllegalArgumentException
      A constructor with the content of the header and the decoded key-value pairs of the content.

      It is the caller's responsibility to ensure that the decoded key-value pairs matches the content (value).

      Parameters:
      value - The content of the header.
      pairs - The decoded key-value pairs of the content.
      Throws:
      IllegalArgumentException - pairs contains one or more header parameters that do not conform to the requirements of 3.1. Common COSE Header Parameters.
  • Method Details

    • getPairs

      public List<? extends CBORPair> getPairs()
      Get the set of parameters of this header as a list of CBORPair.

      The second argument given to the COSEProtectedHeader(byte[], List) constructor is returned.

      Returns:
      The set of parameters of this header.
    • getParameters

      public Map<Object,Object> getParameters()
      Get the set of parameters of this header as a Map.

      A Map instance is built from the second argument given to the COSEProtectedHeader(byte[], List) constructor. If the second argument was null, this method returns an empty Map instance.

      Returns:
      The set of parameters of this header.
    • getAlg

      public Object getAlg()
      Get the value of the "alg (1)" parameter.

      The type of the value is an integer (int, long or BigInteger) or a string (String).

      Returns:
      The value of the "alg (1)" parameter. If the header does not contain the parameter, null is returned.
      See Also:
    • getCrit

      public List<Object> getCrit()
      Get the value of the "crit (2)" parameter.

      The type of elements in the returned list is an integer (int, long or BigInteger) or a string (String).

      Returns:
      The value of the "crit (2)" parameter. If the header does not contain the parameter, null is returned.
    • getContentType

      public Object getContentType()
      Get the value of the "content type (3)" parameter.

      The type of the value is an unsigned integer (int, long or BigInteger) or a string (String).

      Returns:
      The value of the "content type (3)" parameter. If the header does not contain the parameter, null is returned.
    • getKid

      public byte[] getKid()
      Get the value of the "kid (4)" parameter.
      Returns:
      The value of the "kid (4)" parameter. If the header does not contain the parameter, null is returned.
    • getIv

      public byte[] getIv()
      Get the value of the "IV (5)" parameter.
      Returns:
      The value of the "IV (5)" parameter. If the header does not contain the parameter, null is returned.
    • getPartialIv

      public byte[] getPartialIv()
      Get the value of the "Partial IV (6)" parameter.
      Returns:
      The value of the "Partial IV (6)" parameter. If the header does not contain the parameter, null is returned.
    • getX5Chain

      public List<X509Certificate> getX5Chain()
      Get the value of the "x5chain (33)" parameter.
      Returns:
      The value of the "x5chain (33)" parameter. If the header does not contain the parameter, null is returned.
      Since:
      1.2
    • build

      public static COSEProtectedHeader build(CBORItem header) throws COSEException
      Interpret the given CBOR data item as a protected header and build an instance of COSEProtectedHeader from it.
      Parameters:
      header - A CBOR data item that represents a protected header. It must be a byte string whose content is a CBOR map or empty.
      Returns:
      A protected header.
      Throws:
      COSEException - The given CBOR data item does not conform to the requirements of protected header.
    • build

      public static COSEProtectedHeader build(Map<Object,Object> map)
      Build a COSEProtectedHeader instance from the given map.
      Parameters:
      map - A map containing header parameters.
      Returns:
      A COSEProtectedHeader instance built from the given map.