RSAKeyValueType rsaKeyValueType = sigFactory.createRSAKeyValueType();
rsaKeyValueType.setExponent(((RSAPublicKey) keyPair.getPublic()).getPublicExponent().toByteArray());
rsaKeyValueType.setModulus(((RSAPublicKey) keyPair.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 = dbf.newDocumentBuilder().newDocument();
marshaller.marshal(registerRequest, registerRequestDoc);
String authenticationData = "024837";
SecretKey sk = XKMSUtil.getSecretKeyFromPassphrase(authenticationData, true, 20, XKMSUtil.KEY_AUTHENTICATION);
org.apache.xml.security.signature.XMLSignature authXMLSig = new org.apache.xml.security.signature.XMLSignature(registerRequestDoc, "",
org.apache.xml.security.signature.XMLSignature.ALGO_ID_MAC_HMAC_SHA1,
org.apache.xml.security.c14n.Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
org.apache.xml.security.transforms.Transforms transforms = new org.apache.xml.security.transforms.Transforms(registerRequestDoc);
transforms.addTransform(org.apache.xml.security.transforms.Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
authXMLSig.addDocument("#" + prototypeKeyBindingType.getId(), transforms, org.apache.xml.security.utils.Constants.ALGO_ID_DIGEST_SHA1);
authXMLSig.sign(sk);
Element authenticationElement = registerRequestDoc.createElementNS("http://www.w3.org/2002/03/xkms#", "Authentication");
Element keyBindingAuthenticationElement = registerRequestDoc.createElementNS("http://www.w3.org/2002/03/xkms#", "KeyBindingAuthentication");
keyBindingAuthenticationElement.appendChild(authXMLSig.getElement().cloneNode(true));
authenticationElement.appendChild(keyBindingAuthenticationElement);
registerRequestDoc.getDocumentElement().appendChild(authenticationElement);
org.apache.xml.security.signature.XMLSignature xmlSig = new org.apache.xml.security.signature.XMLSignature(registerRequestDoc, "",
org.apache.xml.security.signature.XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1,
org.apache.xml.security.c14n.Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
transforms = new org.apache.xml.security.transforms.Transforms(registerRequestDoc);
transforms.addTransform(org.apache.xml.security.transforms.Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
xmlSig.addDocument("#" + prototypeKeyBindingType.getId(), transforms, org.apache.xml.security.utils.Constants.ALGO_ID_DIGEST_SHA1);
xmlSig.sign(keyPair.getPrivate());
Element pOPElement = registerRequestDoc.createElementNS("http://www.w3.org/2002/03/xkms#", "ProofOfPossession");
pOPElement.appendChild(xmlSig.getElement().cloneNode(true));