aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter/wag
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2009-12-14 13:47:48 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2009-12-14 13:47:48 +0000
commit9b615852df5f56eeb67c4dd021a56e72d31a2498 (patch)
tree5cdf42cdb8dd552d73f7d4ef4299aa4743975d5e /src/main/java/at/knowcenter/wag
parent8ba10b6fa16c78ec3a8661d7b050320971495405 (diff)
downloadpdf-as-3-9b615852df5f56eeb67c4dd021a56e72d31a2498.tar.gz
pdf-as-3-9b615852df5f56eeb67c4dd021a56e72d31a2498.tar.bz2
pdf-as-3-9b615852df5f56eeb67c4dd021a56e72d31a2498.zip
Error code created for protected pdf documents.
SettingsReader: Debug message for getInternalResource added (TRACE) multipart/formdata: align multipart charset with data charset added FIXME notes for FileHelper.readFromFile Signature/Verification-Demo updated git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@507 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/knowcenter/wag')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java10
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/pdf/TextualSignature.java14
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/BKUConnector.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java4
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUPostConnection.java6
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapConnection.java6
6 files changed, 31 insertions, 11 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java
index 4ae64a2..2da0d61 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java
@@ -631,7 +631,15 @@ public class SettingsReader implements Serializable
* @return
*/
public InputStream getInternalResource(String relativePath) {
- return this.getClass().getResourceAsStream(INTERNAL_RESOURCE_PATH + relativePath);
+ String streamURI = INTERNAL_RESOURCE_PATH + relativePath;
+ logger_.trace("Trying to get stream from \"" + streamURI + "\".");
+ InputStream stream = this.getClass().getResourceAsStream(streamURI);
+ if (stream == null) {
+ logger_.trace("Could not get stream.");
+ } else {
+ logger_.trace("Got stream.");
+ }
+ return stream;
}
/**
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/TextualSignature.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/TextualSignature.java
index d5b3c5d..c2a253b 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/TextualSignature.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/TextualSignature.java
@@ -27,11 +27,12 @@ import org.pdfbox.pdfparser.PDFParser;
import org.pdfbox.pdmodel.PDDocument;
import org.pdfbox.util.PDFTextStripper;
-import at.gv.egiz.pdfas.exceptions.pdf.TextExtractionException;
+import at.gv.egiz.pdfas.exceptions.ErrorCode;
import at.gv.egiz.pdfas.framework.input.PdfDataSource;
import at.gv.egiz.pdfas.performance.PerformanceCounters;
import at.knowcenter.wag.egov.egiz.cfg.ConfigLogger;
import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
+import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
@@ -59,10 +60,11 @@ public class TextualSignature
* @param pdf_stream
* The pdf_input stream.
* @return Returns the extracted document text.
+ * @throws PDFDocumentException
* @throws TextExtractionException
* Forwarded exception.
*/
- public static String extractTextTextual(PdfDataSource pdfDataSource) throws TextExtractionException
+ public static String extractTextTextual(PdfDataSource pdfDataSource) throws PDFDocumentException
{
PerformanceCounters.textExtractions.increment();
@@ -85,7 +87,7 @@ public class TextualSignature
PdfReader reader = new PdfReader(pdf_data);
if (!reader.isOpenedWithFullPermissions()) {
// cannot perform modification and extraction
- throw new TextExtractionException("Document is protected");
+ throw new PDFDocumentException(ErrorCode.DOCUMENT_IS_PROTECTED, "Document is protected.");
}
//pdf_stream.close();
@@ -178,15 +180,15 @@ public class TextualSignature
}
catch (IllegalArgumentException e)
{
- throw new TextExtractionException(e);
+ throw new PDFDocumentException(ErrorCode.DOCUMENT_CANNOT_BE_READ, e);
}
catch (IOException e)
{
- throw new TextExtractionException(e);
+ throw new PDFDocumentException(ErrorCode.DOCUMENT_CANNOT_BE_READ, e);
}
catch (DocumentException e)
{
- throw new TextExtractionException(e);
+ throw new PDFDocumentException(ErrorCode.DOCUMENT_CANNOT_BE_READ, e);
}
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/BKUConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/BKUConnector.java
index c5ab9f5..c02b2c9 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/BKUConnector.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/BKUConnector.java
@@ -626,6 +626,7 @@ public class BKUConnector implements LocalConnector
String keybox_identifier = getSignKeyboxIdentifier(signType);
String sign_request_filename = getSignRequestTemplateFileName(signType);
+ // FIXME[tknall]: might fail since template has been moved to library
String sign_req_str = FileHelper.readFromFile(SettingsReader.relocateFile(sign_request_filename));
if (logger_.isDebugEnabled())
{
@@ -650,6 +651,7 @@ public class BKUConnector implements LocalConnector
SignatureObject sigObject) throws SignatureException
{
String verify_request = getVerifyRequestTemplateFileName(sigObject.getSignationType());
+ // FIXME[tknall]: might fail since template has been moved to library
String verify_req_str = FileHelper.readFromFile(SettingsReader.relocateFile(verify_request));
if (logger_.isDebugEnabled())
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java
index 7406ccd..30bffb7 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java
@@ -181,6 +181,7 @@ public class MOAConnector implements Connector
String sign_request_filename = getSignRequestTemplateFileName(sigType);
String key_ident = getSignKeyIdentifier(sigType);
+ // FIXME[tknall]: might fail since template has been moved to library
String sign_req_str = FileHelper.readFromFile(SettingsReader.relocateFile(sign_request_filename));
if (sign_req_str == null)
{
@@ -413,7 +414,9 @@ public class MOAConnector implements Connector
}
String verify_template = getVerifyTemplateFileName(sigObject.getSignationType());
String sig_prop_template = getSigPropFileName(sigObject.getSignationType());
+ // FIXME[tknall]: might fail since template has been moved to library
String verify_req_str = FileHelper.readFromFile(SettingsReader.relocateFile(verify_template));
+ // FIXME[tknall]: might fail since template has been moved to library
String sig_prop_str = FileHelper.readFromFile(SettingsReader.relocateFile(sig_prop_template));
if (logger_.isDebugEnabled())
@@ -522,6 +525,7 @@ public class MOAConnector implements Connector
// +
// ".request");
String trust_profile = getVerifyTrustProfileID(sigObject.getSignationType());
+ // FIXME[tknall]: might fail since template has been moved to library
String verify_req_str = FileHelper.readFromFile(SettingsReader.relocateFile(verify_request));
String verify_template_str = null;
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUPostConnection.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUPostConnection.java
index d2cffe8..6ea8ced 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUPostConnection.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUPostConnection.java
@@ -100,8 +100,10 @@ public final class BKUPostConnection
//ByteArrayPartSource baps = new ByteArrayPartSource(filename, data.getData());
FilePart filepart = new FilePart("fileupload", ps); //$NON-NLS-1$
filepart.setContentType(data.getMimeType());
- // this is optional
- // filepart.setCharSet(data.getCharacterEncoding());
+
+ // not really needed since external referenced data has to be taken "as-is" (binary stream) for
+ // digest calculation, so neither content type nor charset is relevant
+ filepart.setCharSet(data.getCharacterEncoding());
Part[] parts = { xmlpart, filepart };
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapConnection.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapConnection.java
index d0448cb..38998c4 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapConnection.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapConnection.java
@@ -198,8 +198,10 @@ public final class MOASoapConnection
FilePartMR filepart = new FilePartMR("fileupload", ps); //$NON-NLS-1$
filepart.setContentType(data.getMimeType());
filepart.setContentID("<fileupload>");
- // this is optional
- // filepart.setCharSet(data.getCharacterEncoding());
+
+ // not really needed since external referenced data has to be taken "as-is" (binary stream) for
+ // digest calculation, so neither content type nor charset is relevant
+ filepart.setCharSet(data.getCharacterEncoding());
Part[] parts = { xmlpart, filepart };