useKeyWithType.setIdentifier("CN=Test Testarsson");
registerRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CHAIN);
KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
RSAKeyValueType rsaKeyValueType = sigFactory.createRSAKeyValueType();
rsaKeyValueType.setExponent(((RSAPublicKey) keys.getPublic()).getPublicExponent().toByteArray());
rsaKeyValueType.setModulus(((RSAPublicKey) keys.getPublic()).getModulus().toByteArray());
JAXBElement<RSAKeyValueType> rsaKeyValue = sigFactory.createRSAKeyValue(rsaKeyValueType);
keyInfoType.getContent().add(rsaKeyValue);
PrototypeKeyBindingType prototypeKeyBindingType = xKMSObjectFactory.createPrototypeKeyBindingType();
prototypeKeyBindingType.getUseKeyWith().add(useKeyWithType);
prototypeKeyBindingType.setKeyInfo(keyInfoType);
prototypeKeyBindingType.setId("100231");
registerRequestType.setPrototypeKeyBinding(prototypeKeyBindingType);
JAXBElement<RegisterRequestType> registerRequest = xKMSObjectFactory.createRegisterRequest(registerRequestType);
Document registerRequestDoc = db.newDocument();
marshaller.marshal( registerRequest, registerRequestDoc );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLUtils.outputDOM(registerRequestDoc, baos);
log.debug("XMLUtils.outputDOM: " + baos.toString());
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
JAXBElement<RegisterRequestType> registerRequest2 = (JAXBElement<RegisterRequestType>) unmarshaller.unmarshal(bais);
registerRequestType = registerRequest2.getValue();
RSAKeyValueType rSAKeyValueType = (RSAKeyValueType) ((JAXBElement) registerRequestType.getPrototypeKeyBinding().getKeyInfo().getContent().get(0)).getValue();
RSAPublicKeySpec rSAPublicKeySpec = new RSAPublicKeySpec(new BigInteger(rSAKeyValueType.getModulus()), new BigInteger(rSAKeyValueType.getExponent()));
RSAPublicKey rSAPublicKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(rSAPublicKeySpec);
X509Certificate cert = CertTools.genSelfCert("CN=test", 10, null,keys.getPrivate(), rSAPublicKey, "SHA1WithRSA", true);
cert.verify(rSAPublicKey);