Interface CertificateParser.KeyHandler
- All Superinterfaces:
CertificateParser.ParserHandler
- Enclosing class:
CertificateParser
KeyHandler is triggered by a CertificateParser and allows
to fill the fields of a PublicKey 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 the KeyBuilder class. Note that the CertificateParser
may only support a subset of types supported by the KeyBuilder class.
This handler is a way for the application to provide to the
CertificateParser a pre-allocated PublicKey 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
the PublicKey object if necessary.
When parsing the certificate public key field, the KeyHandler is
triggered by the CertificateParser prior any other handlers
implementing a ParserHandler. 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
KeyHandleris a way for the application to provide a pre-allocatedPublicKeyobject to be populated by the parser rather than allocating a new one. Hence, any calls toCertificate.getPublicKey()on the certificate being created will return thisPublicKeyobject. It may benull.
- When parsing a certificate using
CertificateParser.parseCert(byte[], short, short, ParserHandler)
or
CertificateParser.parseCert(byte[], short, short, ParserHandler,PublicKey),
the
KeyHandleris a way for the application to provide a pre-allocatedPublicKeyobject 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
-
Method Details
-
onKey
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:
-