}
return spkiDataTypeKDV;
}
private static SignatureTransformDataValue mapSignatureTransformDataValue(Object xform) {
SignatureTransformDataValue sdv = new SignatureTransformDataValue();
if (xform instanceof String) {
sdv.setContentType(String.class.getSimpleName());
String xformStr = xform.toString();
byte[] xformBytes = xformStr.getBytes();
sdv.setContentBytes(xformBytes);
} else if (xform instanceof Element) {
sdv.setContentType(Element.class.getCanonicalName());
Element xformEl = (Element) xform;
String str = serializeTransformElement(xformEl);
try {
sdv.setContentBytes(str.getBytes("UTF-8"));
} catch (Exception e) {
throw new RuntimeException("Failed to encode string due to: " + e.getMessage(), e);
}
} else if (xform instanceof byte[]) {
sdv.setContentType(byte[].class.getSimpleName());
sdv.setContentBytes((byte[]) xform);
} else if (xform instanceof JAXBElement) {
sdv.setContentType(Element.class.getCanonicalName());
JAXBElement xformJAXB = (JAXBElement) xform;
DOMResult domResult = new DOMResult();
JAXB.marshal(xformJAXB, domResult);
Element xformEl = ((Document) domResult.getNode()).getDocumentElement();
String str = serializeTransformElement(xformEl);
try {
sdv.setContentBytes(str.getBytes("UTF-8"));
} catch (Exception e) {
throw new RuntimeException("Failed to encode string due to: " + e.getMessage(), e);
}
} else {
throw new RuntimeException("Unrecognized type: " + xform.getClass().getCanonicalName());