summaryrefslogtreecommitdiff
path: root/bkucommon/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'bkucommon/src/main/java')
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java50
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/HashDataInputImpl.java51
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java4
3 files changed, 52 insertions, 53 deletions
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java
new file mode 100644
index 00000000..71b62911
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java
@@ -0,0 +1,50 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package at.gv.egiz.bku.slcommands.impl;
+
+import at.gv.egiz.bku.binding.HttpUtil;
+import at.gv.egiz.bku.slcommands.impl.xsect.DataObject;
+import at.gv.egiz.stal.HashDataInput;
+import java.io.InputStream;
+
+/**
+ *
+ * @author clemens
+ */
+public class DataObjectHashDataInput implements HashDataInput {
+
+ protected DataObject dataObject;
+
+ public DataObjectHashDataInput(DataObject dataObject) {
+ if (dataObject.getReference() == null)
+ throw new NullPointerException("DataObject reference must not be null");
+ this.dataObject = dataObject;
+ }
+
+ @Override
+ public String getReferenceId() {
+ return dataObject.getReference().getId();
+ }
+
+ @Override
+ public String getMimeType() {
+ return dataObject.getMimeType();
+ }
+
+ /**
+ *
+ * @return the pre-digested input stream if reference caching is enabled, null otherwise
+ */
+ @Override
+ public InputStream getHashDataInput() {
+ return dataObject.getReference().getDigestInputStream();
+ }
+
+ @Override
+ public String getEncoding() {
+ return HttpUtil.getCharset(dataObject.getMimeType(), false);
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/HashDataInputImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/HashDataInputImpl.java
deleted file mode 100644
index d6999404..00000000
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/HashDataInputImpl.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package at.gv.egiz.bku.slcommands.impl;
-
-import at.gv.egiz.bku.binding.HttpUtil;
-import at.gv.egiz.bku.slcommands.impl.xsect.DataObject;
-import at.gv.egiz.stal.HashDataInput;
-import java.io.InputStream;
-
-/**
- *
- * @author clemens
- */
-public class HashDataInputImpl implements HashDataInput {
-
- String refId;
- String mimeType;
- String encoding;
- InputStream hashDataInput;
-
- public HashDataInputImpl(DataObject dataObject) {
- refId = dataObject.getReference().getId();
- String contentType = dataObject.getMimeType();
- mimeType = contentType.split(";")[0].trim();
- encoding = HttpUtil.getCharset(dataObject.getMimeType(), false);
- hashDataInput = dataObject.getReference().getDigestInputStream();
- }
-
- @Override
- public String getReferenceId() {
- return refId;
- }
-
- @Override
- public String getMimeType() {
- return mimeType;
- }
-
- @Override
- public InputStream getHashDataInput() {
- return hashDataInput;
- }
-
- @Override
- public String getEncoding() {
- return encoding;
- }
-
-}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java
index 2d89c8ae..dd7c7d8a 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/STALSignature.java
@@ -16,7 +16,7 @@
*/
package at.gv.egiz.bku.slcommands.impl.xsect;
-import at.gv.egiz.bku.slcommands.impl.HashDataInputImpl;
+import at.gv.egiz.bku.slcommands.impl.DataObjectHashDataInput;
import at.gv.egiz.bku.slexceptions.SLViewerException;
import java.io.ByteArrayOutputStream;
@@ -131,7 +131,7 @@ public class STALSignature extends SignatureSpi {
} catch (SLViewerException e) {
throw new STALSignatureException(e);
}
- hashDataInputs.add(new HashDataInputImpl(dataObject));
+ hashDataInputs.add(new DataObjectHashDataInput(dataObject));
}
SignRequest signRequest = new SignRequest();