public class Attribute extends Object
In addition an attribute map is provided for attributes which will not be sent as part of the message, but which are needed for the code to function correctly. As an example of how this works, there are some situations where the algorithm identifier is not sent as part of an encrypted message, however it is needed in order to encrypt or decrypt the content so the application would set it in the unsent package at send time - for encryption - or at receive time - for decryption.
| Modifier and Type | Field and Description |
|---|---|
static int |
DO_NOT_SEND
Used to place an attribute in the do not send attribute map
Attributes in this map are available for lookup and use but will not
be transmitted as part of the message.
|
static int |
DontSendAttributes
Deprecated.
As of COSE 0.9.1, use Attribute.DO_NOT_SEND
|
protected byte[] |
externalData
Holder for the external data object that is authenticated as part of the
message
|
protected com.upokecenter.cbor.CBORObject |
objDontSend
Internal map of attributes which are not a part of the encoded message.
|
protected com.upokecenter.cbor.CBORObject |
objProtected
Internal map of protected attributes
|
protected com.upokecenter.cbor.CBORObject |
objUnprotected
Internal map of unprotected attributes
|
static int |
PROTECTED
Used to place an attribute in the protected attribute map
Attributes placed in this map are part of the integrity check if the cryptographic algorithm supports authenticated data.
|
static int |
ProtectedAttributes
Deprecated.
As of COSE 0.9.1, use Attribute.PROTECT
|
protected byte[] |
rgbProtected
The encoded byte string for the protected attributes.
|
static int |
UNPROTECTED
Used to place an attribute in the unprotected attribute map
Attributes placed in this map are not integrity protected.
|
static int |
UnprotectedAttributes
Deprecated.
As of COSE 0.9.1, use Attribute.UNPROTECT
|
| Constructor and Description |
|---|
Attribute() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAttribute(com.upokecenter.cbor.CBORObject label,
com.upokecenter.cbor.CBORObject value,
int where)
Set an attribute in the COSE object.
|
void |
addAttribute(HeaderKeys label,
byte[] value,
int where)
Set an attribute in the COSE object.
|
void |
addAttribute(HeaderKeys label,
com.upokecenter.cbor.CBORObject value,
int where)
Set an attribute in the COSE object.
|
void |
AddProtected(com.upokecenter.cbor.CBORObject label,
com.upokecenter.cbor.CBORObject value)
Deprecated.
As of COSE 0.9.0, use addAttribute(CBORObject, CBORObject, Attribute.PROTECTED);
|
void |
AddProtected(HeaderKeys label,
byte[] value)
Deprecated.
As of COSE 0.9.0, use addAttribute(HeaderKeys, byte[], Attribute.PROTECTED);
|
void |
AddProtected(HeaderKeys label,
com.upokecenter.cbor.CBORObject value)
Deprecated.
As of COSE 0.9.0, use addAttribute(HeaderKeys, CBORObject, Attribute.PROTECTED);
|
void |
AddUnprotected(com.upokecenter.cbor.CBORObject label,
com.upokecenter.cbor.CBORObject value)
Deprecated.
As of COSE 0.9.1, use addAttribute(HeaderKeys, byte[], Attribute.UNPROTECTED);
|
void |
AddUnprotected(HeaderKeys label,
byte[] value)
Deprecated.
As of COSE 0.9.1, use addAttribute(HeaderKeys, byte[], Attribute.UNPROTECTED);
|
void |
AddUnprotected(HeaderKeys label,
com.upokecenter.cbor.CBORObject value)
Deprecated.
As of COSE 0.9.1, use addAttribute(HeaderKeys, byte[], Attribute.UNPROTECTED);
|
com.upokecenter.cbor.CBORObject |
findAttribute(com.upokecenter.cbor.CBORObject label)
Locate an attribute in one of the attribute buckets The buckets are
searched in the order protected, unprotected, unsent.
|
com.upokecenter.cbor.CBORObject |
findAttribute(com.upokecenter.cbor.CBORObject label,
int where)
Locate an attribute in one of the attribute buckets The buckets are
searched in the order protected, unprotected, unsent.
|
com.upokecenter.cbor.CBORObject |
findAttribute(HeaderKeys label)
Locate an attribute in one of the attribute buckets The buckets are
searched in the order protected, unprotected, unsent.
|
com.upokecenter.cbor.CBORObject |
findAttribute(HeaderKeys label,
int where)
Locate an attribute in one of the attribute buckets The buckets are
searched in the order protected, unprotected, unsent.
|
com.upokecenter.cbor.CBORObject |
getDoNotSendAttributes()
Return the entire map of do not send attributes
|
byte[] |
getExternal()
Get the optional external data field to be authenticated
* @return external authenticated data
|
com.upokecenter.cbor.CBORObject |
getProtectedAttributes()
Return the entire map of protected attributes
|
com.upokecenter.cbor.CBORObject |
getUnprotectedAttributes()
Return the entire map of unprotected attributes
|
void |
removeAttribute(com.upokecenter.cbor.CBORObject label)
Remove an attribute from the set of all attribute maps.
|
void |
removeAttribute(HeaderKeys label)
Remove an attribute from the set of all attribute maps.
|
void |
setExternal(byte[] rgbData)
Set the optional external data field to be authenticated
|
protected com.upokecenter.cbor.CBORObject objProtected
protected com.upokecenter.cbor.CBORObject objUnprotected
protected com.upokecenter.cbor.CBORObject objDontSend
protected byte[] rgbProtected
protected byte[] externalData
@Deprecated public static final int ProtectedAttributes
@Deprecated public static final int UnprotectedAttributes
@Deprecated public static final int DontSendAttributes
public static final int PROTECTED
public static final int UNPROTECTED
public static final int DO_NOT_SEND
public void addAttribute(com.upokecenter.cbor.CBORObject label,
com.upokecenter.cbor.CBORObject value,
int where)
throws CoseException
label - CBOR object which identifies the attribute in the mapvalue - CBOR object which contains the value of the attributewhere - Identifies which of the buckets to place the attribute in.
ProtectedAttributes - attributes cryptographically protected
UnprotectedAttributes - attributes not cryptographically protected
DontSendAttributes - attributes used locally and not transmittedCoseException - COSE Package exceptionpublic void addAttribute(HeaderKeys label, com.upokecenter.cbor.CBORObject value, int where) throws CoseException
label - HeaderKeys label which identifies the attribute in the mapvalue - CBOR object which contains the value of the attributewhere - Identifies which of the buckets to place the attribute in.
ProtectedAttributes - attributes cryptographically protected
UnprotectedAttributes - attributes not cryptographically protected
DontSendAttributes - attributes used locally and not transmittedCoseException - COSE Package exceptionpublic void addAttribute(HeaderKeys label, byte[] value, int where) throws CoseException
label - HeaderKeys label which identifies the attribute in the mapvalue - CBOR object which contains the value of the attributewhere - Identifies which of the buckets to place the attribute in.
ProtectedAttributes - attributes cryptographically protected
UnprotectedAttributes - attributes not cryptographically protected
DontSendAttributes - attributes used locally and not transmittedCoseException - COSE Package exception@Deprecated public void AddProtected(com.upokecenter.cbor.CBORObject label, com.upokecenter.cbor.CBORObject value) throws CoseException
label - CBOR object which identifies the attribute in the mapvalue - CBOR object which contains the value of the attributeCoseException - COSE Package exception@Deprecated public void AddProtected(HeaderKeys label, com.upokecenter.cbor.CBORObject value) throws CoseException
label - HeaderKeys label which identifies the attribute in the mapvalue - CBOR object which contains the value of the attributeCoseException - COSE Package exception@Deprecated public void AddProtected(HeaderKeys label, byte[] value) throws CoseException
label - CBOR object which identifies the attribute in the mapvalue - byte array of valueCoseException - COSE Package exception@Deprecated public void AddUnprotected(com.upokecenter.cbor.CBORObject label, com.upokecenter.cbor.CBORObject value) throws CoseException
label - value identifies the attribute in the mapvalue - value to be associated with the labelCoseException - COSE Package exception@Deprecated public void AddUnprotected(HeaderKeys label, com.upokecenter.cbor.CBORObject value) throws CoseException
label - identifies the attribute in the mapvalue - value to be associated with the labelCoseException - COSE Package exception@Deprecated public void AddUnprotected(HeaderKeys label, byte[] value) throws CoseException
label - identifies the attribute in the mapvalue - value to be associated with the labelCoseException - COSE Package exceptionpublic com.upokecenter.cbor.CBORObject findAttribute(com.upokecenter.cbor.CBORObject label)
label - - Label of the value to be searched forpublic com.upokecenter.cbor.CBORObject findAttribute(com.upokecenter.cbor.CBORObject label,
int where)
label - - HeaderKey enumeration value to search forwhere - which maps to search for the labelpublic com.upokecenter.cbor.CBORObject findAttribute(HeaderKeys label)
label - - HeaderKey enumeration value to search forpublic com.upokecenter.cbor.CBORObject findAttribute(HeaderKeys label, int where)
label - - HeaderKey enumeration value to search forwhere - which maps to search for the labelpublic com.upokecenter.cbor.CBORObject getProtectedAttributes()
public com.upokecenter.cbor.CBORObject getUnprotectedAttributes()
public com.upokecenter.cbor.CBORObject getDoNotSendAttributes()
public void removeAttribute(com.upokecenter.cbor.CBORObject label)
throws CoseException
label - attribute to be removedCoseException - if integrity protection would be modified.public void removeAttribute(HeaderKeys label) throws CoseException
label - attribute to be removedCoseExceptionpublic byte[] getExternal()
public void setExternal(byte[] rgbData)
rgbData - - data to be authenticatedCOSE for Java documentation, generatedin 2016.