Class COSEKey
- Direct Known Subclasses:
COSEEC2Key,COSEOKPKey
Subclasses should override the following methods.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddJwkProperties(Map<String, Object> map) Add JWK properties to the given map.static COSEKeyBuild an instance ofCOSEKeyor its subclass when possible (e.g.static COSEKeyBuild an instance ofCOSEKeyor its subclass when possible (e.g.copy()Copy thisCOSEKeyinstance.Create aPrivateKeyinstance from this COSE key.Create aPublicKeyinstance from this COSE key.static COSEKeyBuild aCOSEKeyinstance from a map that represents a JWK (JSON Web Key).getAlg()Get the value of the "alg (3)" parameter.byte[]Get the value of the "Base IV (5)" parameter.Get the value of the "key_ops (4)" parameter.byte[]getKid()Get the value of the "kid (2)" parameter.getKty()Get the value of the "kty (1)" parameter.Get the set of parameters of this key as aMap.booleanGet the flag indicating whether this key contains private parameters.toJwk()Convert this key to aMapinstance that represents a JWK (RFC 7517 JSON Web Key (JWK)).toPublic()Convert this COSE key to a public key.Methods inherited from class com.authlete.cbor.CBORPairList
encode, findByKey, getPairs, parse, prettify, toStringMethods inherited from class com.authlete.cbor.CBORItem
encode, encodeMajorWithNumber, encodeToBase64, encodeToBase64Url, encodeToHex, getComment, prettify, setComment, toString
-
Constructor Details
-
COSEKey
-
-
Method Details
-
getParameters
-
getKty
Get the value of the "kty (1)" parameter.The type of the value is an integer (
int,longorBigInteger) or a string (String).- Returns:
- The value of the "kty (1)" parameter.
- See Also:
-
getKid
public byte[] getKid()Get the value of the "kid (2)" parameter.- Returns:
- The value of the "kid (2)" parameter. If the parameter is not
contained,
nullis returned.
-
getAlg
Get the value of the "alg (3)" parameter.The type of the value is an integer (
int,longorBigInteger) or a string (String).- Returns:
- The value of the "alg (3)" parameter. If the parameter is not
contained,
nullis returned. - See Also:
-
getKeyOps
-
getBaseIv
public byte[] getBaseIv()Get the value of the "Base IV (5)" parameter.- Returns:
- The value of the "Base IV (5)" parameter. If the parameter is
not contained,
nullis returned.
-
isPrivate
public boolean isPrivate()Get the flag indicating whether this key contains private parameters.Subclasses of the
COSEKeyclass are expected to override this method.- Returns:
trueif this key contains private parameters.- Since:
- 1.3
-
toPublic
Convert this COSE key to a public key.When this
COSEKeyinstance is a public key, this method returnsthisobject without any modification. Otherwise, this method creates a newCOSEKeyinstance representing a public key and returns the new instance.The default implementation of this method throws an exception. Subclasses should override this method.
- Returns:
- A
COSEKeyinstance representing a public key. - Throws:
COSEException- Since:
- 1.15
-
createPrivateKey
Create aPrivateKeyinstance from this COSE key.The default implementation of this method throws an exception. Subclasses should override this method.
- Returns:
- A
PrivateKeyinstance. - Throws:
COSEException- The creation failed.- Since:
- 1.15
-
createPublicKey
Create aPublicKeyinstance from this COSE key.The default implementation of this method throws an exception. Subclasses should override this method.
- Returns:
- A
PublicKeyinstance. - Throws:
COSEException- The creation failed.- Since:
- 1.15
-
copy
Copy thisCOSEKeyinstance.- Returns:
- A new
COSEKeyinstance that holds the same content as thisCOSEKeyinstance does. - Throws:
COSEException- Copying this instance failed.- Since:
- 1.15
-
toJwk
Convert this key to aMapinstance that represents a JWK (RFC 7517 JSON Web Key (JWK)).Subclasses of the
COSEKeyclass should override theaddJwkProperties(Map)method to add JWK properties that are specific to them.- Returns:
- A
Mapinstance that represents a JWK. - Since:
- 1.3
- See Also:
-
addJwkProperties
-
build
Build an instance ofCOSEKeyor its subclass when possible (e.g.COSEOKPKeyandCOSEEC2Key) from the given CBOR data item.- Parameters:
item- A CBOR data item that represents a COSE key. It must be a CBOR map.- Returns:
- An instance of
COSEKeyor its subclass. - Throws:
COSEException
-
build
Build an instance ofCOSEKeyor its subclass when possible (e.g.COSEOKPKeyandCOSEEC2Key) from the given map.- Parameters:
map- A map that represents a COSE key.- Returns:
- An instance of
COSEKeyor its subclass. - Throws:
COSEException
-
fromJwk
Build aCOSEKeyinstance from a map that represents a JWK (JSON Web Key).- Parameters:
jwk- A map that represents a JWK.- Returns:
- An instance of
COSEKeyor its subclass such asCOSEEC2Key. - Throws:
COSEException- Failed to create aCOSEKeyinstance of the input map.- Since:
- 1.11
-