Package COSE
Class Sign1Message
- java.lang.Object
-
- COSE.Attribute
-
- COSE.Message
-
- COSE.SignCommon
-
- COSE.Sign1Message
-
public class Sign1Message extends SignCommon
The Sign1Message class implements the COSE_Sign1 object. This provides for a single signature where the signer is normally implicitly known.SignMessageneed to be used in those cases where more than one signature is needed on a content. There is no way to convert a signed message between the two formats.Create a Sign1Message object for a new message, when processing an existing message use Message.DecodeFromBytes to create the Sign1Message object.
There are examples of using this class:
Simple Example- Author:
- jimsch
-
-
Field Summary
-
Fields inherited from class COSE.SignCommon
contextString
-
Fields inherited from class COSE.Message
emitContent, emitTag, messageTag, rgbContent
-
Fields inherited from class COSE.Attribute
DO_NOT_SEND, DontSendAttributes, externalData, objDontSend, objProtected, objUnprotected, PROTECTED, ProtectedAttributes, rgbProtected, UNPROTECTED, UnprotectedAttributes
-
-
Constructor Summary
Constructors Constructor Description Sign1Message()Create a signed message object for which there will be a leading tag and the content will be included.Sign1Message(boolean emitTag)Create a signed message object.Sign1Message(boolean emitTag, boolean emitContent)Create a signed message object for which the emission of the leading tag and content is controlled by the parameters.
-
Method Summary
Modifier and Type Method Description protected voidDecodeFromCBORObject(com.upokecenter.cbor.CBORObject messageObject)Internal function used in creating a Sign1Message object from a byte string.protected com.upokecenter.cbor.CBORObjectEncodeCBORObject()Internal function used to create a serialization of a COSE_Sign1 messagevoidsign(OneKey key)Create a signature for the message if one does not exist.booleanvalidate(OneKey cnKey)Validate the signature on the message using the passed in key.-
Methods inherited from class COSE.Message
addCountersignature, DecodeFromBytes, DecodeFromBytes, EncodeToBytes, EncodeToCBORObject, GetContent, getCountersign1, getCountersignerList, HasContent, ProcessCounterSignatures, SetContent, SetContent, setCountersign1, validate, validate
-
Methods inherited from class COSE.Attribute
addAttribute, addAttribute, addAttribute, AddProtected, AddProtected, AddProtected, AddUnprotected, AddUnprotected, AddUnprotected, findAttribute, findAttribute, findAttribute, findAttribute, getDoNotSendAttributes, getExternal, getProtectedAttributes, getUnprotectedAttributes, removeAttribute, removeAttribute, setExternal
-
-
-
-
Constructor Detail
-
Sign1Message
public Sign1Message()
Create a signed message object for which there will be a leading tag and the content will be included.
-
Sign1Message
public Sign1Message(boolean emitTag)
Create a signed message object. Emission of the leading tag is controlled by the parameter.- Parameters:
emitTag- emit leading tag when message is serialized
-
Sign1Message
public Sign1Message(boolean emitTag, boolean emitContent)Create a signed message object for which the emission of the leading tag and content is controlled by the parameters.- Parameters:
emitTag- emit leading tag when message is serializedemitContent- emit the content as part of the message- Since:
- COSE 0.9.1
-
-
Method Detail
-
sign
public void sign(OneKey key) throws CoseException
Create a signature for the message if one does not exist.- Parameters:
key- key to use to sign the message- Throws:
CoseException- Errors generated by the COSE module
-
validate
public boolean validate(OneKey cnKey) throws CoseException
Validate the signature on the message using the passed in key.- Parameters:
cnKey- key to use for validation- Returns:
- true if the signature validates
- Throws:
CoseException- Errors generated by the COSE module
-
DecodeFromCBORObject
protected void DecodeFromCBORObject(com.upokecenter.cbor.CBORObject messageObject) throws CoseExceptionInternal function used in creating a Sign1Message object from a byte string.- Specified by:
DecodeFromCBORObjectin classMessage- Parameters:
messageObject- COSE_Sign1 encoded object.- Throws:
CoseException- Errors generated by the COSE module
-
EncodeCBORObject
protected com.upokecenter.cbor.CBORObject EncodeCBORObject() throws CoseExceptionInternal function used to create a serialization of a COSE_Sign1 message- Specified by:
EncodeCBORObjectin classMessage- Returns:
- CBOR object which can be encoded.
- Throws:
CoseException- Errors generated by the COSE module
-
-