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 aSigStructureinstance 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 givenCOSESignatureobject 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:
thisobject.
-
signature1
Set"Signature1"toSig_structure.context.- Returns:
thisobject.
-
bodyAttributes
Set the attributes toSig_structure.body_protected.- Parameters:
attributes- The protected header of the body information (COSE_SignorCOSE_Sign1).- Returns:
thisobject.
-
signerAttributes
Set the attributes toSig_structure.sign_protected.- Parameters:
attributes- The protected header of aCOSE_Signature.- Returns:
thisobject.
-
externalData
Set the data toSig_structure.external_add.- Parameters:
data- The externally supplied data.- Returns:
thisobject.
-
externalData
Set the data toSig_structure.external_add.- Parameters:
data- The externally supplied data.- Returns:
thisobject.
-
payload
Set the payload toSig_structure.payload.- Parameters:
payload- The payload to be signed.- Returns:
thisobject.
-
payload
Set the payload toSig_structure.payload.- Parameters:
payload- The payload to be signed.- Returns:
thisobject.
-
payload
Set the payload toSig_structure.payload.- Parameters:
payload- The payload to be signed. Its UTF-8 byte sequence is used.- Returns:
thisobject.
-
sign
Set some fields ofSig_structurebased on the givenCOSESignobject that representsCOSE_Signwhich 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.payloadif the payload is not null and not aCBORNullinstance.
- Parameters:
sign- ACOSESignobject that representsCOSE_Sign.- Returns:
thisobject.- See Also:
- Set
-
signature
Set the protected header of the givenCOSESignatureobject toSig_structure.sign_protected.The
COSESignatureclass representsCOSE_Signaturewhich is defined in 4.1. Signing with One or More Signers of RFC 9052.- Parameters:
signature- ACOSESignatureobject that representsCOSE_Signature.- Returns:
thisobject.
-
sign1
Set some fields ofSig_structurebased on the givenCOSESign1object that representsCOSE_Sign1which 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.payloadif the payload is not null and not aCBORNullinstance.
- Parameters:
sign1- ACOSESign1object that representsCOSE_Sign1.- Returns:
thisobject.- See Also:
- Set
-
build
Build aSigStructureinstance that representsSig_structure.For this method to return a
SigStructureinstance 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
SigStructureinstance. - Throws:
IllegalStateException
-