aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-legacy
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-legacy')
-rw-r--r--pdf-as-legacy/build.gradle1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java9
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/PdfAs.java18
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeParameters.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeResult.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/NonTextObjectInfo.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/package-info.java8
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureLifetimeEnum.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfile.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfileImpl.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureInformation.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureProfile.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/package-info.java8
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/ConfigUtilsException.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/ErrorCode.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/PdfAsException.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/PdfAsWrappedException.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/package-info.java8
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/DataSink.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/DataSource.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/FileBased.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/TextBased.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/package-info.java8
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/package-info.java8
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/SignResult.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/SignatureDetailInformation.java1
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/package-info.java8
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/pos/SignaturePositioning.java41
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/package-info.java8
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/ByteArrayDataSink_OLD.java34
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/ByteArrayDataSource_OLD.java40
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/FileDataSource.java43
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/LegacyMainTest.java51
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/PdfAsObject.java106
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignParameterWrapper.java95
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignResultImpl.java40
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignatureDetailInformationWrapper.java56
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/VerifyParameterWrapper.java8
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/package-info.java8
-rw-r--r--pdf-as-legacy/src/main/java/at/knowcenter/wag/egov/egiz/sig/package-info.java8
42 files changed, 506 insertions, 128 deletions
diff --git a/pdf-as-legacy/build.gradle b/pdf-as-legacy/build.gradle
index 25a2d5ba..5d27b162 100644
--- a/pdf-as-legacy/build.gradle
+++ b/pdf-as-legacy/build.gradle
@@ -19,6 +19,7 @@ dependencies {
compile project (':pdf-as-lib')
compile project (':stamper:stmp-itext')
compile project (':signature-standards:sigs-pkcs7detached')
+ compile project (':signature-standards:sigs-pades')
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.1'
compile group: 'commons-codec', name: 'commons-codec', version: '1.8'
testCompile group: 'junit', name: 'junit', version: '4.+'
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java
index 95ffa42b..c09dbd40 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java
@@ -36,6 +36,7 @@ import at.gv.egiz.pdfas.wrapper.PdfAsObject;
*
* @author wprinz
*/
+@Deprecated
public class PdfAsFactory
{
/**
@@ -54,9 +55,10 @@ public class PdfAsFactory
* if the config file is invalid.
* @see PdfAS#USERHOME_CONFIG_FOLDER
*/
+ @Deprecated
public static PdfAs createPdfAs(File workDirectory) throws PdfAsException
{
- return createPdfAs(workDirectory);
+ return new PdfAsObject(workDirectory);
}
/**
@@ -79,6 +81,7 @@ public class PdfAsFactory
* if the config file is invalid.
* @see PdfAS#USERHOME_CONFIG_FOLDER
*/
+ @Deprecated
public static PdfAs createPdfAs(File workDirectory, boolean registerProvider) throws PdfAsException
{
return new PdfAsObject(workDirectory);
@@ -96,9 +99,10 @@ public class PdfAsFactory
* if the config file is invalid.
* @see PdfAS#USERHOME_CONFIG_FOLDER
*/
+ @Deprecated
public static PdfAs createPdfAs() throws PdfAsException
{
- return createPdfAs(null);
+ return createPdfAs(new File(System.getProperty("user.home") + "/.pdfas/"));
}
/**
@@ -118,6 +122,7 @@ public class PdfAsFactory
* if the config file is invalid.
* @see PdfAS#USERHOME_CONFIG_FOLDER
*/
+ @Deprecated
public static PdfAs createPdfAs(boolean registerProvider) throws PdfAsException
{
return createPdfAs(null, registerProvider);
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/PdfAs.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/PdfAs.java
index 51644ddd..505360c1 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/PdfAs.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/PdfAs.java
@@ -53,6 +53,7 @@ import at.gv.egiz.pdfas.api.xmldsig.ReconstructXMLDsigResult;
* @author wprinz
* @author exthex
*/
+@Deprecated
public interface PdfAs
{
// 23.11.2010 changed by exthex - added:
@@ -77,6 +78,7 @@ public interface PdfAs
* @see SignParameters
* @see SignResult
*/
+ @Deprecated
public SignResult sign(SignParameters signParameters) throws PdfAsException;
/**
@@ -94,6 +96,7 @@ public interface PdfAs
* @see SignParameters
* @see SignResult
*/
+ @Deprecated
public SignResult sign(SignParameters signParameters, SignatureDetailInformation signatureDetailInformation) throws PdfAsException;
/**
@@ -109,6 +112,7 @@ public interface PdfAs
* @see VerifyResults
* @see VerifyResult
*/
+ @Deprecated
public VerifyResults verify(VerifyParameters verifyParameters) throws PdfAsException;
/**
@@ -125,6 +129,7 @@ public interface PdfAs
* @see AnalyzeResult
* @see {@link #verify(AnalyzeResult)}
*/
+ @Deprecated
public AnalyzeResult analyze(AnalyzeParameters analyzeParameters) throws PdfAsException;
/**
@@ -135,6 +140,7 @@ public interface PdfAs
* @return a list of xmldsigs, one for each signature in the document
* @throws PdfAsException if the reconstruction fails
*/
+ @Deprecated
public ReconstructXMLDsigResult reconstructXMLDSIG(ReconstructXMLDsigParameters reconstructXMLDsigParameters) throws PdfAsException;
/**
@@ -145,6 +151,7 @@ public interface PdfAs
* @return a list of xmldsigs, one for each signature in the document
* @throws PdfAsException
*/
+ @Deprecated
public ReconstructXMLDsigResult reconstructXMLDSIG(ReconstructXMLDsigAfterAnalysisParameters reconstructXMLDsigParameters) throws PdfAsException;
/**
@@ -162,6 +169,7 @@ public interface PdfAs
* @see VerifyResult
* @see {@link #analyze(AnalyzeParameters)}
*/
+ @Deprecated
public VerifyResults verify(VerifyAfterAnalysisParameters verifyAfterAnalysisParameters) throws PdfAsException;
/**
@@ -173,6 +181,7 @@ public interface PdfAs
* @throws PdfAsException
* Thrown on error.
*/
+ @Deprecated
public VerifyResults verify(VerifyAfterReconstructXMLDsigParameters verifyAfterReconstructXMLDsigParameters) throws PdfAsException;
/**
@@ -181,6 +190,7 @@ public interface PdfAs
* @throws PdfAsException
* Thrown, if an error occurs.
*/
+ @Deprecated
public void reloadConfig() throws PdfAsException;
/**
@@ -204,6 +214,7 @@ public interface PdfAs
*
* @see SignatureProfile
*/
+ @Deprecated
public List getProfileInformation() throws PdfAsException;
/**
@@ -212,6 +223,7 @@ public interface PdfAs
* @param mode lifetime mode
* @return the created signature profile to work with.
*/
+ @Deprecated
public DynamicSignatureProfile createDynamicSignatureProfile(String parentProfile, DynamicSignatureLifetimeEnum mode);
/**
@@ -224,6 +236,7 @@ public interface PdfAs
* @param mode lifetime mode
* @return the created signature profile to work with.
*/
+ @Deprecated
public DynamicSignatureProfile createDynamicSignatureProfile(String myUniqueName, String parentProfile, DynamicSignatureLifetimeEnum mode);
/**
@@ -235,6 +248,7 @@ public interface PdfAs
* @return the created signature profile to work with.
* @see DynamicSignatureProfile
*/
+ @Deprecated
public DynamicSignatureProfile createEmptyDynamicSignatureProfile(DynamicSignatureLifetimeEnum mode);
/**
@@ -246,6 +260,7 @@ public interface PdfAs
* @param mode lifetime mode
* @return the created signature profile to work with.
*/
+ @Deprecated
public DynamicSignatureProfile createEmptyDynamicSignatureProfile(String myUniqueName, DynamicSignatureLifetimeEnum mode);
/**
@@ -255,6 +270,7 @@ public interface PdfAs
* @return the signature profile or <code>null</code> if not found.
* @see DynamicSignatureProfile
*/
+ @Deprecated
public DynamicSignatureProfile loadDynamicSignatureProfile(String profileName);
/**
@@ -266,6 +282,7 @@ public interface PdfAs
* @return Only the {@link SignatureDetailInformation#getSignaturePosition()}, {@link SignatureDetailInformation#getNonTextualObjects()}, {@link SignatureDetailInformation#getSignatureData()} are filled.
* @throws PdfAsException if something goes wrong during the process
*/
+ @Deprecated
public SignatureDetailInformation prepareSign(SignParameters signParameters) throws PdfAsException;
/**
@@ -279,6 +296,7 @@ public interface PdfAs
* @return
* @throws PdfAsException
*/
+ @Deprecated
public SignResult finishSign(SignParameters signParameters, SignatureDetailInformation signatureDetailInformation) throws PdfAsException;
}
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeParameters.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeParameters.java
index 1ce7057f..164aa464 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeParameters.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeParameters.java
@@ -31,6 +31,7 @@ import at.gv.egiz.pdfas.api.io.DataSource;
*
* @author wprinz
*/
+@Deprecated
public class AnalyzeParameters
{
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeResult.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeResult.java
index 9b913ae4..43c23190 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeResult.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeResult.java
@@ -34,6 +34,7 @@ import at.gv.egiz.pdfas.api.exceptions.PdfAsException;
* @author wprinz
*
*/
+@Deprecated
public interface AnalyzeResult
{
/**
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/NonTextObjectInfo.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/NonTextObjectInfo.java
index 08297b7a..311cff45 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/NonTextObjectInfo.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/NonTextObjectInfo.java
@@ -29,6 +29,7 @@ package at.gv.egiz.pdfas.api.analyze;
* @author dferbas
*
*/
+@Deprecated
public class NonTextObjectInfo {
public static final String TYPE_IMAGE = "image";
public static final String TYPE_ANNOTATION = "annotation";
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/package-info.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/package-info.java
deleted file mode 100644
index 9c56d142..00000000
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/analyze/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author afitzek
- *
- */
-package at.gv.egiz.pdfas.api.analyze; \ No newline at end of file
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java
index 2bc68ea0..568787b4 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java
@@ -29,6 +29,7 @@ package at.gv.egiz.pdfas.api.commons;
*
* @author wprinz
*/
+@Deprecated
public final class Constants
{
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureLifetimeEnum.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureLifetimeEnum.java
index 7b3d17b2..369bff87 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureLifetimeEnum.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureLifetimeEnum.java
@@ -31,6 +31,7 @@ import java.io.Serializable;
* @author exthex
*
*/
+@Deprecated
public final class DynamicSignatureLifetimeEnum implements Serializable {
private static final long serialVersionUID = 1L;
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfile.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfile.java
index 7418f4dc..9620d2fe 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfile.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfile.java
@@ -71,6 +71,7 @@ import at.gv.egiz.pdfas.api.sign.SignParameters;
* @author exthex
*
*/
+@Deprecated
public interface DynamicSignatureProfile {
/**
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfileImpl.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfileImpl.java
index dd336707..71317a52 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfileImpl.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfileImpl.java
@@ -41,6 +41,7 @@ import at.knowcenter.wag.egov.egiz.sig.SignatureTypes;
* @author exthex
*
*/
+@Deprecated
public class DynamicSignatureProfileImpl implements DynamicSignatureProfile {
private String name;
private Properties newProps = new Properties();
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureInformation.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureInformation.java
index 7315af6a..2f5c7d97 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureInformation.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureInformation.java
@@ -38,6 +38,7 @@ import at.gv.egiz.pdfas.api.io.DataSource;
*
* @author wprinz
*/
+@Deprecated
public interface SignatureInformation
{
/**
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureProfile.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureProfile.java
index 1325d04f..def2d820 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureProfile.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureProfile.java
@@ -32,6 +32,7 @@ import at.knowcenter.wag.egov.egiz.sig.SignatureTypes.State;
*
* @author wprinz
*/
+@Deprecated
public interface SignatureProfile {
// TODO: implement full profile support
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/package-info.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/package-info.java
deleted file mode 100644
index a439a40f..00000000
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author afitzek
- *
- */
-package at.gv.egiz.pdfas.api.commons; \ No newline at end of file
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/ConfigUtilsException.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/ConfigUtilsException.java
index 644f74ee..f8059d16 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/ConfigUtilsException.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/ConfigUtilsException.java
@@ -26,6 +26,7 @@ package at.gv.egiz.pdfas.api.exceptions;
/**
* @author <a href="mailto:thomas.knall@egiz.gv.at">Thomas Knall</a>
*/
+@Deprecated
public class ConfigUtilsException extends Exception {
/**
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/ErrorCode.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/ErrorCode.java
index 790ce9e0..c5364abc 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/ErrorCode.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/ErrorCode.java
@@ -32,6 +32,7 @@ package at.gv.egiz.pdfas.api.exceptions;
*
* @author wprinz
*/
+@Deprecated
public final class ErrorCode
{
public static final int EXTERNAL_ERROR = 0;
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/PdfAsException.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/PdfAsException.java
index 1fb556a5..fb602934 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/PdfAsException.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/PdfAsException.java
@@ -32,6 +32,7 @@ package at.gv.egiz.pdfas.api.exceptions;
*
* @author wprinz
*/
+@Deprecated
public class PdfAsException extends Exception
{
/**
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/PdfAsWrappedException.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/PdfAsWrappedException.java
index 2ddd1146..c5fb3fd3 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/PdfAsWrappedException.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/PdfAsWrappedException.java
@@ -1,5 +1,6 @@
package at.gv.egiz.pdfas.api.exceptions;
+@Deprecated
public class PdfAsWrappedException extends PdfAsException {
/**
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/package-info.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/package-info.java
deleted file mode 100644
index 51f23335..00000000
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/exceptions/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author afitzek
- *
- */
-package at.gv.egiz.pdfas.api.exceptions; \ No newline at end of file
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/DataSink.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/DataSink.java
index a539ce03..5163822d 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/DataSink.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/DataSink.java
@@ -37,6 +37,7 @@ import java.io.OutputStream;
*
* @author wprinz
*/
+@Deprecated
public interface DataSink
{
/**
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/DataSource.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/DataSource.java
index 41502558..dfeb6261 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/DataSource.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/DataSource.java
@@ -35,6 +35,7 @@ import java.io.InputStream;
* @author wprinz
*
*/
+@Deprecated
public interface DataSource
{
/**
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/FileBased.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/FileBased.java
index f3d0d0e6..c09f480b 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/FileBased.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/FileBased.java
@@ -34,6 +34,7 @@ import java.io.File;
*
* @author wprinz
*/
+@Deprecated
public interface FileBased
{
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/TextBased.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/TextBased.java
index 39602ff4..9e3987ba 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/TextBased.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/TextBased.java
@@ -37,6 +37,7 @@ package at.gv.egiz.pdfas.api.io;
*
* @author wprinz
*/
+@Deprecated
public interface TextBased
{
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/package-info.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/package-info.java
deleted file mode 100644
index 0831b9b9..00000000
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/io/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author afitzek
- *
- */
-package at.gv.egiz.pdfas.api.io; \ No newline at end of file
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/package-info.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/package-info.java
deleted file mode 100644
index 0a065481..00000000
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author afitzek
- *
- */
-package at.gv.egiz.pdfas.api; \ No newline at end of file
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java
index 5533b8b3..62b48227 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java
@@ -37,6 +37,7 @@ import at.knowcenter.wag.egov.egiz.sig.SignatureTypes;
*
* @author wprinz
*/
+@Deprecated
public class SignParameters
{
// 23.11.2010 changed by exthex - added parameters for placeholder handling
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/SignResult.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/SignResult.java
index fa0282f9..ad9b6cf8 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/SignResult.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/SignResult.java
@@ -35,6 +35,7 @@ import at.gv.egiz.pdfas.api.sign.pos.SignaturePosition;
*
* @author wprinz
*/
+@Deprecated
public interface SignResult
{
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/SignatureDetailInformation.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/SignatureDetailInformation.java
index c5a0263b..b4bba9a3 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/SignatureDetailInformation.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/SignatureDetailInformation.java
@@ -37,6 +37,7 @@ import at.gv.egiz.pdfas.api.sign.pos.SignaturePosition;
*
* @author exthex
*/
+@Deprecated
public interface SignatureDetailInformation
{
public DataSource getSignatureData();
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/package-info.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/package-info.java
deleted file mode 100644
index 95c97422..00000000
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author afitzek
- *
- */
-package at.gv.egiz.pdfas.api.sign; \ No newline at end of file
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/pos/SignaturePositioning.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/pos/SignaturePositioning.java
index eb9b9de4..029d9022 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/pos/SignaturePositioning.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/sign/pos/SignaturePositioning.java
@@ -291,6 +291,47 @@ public class SignaturePositioning implements Serializable
}
}
}
+
+ public String getPositionString() {
+ StringBuilder sb = new StringBuilder();
+ AxisAlgorithm xAlgo = getXAlgorithm();
+
+ if(xAlgo instanceof AutoAxisAlgorithm) {
+ sb.append("x:auto;");
+ } else if(xAlgo instanceof AbsoluteAxisAlgorithm) {
+ sb.append("x:" + ((AbsoluteAxisAlgorithm)xAlgo).getAbsoluteValue() + ";");
+ }
+
+ AxisAlgorithm yAlgo = getXAlgorithm();
+
+ if(yAlgo instanceof AutoAxisAlgorithm) {
+ sb.append("y:auto;");
+ } else if(yAlgo instanceof AbsoluteAxisAlgorithm) {
+ sb.append("y:" + ((AbsoluteAxisAlgorithm)yAlgo).getAbsoluteValue() + ";");
+ }
+
+ AxisAlgorithm wAlgo = getWidthAlgorithm();
+
+ if(wAlgo instanceof AutoAxisAlgorithm) {
+ sb.append("w:auto;");
+ } else if(wAlgo instanceof AbsoluteAxisAlgorithm) {
+ sb.append("w:" + ((AbsoluteAxisAlgorithm)wAlgo).getAbsoluteValue() + ";");
+ }
+
+ PageAlgorithm pAlgo = getPageAlgorithm();
+
+ if(pAlgo instanceof AutoPageAlgorithm) {
+ sb.append("p:auto;");
+ } else if(pAlgo instanceof NewPageAlgorithm) {
+ sb.append("p:new;");
+ }
+
+ float footerLine = getFooterLine();
+
+ sb.append("f:" + + footerLine);
+
+ return sb.toString();
+ }
}
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/package-info.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/package-info.java
deleted file mode 100644
index 073f3ce2..00000000
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author afitzek
- *
- */
-package at.gv.egiz.pdfas; \ No newline at end of file
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/ByteArrayDataSink_OLD.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/ByteArrayDataSink_OLD.java
new file mode 100644
index 00000000..bb39a322
--- /dev/null
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/ByteArrayDataSink_OLD.java
@@ -0,0 +1,34 @@
+package at.gv.egiz.pdfas.wrapper;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import at.gv.egiz.pdfas.api.io.DataSink;
+
+public class ByteArrayDataSink_OLD implements DataSink {
+
+ private ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ public ByteArrayOutputStream getBAOS() {
+ return baos;
+ }
+
+ public OutputStream createOutputStream(String mimeType) throws IOException {
+ return baos;
+ }
+
+ public OutputStream createOutputStream(String mimeType,
+ String characterEncoding) throws IOException {
+ return baos;
+ }
+
+ public String getMimeType() {
+ return "application/pdf";
+ }
+
+ public String getCharacterEncoding() {
+ return "UTF-8";
+ }
+
+}
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/ByteArrayDataSource_OLD.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/ByteArrayDataSource_OLD.java
new file mode 100644
index 00000000..ad494acd
--- /dev/null
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/ByteArrayDataSource_OLD.java
@@ -0,0 +1,40 @@
+package at.gv.egiz.pdfas.wrapper;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import at.gv.egiz.pdfas.api.io.DataSource;
+
+public class ByteArrayDataSource_OLD implements DataSource {
+
+ private InputStream is;
+ private int length;
+ private byte[] data;
+
+ public ByteArrayDataSource_OLD(byte[] data) {
+ this.length = data.length;
+ this.is = new ByteArrayInputStream(data);
+ this.data = data;
+ }
+
+ public InputStream createInputStream() {
+ return is;
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+ public byte[] getAsByteArray() {
+ return this.data;
+ }
+
+ public String getMimeType() {
+ return "application/pdf";
+ }
+
+ public String getCharacterEncoding() {
+ return "UTF-8";
+ }
+
+}
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/FileDataSource.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/FileDataSource.java
new file mode 100644
index 00000000..19394f0a
--- /dev/null
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/FileDataSource.java
@@ -0,0 +1,43 @@
+package at.gv.egiz.pdfas.wrapper;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.management.RuntimeErrorException;
+
+import at.gv.egiz.pdfas.api.io.DataSource;
+import at.gv.egiz.pdfas.common.utils.StreamUtils;
+
+public class FileDataSource implements DataSource {
+
+ private byte[] data;
+
+ public FileDataSource(File file) throws FileNotFoundException, IOException {
+ data = StreamUtils.inputStreamToByteArray(new FileInputStream(file));
+ }
+
+ public InputStream createInputStream() {
+ return new ByteArrayInputStream(data);
+ }
+
+ public int getLength() {
+ return data.length;
+ }
+
+ public byte[] getAsByteArray() {
+ return data;
+ }
+
+ public String getMimeType() {
+ return "application/pdf";
+ }
+
+ public String getCharacterEncoding() {
+ return "UTF-8";
+ }
+
+}
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/LegacyMainTest.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/LegacyMainTest.java
new file mode 100644
index 00000000..b64bb4c7
--- /dev/null
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/LegacyMainTest.java
@@ -0,0 +1,51 @@
+package at.gv.egiz.pdfas.wrapper;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.Iterator;
+
+import at.gv.egiz.pdfas.PdfAsFactory;
+import at.gv.egiz.pdfas.api.PdfAs;
+import at.gv.egiz.pdfas.api.sign.SignParameters;
+import at.gv.egiz.pdfas.api.verify.VerifyParameters;
+import at.gv.egiz.pdfas.api.verify.VerifyResult;
+import at.gv.egiz.pdfas.api.verify.VerifyResults;
+
+public class LegacyMainTest {
+ public static void main(String[] args) {
+ try {
+ PdfAs pdfAsOld = PdfAsFactory.createPdfAs();
+ SignParameters signParameters = new SignParameters();
+ signParameters.setSignatureProfileId("SIGNATURBLOCK_DE");
+ signParameters.setSignatureDevice("bku");
+ signParameters.setSignatureType("binary");
+
+ FileDataSource dataSource = new FileDataSource(new File("/home/afitzek/simple.pdf"));
+ signParameters.setDocument(dataSource);
+ ByteArrayDataSink_OLD dataSink = new ByteArrayDataSink_OLD();
+ signParameters.setOutput(dataSink);
+ pdfAsOld.sign(signParameters);
+
+ FileOutputStream fos = new FileOutputStream(new File("/home/afitzek/simple_osigned.pdf"));
+ fos.write(dataSink.getBAOS().toByteArray());
+ fos.close();
+
+ VerifyParameters parameters = new VerifyParameters();
+ parameters.setDocument(new FileDataSource(new File("/home/afitzek/simple_osigned.pdf")));
+ parameters.setSignatureDevice("bku");
+
+ VerifyResults verifyResults = pdfAsOld.verify(parameters);
+
+ Iterator<Object> verifyIt = verifyResults.getResults().iterator();
+
+ while(verifyIt.hasNext()) {
+ Object obj = verifyIt.next();
+ VerifyResult verify = (VerifyResult)obj;
+ System.out.println("Verify Code: " + verify.getValueCheckCode().getCode());
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/PdfAsObject.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/PdfAsObject.java
index 30814ff3..0f1a60c1 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/PdfAsObject.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/PdfAsObject.java
@@ -1,6 +1,10 @@
package at.gv.egiz.pdfas.wrapper;
+import iaik.x509.X509Certificate;
+
import java.io.File;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -46,38 +50,62 @@ public class PdfAsObject implements PdfAs {
public SignResult sign(SignParameters signParameters,
SignatureDetailInformation signatureDetailInformation)
throws PdfAsException {
- // Create the signature ....
- SignParameter signParameter4 = PdfAsFactory.createSignParameter(
- this.configuration, new ByteArrayDataSource(signParameters
- .getDocument().getAsByteArray()));
- SignParameterWrapper wrapper = new SignParameterWrapper(signParameters, signParameter4);
-
- // TODO wait for SL wrapper implementation
- return null;
+ if (!(signatureDetailInformation instanceof SignatureDetailInformationWrapper)) {
+ throw new PdfAsException(ErrorCode.SIGNATURE_COULDNT_BE_CREATED,
+ "Invalid state");
+ }
+
+ SignatureDetailInformationWrapper sdi = (SignatureDetailInformationWrapper) signatureDetailInformation;
+ StatusRequest request = sdi.getStatus();
+
+ if (request.needSignature()) {
+ try {
+ byte[] signature = sdi.wrapper.getSignParameter4().getPlainSigner().sign(
+ request.getSignatureData(), request.getSignatureDataByteRange());
+ request.setSigature(signature);
+ request = this.pdfas4.process(request);
+ if(request.isReady()) {
+ at.gv.egiz.pdfas.lib.api.sign.SignResult result = this.pdfas4.finishSign(request);
+ sdi.wrapper.syncNewToOld();
+ SignResultImpl oldresult = new SignResultImpl(sdi.wrapper.getSignParameters().getOutput(),
+ sdi.getX509Certificate());
+ return oldresult;
+ } else {
+ throw new PdfAsException(ErrorCode.SIGNATURE_COULDNT_BE_CREATED,
+ "Invalid state");
+ }
+ } catch (at.gv.egiz.pdfas.common.exceptions.PdfAsException e) {
+ throw new PdfAsException(
+ ErrorCode.SIGNATURE_COULDNT_BE_CREATED, e.getMessage());
+ }
+ } else {
+ throw new PdfAsException(ErrorCode.SIGNATURE_COULDNT_BE_CREATED,
+ "Invalid state");
+ }
}
public VerifyResults verify(VerifyParameters verifyParameters)
throws PdfAsException {
try {
- VerifyParameter newParameter = VerifyParameterWrapper.toNewParameters(verifyParameters);
-
+ VerifyParameter newParameter = VerifyParameterWrapper
+ .toNewParameters(verifyParameters, this.pdfas4.getConfiguration());
+
List<VerifyResult> results = this.pdfas4.verify(newParameter);
-
+
Iterator<VerifyResult> it = results.iterator();
-
- List<at.gv.egiz.pdfas.api.verify.VerifyResult> resultList =
- new ArrayList<at.gv.egiz.pdfas.api.verify.VerifyResult>();
-
- while(it.hasNext()) {
+
+ List<at.gv.egiz.pdfas.api.verify.VerifyResult> resultList = new ArrayList<at.gv.egiz.pdfas.api.verify.VerifyResult>();
+
+ while (it.hasNext()) {
VerifyResult newResult = it.next();
- at.gv.egiz.pdfas.api.verify.VerifyResult oldResult =
- new VerifyResultWrapper(newResult);
+ at.gv.egiz.pdfas.api.verify.VerifyResult oldResult = new VerifyResultWrapper(
+ newResult);
resultList.add(oldResult);
}
-
+
return new VerifyResultsImpl(resultList);
- } catch(at.gv.egiz.pdfas.common.exceptions.PdfAsException e) {
+ } catch (at.gv.egiz.pdfas.common.exceptions.PdfAsException e) {
throw new PdfAsException(0, e.getMessage());
}
}
@@ -166,15 +194,39 @@ public class PdfAsObject implements PdfAs {
this.configuration, new ByteArrayDataSource(signParameters
.getDocument().getAsByteArray()));
- SignParameterWrapper wrapper = new SignParameterWrapper(signParameters, signParameter4);
-
- // TODO: wrapper sync old to new
- StatusRequest request = this.pdfas4.startSign(wrapper.getSignParameter4());
- // TODO: wait for SL implementation wrapper
- return null;
+ SignParameterWrapper wrapper = new SignParameterWrapper(
+ signParameters, signParameter4);
+ SignatureDetailInformationWrapper sdi = null;
+
+ wrapper.syncOldToNew();
+
+ StatusRequest request = this.pdfas4.startSign(wrapper
+ .getSignParameter4());
+
+ if (request.needCertificate()) {
+ X509Certificate certificate = signParameter4.getPlainSigner()
+ .getCertificate();
+ sdi = new SignatureDetailInformationWrapper(certificate);
+ request.setCertificate(certificate.getEncoded());
+ request = this.pdfas4.process(request);
+ if (request.needSignature()) {
+ sdi.setDataSource(new ByteArrayDataSource_OLD(request
+ .getSignatureData()));
+ }
+ sdi.wrapper = wrapper;
+ sdi.setStatus(request);
+ }
+ return sdi;
} catch (at.gv.egiz.pdfas.common.exceptions.PdfAsException e) {
- throw new PdfAsException(0, e.getMessage());
+ throw new PdfAsException(ErrorCode.SIGNATURE_COULDNT_BE_CREATED,
+ e.getMessage());
+ } catch (CertificateEncodingException e) {
+ throw new PdfAsException(ErrorCode.SIGNATURE_COULDNT_BE_CREATED,
+ e.getMessage());
+ } catch (CertificateException e) {
+ throw new PdfAsException(ErrorCode.SIGNATURE_COULDNT_BE_CREATED,
+ e.getMessage());
}
}
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignParameterWrapper.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignParameterWrapper.java
index b51896bd..87278c85 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignParameterWrapper.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignParameterWrapper.java
@@ -1,31 +1,104 @@
package at.gv.egiz.pdfas.wrapper;
+import java.io.OutputStream;
+import java.util.Enumeration;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.gv.egiz.pdfas.api.exceptions.ErrorCode;
+import at.gv.egiz.pdfas.api.exceptions.PdfAsException;
import at.gv.egiz.pdfas.api.sign.SignParameters;
+import at.gv.egiz.pdfas.lib.api.ByteArrayDataSink;
import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
+import at.gv.egiz.pdfas.sigs.pades.PAdESSigner;
+import at.gv.egiz.sl.util.BKUSLConnector;
+import at.gv.egiz.sl.util.MOAConnector;
public class SignParameterWrapper {
+ private static final Logger logger = LoggerFactory
+ .getLogger(SignParameterWrapper.class);
+
private SignParameter signParameter4;
private SignParameters signParameters;
-
- public SignParameterWrapper(SignParameters signParameters, SignParameter signParameter4) {
+ private ByteArrayDataSink output;
+
+ public SignParameterWrapper(SignParameters signParameters,
+ SignParameter signParameter4) {
this.signParameter4 = signParameter4;
this.signParameters = signParameters;
}
-
- private void syncOldToNew() {
- // TODO
+
+ public void syncOldToNew() throws PdfAsException {
+ output = new ByteArrayDataSink();
+ this.signParameter4.setOutput(output);
+
+ if (this.signParameters.getSignaturePositioning() != null) {
+ // Create positioning string
+ String posString = this.signParameters.getSignaturePositioning()
+ .getPositionString();
+ logger.info("Pos String: " + posString);
+ if (posString.equals("x:auto;y:auto;w:auto;p:auto;f:0.0")) {
+ this.signParameter4.setSignaturePosition(null);
+ } else {
+ this.signParameter4.setSignaturePosition(posString);
+ }
+ } else {
+ this.signParameter4.setSignaturePosition(null);
+ }
+
+ // Select signing device
+ if (this.signParameters.getSignatureDevice().equals("moa")) {
+ try {
+ this.signParameter4
+ .setPlainSigner(new PAdESSigner(new MOAConnector(
+ this.signParameter4.getConfiguration())));
+ } catch (Exception e) {
+ throw new PdfAsException(ErrorCode.CERTIFICATE_NOT_FOUND,
+ "You need to specify MOA certificate file to use moa (moa.sign.Certificate)");
+ }
+ } else if (this.signParameters.getSignatureDevice().equals("bku")) {
+ this.signParameter4
+ .setPlainSigner(new PAdESSigner(new BKUSLConnector(
+ this.signParameter4.getConfiguration())));
+ } else {
+ throw new PdfAsException(ErrorCode.UNSUPPORTED_SIGNATURE,
+ "Unsupported device! Use bku or moa!");
+ }
+
+ // Overwrite Configurations
+ Enumeration<Object> keys = this.signParameters
+ .getProfileOverrideProperties().keys();
+
+ while (keys.hasMoreElements()) {
+ Object obj = keys.nextElement();
+ if (obj != null) {
+ String key = obj.toString();
+ this.signParameter4.getConfiguration().setValue(
+ key,
+ this.signParameters.getProfileOverrideProperties()
+ .getProperty(key));
+ }
+ }
}
-
- private void syncNewToOld() {
- // TODO
+
+ public void syncNewToOld() throws PdfAsException {
+ try {
+ OutputStream os = this.signParameters.getOutput()
+ .createOutputStream("application/pdf");
+ os.write(output.getData());
+ os.close();
+ } catch (Exception e) {
+ throw new PdfAsException(ErrorCode.SIGNATURE_COULDNT_BE_CREATED,
+ e.getMessage());
+ }
}
-
-
+
public SignParameter getSignParameter4() {
return this.signParameter4;
}
-
+
public SignParameters getSignParameters() {
return this.signParameters;
}
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignResultImpl.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignResultImpl.java
new file mode 100644
index 00000000..b8a9ab33
--- /dev/null
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignResultImpl.java
@@ -0,0 +1,40 @@
+package at.gv.egiz.pdfas.wrapper;
+
+import java.security.cert.X509Certificate;
+import java.util.List;
+
+import at.gv.egiz.pdfas.api.io.DataSink;
+import at.gv.egiz.pdfas.api.sign.SignResult;
+import at.gv.egiz.pdfas.api.sign.pos.SignaturePosition;
+
+public class SignResultImpl implements SignResult {
+
+ private DataSink sink;
+ private X509Certificate certificate;
+
+ public SignResultImpl(DataSink data, X509Certificate cert) {
+ this.certificate = cert;
+ this.sink = data;
+ }
+
+ public DataSink getOutputDocument() {
+ return this.sink;
+ }
+
+ public X509Certificate getSignerCertificate() {
+ return certificate;
+ }
+
+ public SignaturePosition getSignaturePosition() {
+ return null;
+ }
+
+ public List getNonTextualObjects() {
+ return null;
+ }
+
+ public boolean hasNonTextualObjects() {
+ return false;
+ }
+
+}
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignatureDetailInformationWrapper.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignatureDetailInformationWrapper.java
index 683e083f..5192ffe4 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignatureDetailInformationWrapper.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignatureDetailInformationWrapper.java
@@ -8,14 +8,36 @@ import java.util.Map;
import at.gv.egiz.pdfas.api.io.DataSource;
import at.gv.egiz.pdfas.api.sign.SignatureDetailInformation;
import at.gv.egiz.pdfas.api.sign.pos.SignaturePosition;
+import at.gv.egiz.pdfas.common.utils.DNUtils;
+import at.gv.egiz.pdfas.lib.api.StatusRequest;
-public class SignatureDetailInformationWrapper implements SignatureDetailInformation {
+public class SignatureDetailInformationWrapper implements
+ SignatureDetailInformation {
- private SignParameterWrapper wrapper;
+ public SignParameterWrapper wrapper;
+ private StatusRequest status;
+ private DataSource dataSource;
+ private iaik.x509.X509Certificate certificate;
+
+ public SignatureDetailInformationWrapper(iaik.x509.X509Certificate cert) {
+ this.certificate = cert;
+ }
+
+ public StatusRequest getStatus() {
+ return status;
+ }
+
+ public void setStatus(StatusRequest status) {
+ this.status = status;
+ }
+
+ public void setDataSource(DataSource dataSource) {
+ this.dataSource = dataSource;
+ }
+
public DataSource getSignatureData() {
- // TODO
- return null;
+ return this.dataSource;
}
public SignaturePosition getSignaturePosition() {
@@ -32,23 +54,28 @@ public class SignatureDetailInformationWrapper implements SignatureDetailInforma
}
public String getIssuer() {
- return null;
+ return this.certificate.getIssuerDN().getName();
}
public Map getIssuerDNMap() {
- return null;
+ try {
+ return DNUtils.dnToMap(getIssuer());
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
}
public String getSubjectName() {
- return null;
+ return this.certificate.getSubjectDN().getName();
}
public String getSerialNumber() {
- return null;
+ return this.certificate.getSerialNumber().toString();
}
public String getSigAlgorithm() {
- return null;
+ return this.certificate.getSigAlgName();
}
public String getSigID() {
@@ -64,20 +91,23 @@ public class SignatureDetailInformationWrapper implements SignatureDetailInforma
}
public String getSigTimeStamp() {
- // TODO Auto-generated method stub
return null;
}
public Map getSubjectDNMap() {
- return null;
+ try {
+ return DNUtils.dnToMap(getSubjectName());
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
}
public X509Certificate getX509Certificate() {
- return null;
+ return this.certificate;
}
public boolean isTextual() {
- // TODO Auto-generated method stub
return false;
}
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/VerifyParameterWrapper.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/VerifyParameterWrapper.java
index 387d9ea4..51a8c843 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/VerifyParameterWrapper.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/VerifyParameterWrapper.java
@@ -1,14 +1,16 @@
package at.gv.egiz.pdfas.wrapper;
import at.gv.egiz.pdfas.api.verify.VerifyParameters;
+import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource;
+import at.gv.egiz.pdfas.lib.api.Configuration;
import at.gv.egiz.pdfas.lib.api.PdfAsFactory;
import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter;
public class VerifyParameterWrapper {
- public static VerifyParameter toNewParameters(VerifyParameters oldParameters) {
- //TODO
- return null;
+ public static VerifyParameter toNewParameters(VerifyParameters oldParameters, Configuration config) {
+ return PdfAsFactory.createVerifyParameter(config,
+ new ByteArrayDataSource(oldParameters.getDocument().getAsByteArray()));
}
}
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/package-info.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/package-info.java
deleted file mode 100644
index 37867d98..00000000
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author afitzek
- *
- */
-package at.gv.egiz.pdfas.wrapper; \ No newline at end of file
diff --git a/pdf-as-legacy/src/main/java/at/knowcenter/wag/egov/egiz/sig/package-info.java b/pdf-as-legacy/src/main/java/at/knowcenter/wag/egov/egiz/sig/package-info.java
deleted file mode 100644
index cf2d67f1..00000000
--- a/pdf-as-legacy/src/main/java/at/knowcenter/wag/egov/egiz/sig/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author afitzek
- *
- */
-package at.knowcenter.wag.egov.egiz.sig; \ No newline at end of file