Interface CertificateParser.KeyHandler
-
- All Superinterfaces:
CertificateParser.ParserHandler
- Enclosing class:
- CertificateParser
public static interface CertificateParser.KeyHandler extends CertificateParser.ParserHandler
AKeyHandleris triggered by aCertificateParserand allows to fill the fields of aPublicKeypre-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
CertificateParserand if it can be build using theKeyBuilderclass. Note that theCertificateParsermay only support a subset of types supported by theKeyBuilderclass.This handler is a way for the application to provide to the
CertificateParsera pre-allocatedPublicKeyobject 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 thePublicKeyobject if necessary.When parsing the certificate public key field, the
KeyHandleris triggered by theCertificateParserprior 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
KeyHandlercan 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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description PublicKeyonKey(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)
-
-