notBoundAuthenticationType.setProtocol("NOTUSED");
notBoundAuthenticationType.setValue("RerecoverPassword".getBytes());
authenticationType.setNotBoundAuthentication(notBoundAuthenticationType);
recoverRequestType.setAuthentication(authenticationType);
RecoverResultType recoverResultType = xKMSInvoker.recover(recoverRequestType, null, null, null, keyBindingType.getId());
assertTrue(recoverResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_SUCCESS));
assertTrue(recoverResultType.getResultMinor() == null);
assertTrue(recoverResultType.getKeyBinding().size() == 1);
keyBindingType = recoverResultType.getKeyBinding().get(0);
assertTrue(keyBindingType.getStatus().getValidReason().size() == 4);
JAXBElement<X509DataType> jAXBX509Data = (JAXBElement<X509DataType>) keyBindingType.getKeyInfo().getContent().get(0);
assertTrue(jAXBX509Data.getValue().getX509IssuerSerialOrX509SKIOrX509SubjectName().size() == 2);
Iterator<Object> iter2 = jAXBX509Data.getValue().getX509IssuerSerialOrX509SKIOrX509SubjectName().iterator();
while (iter2.hasNext()) {
JAXBElement next = (JAXBElement) iter2.next();
assertTrue(next.getName().getLocalPart().equals("X509Certificate"));
byte[] encoded = (byte[]) next.getValue();
Certificate nextCert = CertTools.getCertfromByteArray(encoded);
if (CertTools.getSubjectDN(nextCert).equals(CertTools.stringToBCDNString(dn2))) {
cert2 = nextCert;
}
}
assertTrue(recoverResultType.getPrivateKey() != null);
PrivateKey privateKey = XKMSUtil.getPrivateKeyFromEncryptedXML(recoverResultType.getPrivateKey(), "RerecoverPassword");
X509Certificate testCert = CertTools.genSelfCert("CN=sdf", 12, null, privateKey, cert2.getPublicKey(), "SHA1WithRSA", false);
testCert.verify(cert2.getPublicKey());
}