Class SigStructureBuilder
java.lang.Object
com.authlete.cose.SigStructureBuilder
A utility to build a
SigStructure
instance.
The SigStructure
class represents Sig_structure
which is defined in
4.4. Signing
and Verification Process of RFC 9052 as follows.
Sig_structure = [ context : "Signature" / "Signature1", body_protected : empty_or_serialized_map, ? sign_protected : empty_or_serialized_map, external_aad : bstr, payload : bstr ]
- Since:
- 1.1
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbodyAttributes
(COSEProtectedHeader attributes) Set the attributes toSig_structure.body_protected
.build()
Build aSigStructure
instance that representsSig_structure
.externalData
(byte[] data) Set the data toSig_structure.external_add
.externalData
(CBORByteArray data) Set the data toSig_structure.external_add
.payload
(byte[] payload) Set the payload toSig_structure.payload
.payload
(CBORByteArray payload) Set the payload toSig_structure.payload
.Set the payload toSig_structure.payload
.Set"Signature"
toSig_structure.context
.signature
(COSESignature signature) Set the protected header of the givenCOSESignature
object toSig_structure.sign_protected
.Set"Signature1"
toSig_structure.context
.signerAttributes
(COSEProtectedHeader attributes) Set the attributes toSig_structure.sign_protected
.
-
Constructor Details
-
SigStructureBuilder
public SigStructureBuilder()
-
-
Method Details
-
signature
Set"Signature"
toSig_structure.context
.- Returns:
this
object.
-
signature1
Set"Signature1"
toSig_structure.context
.- Returns:
this
object.
-
bodyAttributes
Set the attributes toSig_structure.body_protected
.- Parameters:
attributes
- The protected header of the body information (COSE_Sign
orCOSE_Sign1
).- Returns:
this
object.
-
signerAttributes
Set the attributes toSig_structure.sign_protected
.- Parameters:
attributes
- The protected header of aCOSE_Signature
.- Returns:
this
object.
-
externalData
Set the data toSig_structure.external_add
.- Parameters:
data
- The externally supplied data.- Returns:
this
object.
-
externalData
Set the data toSig_structure.external_add
.- Parameters:
data
- The externally supplied data.- Returns:
this
object.
-
payload
Set the payload toSig_structure.payload
.- Parameters:
payload
- The payload to be signed.- Returns:
this
object.
-
payload
Set the payload toSig_structure.payload
.- Parameters:
payload
- The payload to be signed.- Returns:
this
object.
-
payload
Set the payload toSig_structure.payload
.- Parameters:
payload
- The payload to be signed. Its UTF-8 byte sequence is used.- Returns:
this
object.
-
sign
Set some fields ofSig_structure
based on the givenCOSESign
object that representsCOSE_Sign
which is defined in 4.1. Signing with One or More Signers of RFC 9052.The implementation of this method does the following.
- Set
"Signature"
toSig_structure.context
. - Set
sign.
getProtectedeHeader()
toSig_structure.body_protected
. - Set
sign.
getPayload()
toSig_sructure.payload
if the payload is not null and not aCBORNull
instance.
- Parameters:
sign
- ACOSESign
object that representsCOSE_Sign
.- Returns:
this
object.- See Also:
- Set
-
signature
Set the protected header of the givenCOSESignature
object toSig_structure.sign_protected
.The
COSESignature
class representsCOSE_Signature
which is defined in 4.1. Signing with One or More Signers of RFC 9052.- Parameters:
signature
- ACOSESignature
object that representsCOSE_Signature
.- Returns:
this
object.
-
sign1
Set some fields ofSig_structure
based on the givenCOSESign1
object that representsCOSE_Sign1
which is defined in 4.2. Signing with One Signer of RFC 9052.The implementation of this method does the following.
- Set
"Signature1"
toSig_structure.context
. - Set
sign1.
getProtectedeHeader()
toSig_structure.body_protected
. - Set
sign1.
getPayload()
toSig_sructure.payload
if the payload is not null and not aCBORNull
instance.
- Parameters:
sign1
- ACOSESign1
object that representsCOSE_Sign1
.- Returns:
this
object.- See Also:
- Set
-
build
Build aSigStructure
instance that representsSig_structure
.For this method to return a
SigStructure
instance successfully, the following must be satisfied.signature()
,signature1()
,sign(COSESign)
, orsign1(COSESign1)
must have been called to setSig_structure.context
.payload(CBORByteArray)
,sign(COSESign)
orsign1(COSESign1)
must have been called to setSig_structure.payload
.
- Returns:
- A newly created
SigStructure
instance. - Throws:
IllegalStateException
-