* @return the constructed {@code KeyInfoType} object.
* @throws WSTrustException if an error occurs while creating the {@code KeyInfoType}.
*/
public static KeyInfoType createKeyInfo(Certificate certificate) throws WSTrustException
{
KeyInfoType keyInfo = null;
try
{
// TODO: check if we need to store the certificate using a base64 format.
byte[] encodedCert = certificate.getEncoded();
// first create a X509DataType that contains the encoded certificate.
org.jboss.identity.xmlsec.w3.xmldsig.ObjectFactory factory = new org.jboss.identity.xmlsec.w3.xmldsig.ObjectFactory();
X509DataType dataType = factory.createX509DataType();
dataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(
factory.createX509DataTypeX509Certificate(encodedCert));
// set the X509DataType in the KeyInfoType.
keyInfo = new KeyInfoType();
keyInfo.getContent().add(factory.createX509Data(dataType));
}
catch (Exception e)
{
throw new WSTrustException("Error creating KeyInfoType", e);
}