private void writeUseKeyType(UseKeyType useKeyType) throws ProcessingException {
StaxUtil.writeStartElement(writer, PREFIX, WSTrustConstants.USE_KEY, BASE_NAMESPACE);
List<Object> theList = useKeyType.getAny();
for (Object useKeyTypeValue : theList) {
if (useKeyTypeValue instanceof Element) {
Element domElement = (Element) useKeyTypeValue;
StaxUtil.writeDOMElement(writer, domElement);
} else if (useKeyTypeValue instanceof byte[]) {
byte[] certificate = (byte[]) useKeyTypeValue;
StaxUtil.writeStartElement(writer, WSTrustConstants.XMLDSig.DSIG_PREFIX, WSTrustConstants.XMLDSig.X509CERT,
WSTrustConstants.DSIG_NS);
StaxUtil.writeNameSpace(writer, WSTrustConstants.XMLDSig.DSIG_PREFIX, WSTrustConstants.DSIG_NS);
StaxUtil.writeCharacters(writer, new String(certificate));
StaxUtil.writeEndElement(writer);
} else if (useKeyTypeValue instanceof KeyValueType) {
writeKeyValueType((KeyValueType) useKeyTypeValue);
} else if (useKeyTypeValue instanceof KeyInfoType) {
StaxUtil.writeKeyInfo(writer, (KeyInfoType) useKeyTypeValue);
} else
throw logger.writerUnknownTypeError(useKeyTypeValue.getClass().getName());
}
StaxUtil.writeEndElement(writer);
}