aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/gv/egiz/dsig/util
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2013-11-27 10:05:17 +0100
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2013-11-27 10:05:17 +0100
commitf3476576c50efd922593c82656efda7aec5ae97f (patch)
tree66107d5c5d3a88af66bd4829d8fcecc5678b749e /pdf-as-lib/src/main/java/at/gv/egiz/dsig/util
parent7b2e2b640b0f392183f7927f692936950d3fabfc (diff)
downloadpdf-as-4-f3476576c50efd922593c82656efda7aec5ae97f.tar.gz
pdf-as-4-f3476576c50efd922593c82656efda7aec5ae97f.tar.bz2
pdf-as-4-f3476576c50efd922593c82656efda7aec5ae97f.zip
MOA integration sign/verification (not finished yet ...)
Lots of PDF-AS Web implementation
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/dsig/util')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/dsig/util/DsigMarschaller.java52
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/dsig/util/package-info.java8
2 files changed, 60 insertions, 0 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/dsig/util/DsigMarschaller.java b/pdf-as-lib/src/main/java/at/gv/egiz/dsig/util/DsigMarschaller.java
new file mode 100644
index 00000000..17770737
--- /dev/null
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/dsig/util/DsigMarschaller.java
@@ -0,0 +1,52 @@
+package at.gv.egiz.dsig.util;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
+
+public class DsigMarschaller {
+ private static Marshaller marshaller = null;
+ private static Unmarshaller unmarshaller = null;
+
+ public final static QName X509DataTypeX509Certificate_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "X509Certificate");
+
+ static {
+ try {
+ JAXBContext context = JAXBContext.newInstance("at.gv.egiz.dsig");
+ marshaller = context.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
+
+ unmarshaller = context.createUnmarshaller();
+ } catch (JAXBException e) {
+ throw new RuntimeException(
+ "There was a problem creating a JAXBContext object for formatting the object to XML.");
+ }
+ }
+
+ public static void marshal(Object obj, OutputStream os) throws JAXBException {
+ marshaller.marshal(obj, os);
+ }
+
+ public static String marshalToString(Object obj) throws JAXBException {
+ StringWriter sw = new StringWriter();
+ marshaller.marshal(obj, sw);
+ return sw.toString();
+ }
+
+ public static Object unmarshal(InputStream is) throws JAXBException {
+ return unmarshaller.unmarshal(is);
+ }
+
+ public static Object unmarshalFromString(String message) throws JAXBException {
+ StringReader sr = new StringReader(message);
+ return unmarshaller.unmarshal(sr);
+ }
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/dsig/util/package-info.java b/pdf-as-lib/src/main/java/at/gv/egiz/dsig/util/package-info.java
new file mode 100644
index 00000000..942b7215
--- /dev/null
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/dsig/util/package-info.java
@@ -0,0 +1,8 @@
+/**
+ *
+ */
+/**
+ * @author afitzek
+ *
+ */
+package at.gv.egiz.dsig.util; \ No newline at end of file