From f72d5842828ec072813eb30051d24f7cc8613606 Mon Sep 17 00:00:00 2001 From: clemenso Date: Wed, 17 Sep 2008 17:18:14 +0000 Subject: hashdatainput digest verification git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@45 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../slcommands/impl/DataObjectHashDataInput.java | 50 +++++++++++++++++++++ .../bku/slcommands/impl/HashDataInputImpl.java | 51 ---------------------- .../bku/slcommands/impl/xsect/STALSignature.java | 4 +- 3 files changed, 52 insertions(+), 53 deletions(-) create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/DataObjectHashDataInput.java delete mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/HashDataInputImpl.java (limited to 'bkucommon/src/main/java') 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(); -- cgit v1.2.3