summaryrefslogtreecommitdiff
path: root/bkucommon/src
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-09-17 17:18:14 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-09-17 17:18:14 +0000
commitf72d5842828ec072813eb30051d24f7cc8613606 (patch)
treebbb1db759ec72d99d85294e0a2598aed9a52c722 /bkucommon/src
parentcf82096145bbdd548e388c1bc25f0e703b9b4624 (diff)
downloadmocca-f72d5842828ec072813eb30051d24f7cc8613606.tar.gz
mocca-f72d5842828ec072813eb30051d24f7cc8613606.tar.bz2
mocca-f72d5842828ec072813eb30051d24f7cc8613606.zip
hashdatainput digest verification
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@45 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'bkucommon/src')
-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();