Class COSEProtectedHeader
java.lang.Object
com.authlete.cbor.CBORItem
com.authlete.cbor.CBORValue<byte[]>
com.authlete.cbor.CBORByteArray
com.authlete.cose.COSEProtectedHeader
-
Constructor Summary
ConstructorsConstructorDescriptionCOSEProtectedHeader
(byte[] value) A constructor with the content of the header.COSEProtectedHeader
(byte[] value, List<? extends CBORPair> pairs) A constructor with the content of the header and the decoded key-value pairs of the content. -
Method Summary
Modifier and TypeMethodDescriptionstatic COSEProtectedHeader
Interpret the given CBOR data item as a protected header and build an instance ofCOSEProtectedHeader
from it.static COSEProtectedHeader
Build aCOSEProtectedHeader
instance from the given map.getAlg()
Get the value of the "alg (1)" parameter.Get the value of the "content type (3)" parameter.getCrit()
Get the value of the "crit (2)" parameter.byte[]
getIv()
Get the value of the "IV (5)" parameter.byte[]
getKid()
Get the value of the "kid (4)" parameter.getPairs()
Get the set of parameters of this header as a list ofCBORPair
.Get the set of parameters of this header as aMap
.byte[]
Get the value of the "Partial IV (6)" parameter.Get the value of the "x5chain (33)" parameter.Methods inherited from class com.authlete.cbor.CBORByteArray
encode, getDecodedContent, prettify, toString, toString, toString
Methods inherited from class com.authlete.cbor.CBORItem
encode, encodeMajorWithNumber, encodeToBase64, encodeToBase64Url, encodeToHex, getComment, prettify, setComment
-
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
Get the set of parameters of this header as a list ofCBORPair
.The second argument given to the
COSEProtectedHeader(byte[], List)
constructor is returned.- Returns:
- The set of parameters of this header.
-
getParameters
Get the set of parameters of this header as aMap
.A
Map
instance is built from the second argument given to theCOSEProtectedHeader(byte[], List)
constructor. If the second argument wasnull
, this method returns an emptyMap
instance.- Returns:
- The set of parameters of this header.
-
getAlg
Get the value of the "alg (1)" parameter.The type of the value is an integer (
int
,long
orBigInteger
) 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
-
getContentType
Get the value of the "content type (3)" parameter.The type of the value is an unsigned integer (
int
,long
orBigInteger
) 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
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
Interpret the given CBOR data item as a protected header and build an instance ofCOSEProtectedHeader
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
Build aCOSEProtectedHeader
instance from the given map.- Parameters:
map
- A map containing header parameters.- Returns:
- A
COSEProtectedHeader
instance built from the given map.
-