public void testSubsequentMessage() throws Exception { KeyPairGenerator kGen = KeyPairGenerator.getInstance("RSA", BC); kGen.initialize(512); KeyPair kp = kGen.generateKeyPair(); X509CertificateHolder cert = makeV3Certificate(kp, "CN=Test", kp, "CN=Test"); ContentSigner signer = new JcaContentSignerBuilder("SHA256withRSA").setProvider(BC).build( kp.getPrivate()); GeneralName user = new GeneralName(new X500Name("CN=Test")); CertificateRequestMessageBuilder builder = new JcaCertificateRequestMessageBuilder( BigInteger.valueOf(1)).setPublicKey(kp.getPublic()).setProofOfPossessionSubsequentMessage( SubsequentMessage.encrCert); ProtectedPKIMessage certRequestMsg = new ProtectedPKIMessageBuilder(user, user).setTransactionID(new byte[] { 1, 2, 3, 4, 5 }).setBody( new PKIBody(PKIBody.TYPE_KEY_UPDATE_REQ, new CertReqMessages(builder.build().toASN1Structure()))).addCMPCertificate( cert).build(signer); ProtectedPKIMessage msg = new ProtectedPKIMessage(new GeneralPKIMessage(certRequestMsg.toASN1Structure().getEncoded())); CertReqMessages reqMsgs = CertReqMessages.getInstance(msg.getBody().getContent()); CertReqMsg reqMsg = reqMsgs.toCertReqMsgArray()[0]; assertEquals(ProofOfPossession.TYPE_KEY_ENCIPHERMENT, reqMsg.getPopo().getType()); }
public CertificateRequestMessage(CertReqMsg certReqMsg) { this.certReqMsg = certReqMsg; this.controls = certReqMsg.getCertReq().getControls(); }
public JcaCertificateRequestMessage(byte[] certReqMsg) { this(CertReqMsg.getInstance(certReqMsg)); }
public JcaCertificateRequestMessage(CertReqMsg certReqMsg) { super(certReqMsg); }
/** * Return the underlying ASN.1 object defining this CertificateRequestMessage object. * * @return a CertReqMsg. */ public CertReqMsg toASN1Structure() { return certReqMsg; }