Interface CertificateParser.KeyHandler
-
- All Superinterfaces:
CertificateParser.ParserHandler
- Enclosing class:
- CertificateParser
public static interface CertificateParser.KeyHandler extends CertificateParser.ParserHandler
AKeyHandler
is triggered by aCertificateParser
and allows to fill the fields of aPublicKey
pre-allocated by the application with the values of the public key of the certificate.This handler is only triggered when the certificate public key has a type and length supported by the
CertificateParser
and if it can be build using theKeyBuilder
class. Note that theCertificateParser
may only support a subset of types supported by theKeyBuilder
class.This handler is a way for the application to provide to the
CertificateParser
a pre-allocatedPublicKey
object to be filled with the field values contained within the certificate. In some cases, the certificate does not contain all fields of the public key (e.g some ECC or DSA parameters are optional for X.509 certificates) and it is up to the application to fill in the missing fields to complete the initialization of thePublicKey
object if necessary.When parsing the certificate public key field, the
KeyHandler
is triggered by theCertificateParser
prior any other handlers implementing aParserHandler
. Hence, the application is aware if the public key can be extracted by the parser and can decide how other fields should be handled (for example keeping the encoded form of the public key).There are two places where
KeyHandler
can be used:- When building a new certificate instance using
CertificateParser.buildCert(byte[], short, short, ParserHandler)
or
CertificateParser.buildCert(byte[], short, short, ParserHandler, PublicKey),
the
KeyHandler
is a way for the application to provide a pre-allocatedPublicKey
object to be populated by the parser rather than allocating a new one. Hence, any calls toCertificate.getPublicKey()
on the certificate being created will return thisPublicKey
object. It may benull
.
- When parsing a certificate using
CertificateParser.parseCert(byte[], short, short, ParserHandler)
or
CertificateParser.parseCert(byte[], short, short, ParserHandler,PublicKey),
the
KeyHandler
is a way for the application to provide a pre-allocatedPublicKey
object to be populated by the parser. Thus, an application does not need to parse the public key elements of the certificate itself.
- Since:
- 3.1
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description PublicKey
onKey(byte keytype, short param)
Override this method to provide the relevant key object to be populated by the parser.
-
-
-
Method Detail
-
onKey
PublicKey onKey(byte keytype, short param)
Override this method to provide the relevant key object to be populated by the parser.- Parameters:
keytype
- the key type (same as Key.getType()) matching the type found during certificate parsingparam
- key parameters- for all key types except for the type KeyBuilder.TYPE_XEC: the key length (same as Key.getSize()) matching the length found during certificate parsing
- for the key type KeyBuilder.TYPE_XEC: the standard name (same as NamedParameterSpec.getName()) matching the one found during certificate parsing
- Returns:
- the key object to be populated by the parser.
- See Also:
CertificateParser.parseCert(byte[], short, short, ParserHandler)
,CertificateParser.buildCert(byte[], short, short, ParserHandler)
-
-