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 COSEProtectedHeaderInterpret the given CBOR data item as a protected header and build an instance ofCOSEProtectedHeaderfrom it.static COSEProtectedHeaderBuild aCOSEProtectedHeaderinstance 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, toStringMethods 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
pairsmatches the content (value).- Parameters:
value- The content of the header.pairs- The decoded key-value pairs of the content.- Throws:
IllegalArgumentException-pairscontains 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
Mapinstance is built from the second argument given to theCOSEProtectedHeader(byte[], List)constructor. If the second argument wasnull, this method returns an emptyMapinstance.- 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,longorBigInteger) or a string (String).- Returns:
- The value of the "alg (1)" parameter. If the header does not
contain the parameter,
nullis returned. - See Also:
-
getCrit
-
getContentType
Get the value of the "content type (3)" parameter.The type of the value is an unsigned integer (
int,longorBigInteger) or a string (String).- Returns:
- The value of the "content type (3)" parameter. If the header
does not contain the parameter,
nullis 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,
nullis 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,
nullis 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,
nullis 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,
nullis returned. - Since:
- 1.2
-
build
Interpret the given CBOR data item as a protected header and build an instance ofCOSEProtectedHeaderfrom 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 aCOSEProtectedHeaderinstance from the given map.- Parameters:
map- A map containing header parameters.- Returns:
- A
COSEProtectedHeaderinstance built from the given map.
-