From 896fbe4a5643bf8c29968f8514a1c14fd51c4d9e Mon Sep 17 00:00:00 2001 From: Tobias Kellner Date: Thu, 27 Nov 2014 20:48:16 +0100 Subject: Add PDF-AS4 signer --- pdf-over-gui/.project | 1 + pdf-over-signer/pdf-over-sigpdfas/.classpath | 31 -- pdf-over-signer/pdf-over-sigpdfas/.project | 23 - .../.settings/org.eclipse.core.resources.prefs | 6 - .../.settings/org.eclipse.jdt.core.prefs | 98 ---- .../.settings/org.eclipse.jdt.ui.prefs | 3 - .../.settings/org.eclipse.m2e.core.prefs | 5 - .../.settings/org.eclipse.mylyn.tasks.ui.prefs | 4 - pdf-over-signer/pdf-over-sigpdfas/pom.xml | 26 - .../signer/pdfas/ByteArrayPDFASDataSource.java | 67 --- .../at/asit/pdfover/signer/pdfas/PDFASHelper.java | 102 ---- .../asit/pdfover/signer/pdfas/PDFASSLRequest.java | 54 -- .../at/asit/pdfover/signer/pdfas/PDFASSigner.java | 190 ------- .../pdfover/signer/pdfas/PDFASSignerFactory.java | 31 -- .../pdfover/signer/pdfas/PDFASSigningState.java | 164 ------ .../signer/pdfas/PdfAsSignatureParameter.java | 603 --------------------- .../pdfas/exceptions/PDFASSLRequestException.java | 34 -- .../src/main/resources/img/fallbackPlaceholder.png | Bin 20948 -> 0 bytes .../src/main/resources/img/sign_prev_de.png | Bin 13580 -> 0 bytes .../src/main/resources/img/sign_prev_en.png | Bin 16968 -> 0 bytes pdf-over-signer/pdf-over-sigpdfas3/.classpath | 31 ++ pdf-over-signer/pdf-over-sigpdfas3/.project | 23 + .../.settings/org.eclipse.core.resources.prefs | 6 + .../.settings/org.eclipse.jdt.core.prefs | 97 ++++ .../.settings/org.eclipse.jdt.ui.prefs | 3 + .../.settings/org.eclipse.m2e.core.prefs | 5 + .../.settings/org.eclipse.mylyn.tasks.ui.prefs | 4 + pdf-over-signer/pdf-over-sigpdfas3/pom.xml | 26 + .../signer/pdfas/ByteArrayPDFASDataSource.java | 67 +++ .../at/asit/pdfover/signer/pdfas/PDFASHelper.java | 102 ++++ .../asit/pdfover/signer/pdfas/PDFASSLRequest.java | 54 ++ .../at/asit/pdfover/signer/pdfas/PDFASSigner.java | 190 +++++++ .../pdfover/signer/pdfas/PDFASSignerFactory.java | 31 ++ .../pdfover/signer/pdfas/PDFASSigningState.java | 173 ++++++ .../signer/pdfas/PdfAsSignatureParameter.java | 602 ++++++++++++++++++++ .../pdfas/exceptions/PDFASSLRequestException.java | 34 ++ .../src/main/resources/img/fallbackPlaceholder.png | Bin 0 -> 20948 bytes .../src/main/resources/img/sign_prev_de.png | Bin 0 -> 13580 bytes .../src/main/resources/img/sign_prev_en.png | Bin 0 -> 16968 bytes pdf-over-signer/pdf-over-sigpdfas4/.classpath | 31 ++ pdf-over-signer/pdf-over-sigpdfas4/.project | 26 + .../.settings/org.eclipse.core.resources.prefs | 6 + .../.settings/org.eclipse.jdt.core.prefs | 97 ++++ .../.settings/org.eclipse.jdt.ui.prefs | 3 + .../.settings/org.eclipse.m2e.core.prefs | 5 + .../.settings/org.eclipse.mylyn.tasks.ui.prefs | 4 + pdf-over-signer/pdf-over-sigpdfas4/pom.xml | 65 +++ .../pdfover/signer/pdfas/PdfAs4BKUSLConnector.java | 144 +++++ .../at/asit/pdfover/signer/pdfas/PdfAs4Helper.java | 79 +++ .../asit/pdfover/signer/pdfas/PdfAs4SLRequest.java | 56 ++ .../signer/pdfas/PdfAs4SignatureParameter.java | 161 ++++++ .../at/asit/pdfover/signer/pdfas/PdfAs4Signer.java | 146 +++++ .../pdfover/signer/pdfas/PdfAs4SignerFactory.java | 31 ++ .../pdfover/signer/pdfas/PdfAs4SigningState.java | 133 +++++ .../pdfas/exceptions/PdfAs4SLRequestException.java | 34 ++ .../src/main/resources/qualified.cer | 19 + .../pdf-as-common-4.0.5-SNAPSHOT.jar | Bin 0 -> 56922 bytes .../pdf-as-common-4.0.5-SNAPSHOT.pom | 46 ++ .../4.0.5-SNAPSHOT/pdf-as-lib-4.0.5-SNAPSHOT.jar | Bin 0 -> 1452115 bytes .../4.0.5-SNAPSHOT/pdf-as-lib-4.0.5-SNAPSHOT.pom | 88 +++ .../pdf-as-pdfbox/pdf-as-pdfbox-4.0.5-SNAPSHOT.jar | Bin 0 -> 106866 bytes .../pdf-as-pdfbox/pdf-as-pdfbox-4.0.5-SNAPSHOT.pom | 58 ++ .../4.0.5-SNAPSHOT/sigs-pades-4.0.5-SNAPSHOT.jar | Bin 0 -> 9586 bytes .../4.0.5-SNAPSHOT/sigs-pades-4.0.5-SNAPSHOT.pom | 40 ++ .../pdf-as/pdf-as-lib/3.5.2/pdf-as-lib-3.5.2.zip | Bin 24156527 -> 0 bytes repo/iaik/iaik_cms/2.15/iaik_cms-2.15.jar | Bin 0 -> 431577 bytes repo/iaik/iaik_cms/2.15/iaik_cms-2.15.pom | 9 + .../iaik_eccelerate/2.15/iaik_eccelerate-2.15.jar | Bin 0 -> 216213 bytes .../iaik_eccelerate/2.15/iaik_eccelerate-2.15.pom | 9 + .../2.15/iaik_eccelerate_cms-2.15.jar | Bin 0 -> 4274 bytes .../2.15/iaik_eccelerate_cms-2.15.pom | 9 + .../5.2/iaik_jce_full_signed-5.2.jar | Bin 0 -> 1129729 bytes .../5.2/iaik_jce_full_signed-5.2.pom | 9 + 73 files changed, 2757 insertions(+), 1441 deletions(-) delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/.classpath delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/.project delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.core.resources.prefs delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.jdt.core.prefs delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.jdt.ui.prefs delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.m2e.core.prefs delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.mylyn.tasks.ui.prefs delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/pom.xml delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/ByteArrayPDFASDataSource.java delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigner.java delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSignerFactory.java delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigningState.java delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/exceptions/PDFASSLRequestException.java delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/src/main/resources/img/fallbackPlaceholder.png delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/src/main/resources/img/sign_prev_de.png delete mode 100644 pdf-over-signer/pdf-over-sigpdfas/src/main/resources/img/sign_prev_en.png create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/.classpath create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/.project create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.core.resources.prefs create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.jdt.core.prefs create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.jdt.ui.prefs create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.m2e.core.prefs create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.mylyn.tasks.ui.prefs create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/pom.xml create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/ByteArrayPDFASDataSource.java create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigner.java create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSignerFactory.java create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigningState.java create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/exceptions/PDFASSLRequestException.java create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/src/main/resources/img/fallbackPlaceholder.png create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/src/main/resources/img/sign_prev_de.png create mode 100644 pdf-over-signer/pdf-over-sigpdfas3/src/main/resources/img/sign_prev_en.png create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/.classpath create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/.project create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.core.resources.prefs create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.jdt.core.prefs create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.jdt.ui.prefs create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.m2e.core.prefs create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.mylyn.tasks.ui.prefs create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/pom.xml create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Helper.java create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SLRequest.java create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignerFactory.java create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/exceptions/PdfAs4SLRequestException.java create mode 100644 pdf-over-signer/pdf-over-sigpdfas4/src/main/resources/qualified.cer create mode 100644 repo/at/gv/egiz/pdfas/pdf-as-common/4.0.5-SNAPSHOT/pdf-as-common-4.0.5-SNAPSHOT.jar create mode 100644 repo/at/gv/egiz/pdfas/pdf-as-common/4.0.5-SNAPSHOT/pdf-as-common-4.0.5-SNAPSHOT.pom create mode 100644 repo/at/gv/egiz/pdfas/pdf-as-lib/4.0.5-SNAPSHOT/pdf-as-lib-4.0.5-SNAPSHOT.jar create mode 100644 repo/at/gv/egiz/pdfas/pdf-as-lib/4.0.5-SNAPSHOT/pdf-as-lib-4.0.5-SNAPSHOT.pom create mode 100644 repo/at/gv/egiz/pdfas/pdf-as-pdfbox/pdf-as-pdfbox-4.0.5-SNAPSHOT.jar create mode 100644 repo/at/gv/egiz/pdfas/pdf-as-pdfbox/pdf-as-pdfbox-4.0.5-SNAPSHOT.pom create mode 100644 repo/at/gv/egiz/pdfas/sigs-pades/4.0.5-SNAPSHOT/sigs-pades-4.0.5-SNAPSHOT.jar create mode 100644 repo/at/gv/egiz/pdfas/sigs-pades/4.0.5-SNAPSHOT/sigs-pades-4.0.5-SNAPSHOT.pom delete mode 100644 repo/eu/europa/ec/joinup/egovlabs/pdf-as/pdf-as-lib/3.5.2/pdf-as-lib-3.5.2.zip create mode 100644 repo/iaik/iaik_cms/2.15/iaik_cms-2.15.jar create mode 100644 repo/iaik/iaik_cms/2.15/iaik_cms-2.15.pom create mode 100644 repo/iaik/iaik_eccelerate/2.15/iaik_eccelerate-2.15.jar create mode 100644 repo/iaik/iaik_eccelerate/2.15/iaik_eccelerate-2.15.pom create mode 100644 repo/iaik/iaik_eccelerate_cms/2.15/iaik_eccelerate_cms-2.15.jar create mode 100644 repo/iaik/iaik_eccelerate_cms/2.15/iaik_eccelerate_cms-2.15.pom create mode 100644 repo/iaik/iaik_jce_full_signed/5.2/iaik_jce_full_signed-5.2.jar create mode 100644 repo/iaik/iaik_jce_full_signed/5.2/iaik_jce_full_signed-5.2.pom diff --git a/pdf-over-gui/.project b/pdf-over-gui/.project index fed987a6..c7fd44f6 100644 --- a/pdf-over-gui/.project +++ b/pdf-over-gui/.project @@ -3,6 +3,7 @@ pdf-over-gui + pdf-as-lib diff --git a/pdf-over-signer/pdf-over-sigpdfas/.classpath b/pdf-over-signer/pdf-over-sigpdfas/.classpath deleted file mode 100644 index 658fc2e3..00000000 --- a/pdf-over-signer/pdf-over-sigpdfas/.classpath +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pdf-over-signer/pdf-over-sigpdfas/.project b/pdf-over-signer/pdf-over-sigpdfas/.project deleted file mode 100644 index a8f28341..00000000 --- a/pdf-over-signer/pdf-over-sigpdfas/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - pdf-over-sigpdfas - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.core.resources.prefs b/pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 29abf999..00000000 --- a/pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,6 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/main/resources=UTF-8 -encoding//src/test/java=UTF-8 -encoding//src/test/resources=UTF-8 -encoding/=UTF-8 diff --git a/pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.jdt.core.prefs b/pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 3e73d18e..00000000 --- a/pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,98 +0,0 @@ -#Fri Aug 03 18:09:51 CEST 2012 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.doc.comment.support=enabled -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected -org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag -org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning -org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=warning -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.6 -org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled -org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL,LOW -org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX,NOTE diff --git a/pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.jdt.ui.prefs b/pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 05288cb4..00000000 --- a/pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.ui.javadoc=true -org.eclipse.jdt.ui.text.custom_code_templates= diff --git a/pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.m2e.core.prefs b/pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index 62e91186..00000000 --- a/pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -#Thu Aug 02 12:33:52 CEST 2012 -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.mylyn.tasks.ui.prefs b/pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.mylyn.tasks.ui.prefs deleted file mode 100644 index c6aa7359..00000000 --- a/pdf-over-signer/pdf-over-sigpdfas/.settings/org.eclipse.mylyn.tasks.ui.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Fri Aug 03 18:56:31 CEST 2012 -eclipse.preferences.version=1 -project.repository.kind=jira -project.repository.url=http\://jira.egovlabs.gv.at diff --git a/pdf-over-signer/pdf-over-sigpdfas/pom.xml b/pdf-over-signer/pdf-over-sigpdfas/pom.xml deleted file mode 100644 index 52f4c404..00000000 --- a/pdf-over-signer/pdf-over-sigpdfas/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - 4.0.0 - - pdf-over-signer - at.a-sit - 4.0.5-SNAPSHOT - .. - - pdf-over-sigpdfas - PDF-Over PDF-AS Signer - - ${project.basedir}/../.. - - - - at.a-sit - pdf-over-signator - ${project.parent.version} - - - eu.europa.ec.joinup.egovlabs.pdf-as - pdf-as-lib - 3.5.2 - - - diff --git a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/ByteArrayPDFASDataSource.java b/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/ByteArrayPDFASDataSource.java deleted file mode 100644 index b2f95f50..00000000 --- a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/ByteArrayPDFASDataSource.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.signer.pdfas; - -//Imports -import java.io.ByteArrayInputStream; -import java.io.InputStream; - -import at.gv.egiz.pdfas.api.io.DataSource; - -/** - * PDF - AS Specific Data Source with byte array representation - */ -public class ByteArrayPDFASDataSource implements DataSource { - - /** - * Internal data byte array - */ - private byte[] data; - - /** - * Default constructor - * @param data The byte[] to be used - */ - public ByteArrayPDFASDataSource(byte[] data) { - this.data = data; - } - - @Override - public InputStream createInputStream() { - return new ByteArrayInputStream(this.data); - } - - @Override - public int getLength() { - return this.data.length; - } - - @Override - public byte[] getAsByteArray() { - return this.data; - } - - @Override - public String getMimeType() { - return "application/pdf"; - } - - @Override - public String getCharacterEncoding() { - return "UTF8"; - } - -} \ No newline at end of file diff --git a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java b/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java deleted file mode 100644 index 473bbf42..00000000 --- a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.signer.pdfas; - -//Imports -import java.io.File; - -import at.asit.pdfover.signator.SignatureException; -import at.gv.egiz.pdfas.api.PdfAs; -import at.gv.egiz.pdfas.api.exceptions.PdfAsException; -import at.gv.egiz.pdfas.api.internal.PdfAsInternal; - -/** - * Encapsulates PDF AS API Object to need just one initialization - */ -public class PDFASHelper { - - /** - * PDF AS Object - */ - private static PdfAs pdfAs = null; - - /** - * Internal Pdf AS Object - */ - private static PdfAsInternal pdfAsInternal = null; - - /** - * Creates PDF AS Object - * @return - * @throws PdfAsException - */ - private static PdfAs createPdfAs() throws PdfAsException { - File directory = new File ("."); - System.setProperty("log4j.configuration", directory.getAbsolutePath() + - "/log4j.properties"); - System.setProperty("pdf-as.work-dir", getWorkDir()); - return new at.gv.egiz.pdfas.impl.api.PdfAsObject(); - } - - /** - * Provides the working directory - * @return the working directory - */ - public static String getWorkDir() { - return System.getProperty("user.home") + "/.pdf-over"; - } - - /** - * Creates a PDF-AS Internal object - * @return the PDF-AS Internal object - * @throws PdfAsException - */ - private static PdfAsInternal createPdfAsInternal() throws PdfAsException { - return new at.gv.egiz.pdfas.impl.api.internal.PdfAsInternalObject(); - } - - /** - * Gets PDF-AS Object - * @return the PDF-AS Object - * @throws SignatureException - */ - public static synchronized PdfAs getPdfAs() throws SignatureException { - if (pdfAs == null) { - try { - pdfAs = createPdfAs(); - } catch(PdfAsException e) { - throw new SignatureException(e); - } - } - return pdfAs; - } - - /** - * Gets PDF-AS Internal object - * @return the PDF-AS Internal object - * @throws SignatureException - */ - public static synchronized PdfAsInternal getPdfAsInternal() throws SignatureException { - if(pdfAsInternal == null) { - try { - pdfAsInternal = createPdfAsInternal(); - } catch(PdfAsException e) { - throw new SignatureException(e); - } - } - return pdfAsInternal; - } -} diff --git a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java b/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java deleted file mode 100644 index f274068a..00000000 --- a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.signer.pdfas; - -// Imports -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.asit.pdfover.signator.ByteArrayDocumentSource; -import at.asit.pdfover.signator.SLRequest; -import at.asit.pdfover.signer.pdfas.exceptions.PDFASSLRequestException; - -/** - * PDF - AS Security Layer Request implementation - */ -public class PDFASSLRequest extends SLRequest { - - /** - * SLF4J Logger instance - **/ - private static final Logger log = LoggerFactory.getLogger(PDFASSLRequest.class); - - /** - * Default constructor - * @param slRequest - * @param signData - * @throws PDFASSLRequestException - */ - public PDFASSLRequest(String slRequest, byte[] signData) throws PDFASSLRequestException { - if(!slRequest.contains(PDFASSigner.LOC_REF)) { - log.error("PDF-AS SL request doesn't contain " + PDFASSigner.LOC_REF); - log.debug("Request: " + slRequest); - throw new PDFASSLRequestException("PDF-AS SL request doesn't contain " + PDFASSigner.LOC_REF); - } - - // Modifing SL Request ... - setRequest(slRequest.replace(PDFASSigner.LOC_REF, SLRequest.DATAOBJECT_STRING)); - - setSignatureData(new ByteArrayDocumentSource(signData)); - } -} diff --git a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigner.java b/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigner.java deleted file mode 100644 index 6fa1c094..00000000 --- a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigner.java +++ /dev/null @@ -1,190 +0,0 @@ -package at.asit.pdfover.signer.pdfas; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.asit.pdfover.signator.BKUs; -import at.asit.pdfover.signator.ByteArrayDocumentSource; -import at.asit.pdfover.signator.SLResponse; -import at.asit.pdfover.signator.SignResult; -import at.asit.pdfover.signator.SignResultImpl; -import at.asit.pdfover.signator.SignatureException; -import at.asit.pdfover.signator.SignatureParameter; -import at.asit.pdfover.signator.SignaturePosition; -import at.asit.pdfover.signator.Signer; -import at.asit.pdfover.signator.SigningState; -import at.asit.pdfover.signer.pdfas.exceptions.PDFASSLRequestException; -import at.gv.egiz.pdfas.api.PdfAs; -import at.gv.egiz.pdfas.api.commons.Constants; -import at.gv.egiz.pdfas.api.exceptions.PdfAsException; -import at.gv.egiz.pdfas.api.internal.LocalBKUParams; -import at.gv.egiz.pdfas.api.internal.PdfAsInternal; -import at.gv.egiz.pdfas.api.sign.SignParameters; -import at.gv.egiz.pdfas.api.sign.SignatureDetailInformation; -import at.gv.egiz.pdfas.io.ByteArrayDataSink; - -/** - * PDF AS Signer Implementation - */ -public class PDFASSigner implements Signer { - - /** - * SLF4J Logger instance - **/ - static final Logger log = LoggerFactory.getLogger(PDFASSigner.class); - - /** - * The template URL - */ - protected static final String URL_TEMPLATE = "http://pdfover.4.gv.at/template"; - - /** - * Location reference string - */ - protected static final String LOC_REF = "" + URL_TEMPLATE - + ""; - - @Override - public SigningState prepare(SignatureParameter parameter) - throws SignatureException { - try { - PdfAsSignatureParameter sign_para = null; - - if (PdfAsSignatureParameter.class.isInstance(parameter)) { - sign_para = PdfAsSignatureParameter.class.cast(parameter); - } - - if (sign_para == null) { - throw new SignatureException("Incorrect SignatureParameter!"); - } - - PdfAs pdfas = PDFASHelper.getPdfAs(); - - PDFASSigningState state = new PDFASSigningState(); - - SignParameters params = new SignParameters(); - params.setSignaturePositioning(sign_para.getPDFASPositioning()); - - if (parameter.getSignatureDevice() == BKUs.LOCAL) { - params.setSignatureDevice(Constants.SIGNATURE_DEVICE_BKU); - } else if (parameter.getSignatureDevice() == BKUs.MOBILE) { - params.setSignatureDevice(Constants.SIGNATURE_DEVICE_MOBILE); - // params.setSignatureDevice(Constants.SIGNATURE_DEVICE_MOBILETEST); - } - params.setSignatureType(Constants.SIGNATURE_TYPE_BINARY); - - params.setSignatureProfileId(sign_para.getSignatureProfileID()); - - params.setOutput(new ByteArrayDataSink()); - if (parameter.getEmblem() != null) { - params.setProfileOverrideValue("SIG_LABEL", parameter - .getEmblem().getFileName()); - } - - if(parameter.getProperty("SIG_NOTE") != null) { - params.setProfileOverrideValue("SIG_NOTE", parameter.getProperty("SIG_NOTE")); - } - - // Prepare Output sink - state.setOutput(new ByteArrayDataSink()); - params.setOutput(state.getOutput()); - - params.setDocument(sign_para.getPDFASDataSource()); - - state.setSignParameters(params); - - PdfAsInternal pdfasInternal = PDFASHelper.getPdfAsInternal(); - - // Prepares the document - SignatureDetailInformation sdi = pdfas.prepareSign(params); - - state.setSignatureDetailInformation(sdi); - - // Retrieve the SL Request - String slRequest = pdfasInternal.prepareLocalSignRequest(params, - false, URL_TEMPLATE, sdi); - - at.gv.egiz.pdfas.api.io.DataSource sig_data = sdi - .getSignatureData(); - - PDFASSLRequest request = new PDFASSLRequest(slRequest, - sig_data.getAsByteArray()); - - state.setSignatureRequest(request); - - return state; - } catch (PDFASSLRequestException e) { - throw new SignatureException(e); - } catch (PdfAsException e) { - throw new SignatureException(e); - } catch (Throwable t) { - throw new SignatureException(t); - } - } - - @Override - public SignResult sign(SigningState state) throws SignatureException { - try { - PDFASSigningState sstate = null; - - if (PDFASSigningState.class.isInstance(state)) { - sstate = PDFASSigningState.class.cast(state); - } - - if (sstate == null) { - throw new SignatureException("Incorrect SigningState!"); - } - - // Retrieve objects - PdfAs pdfas = PDFASHelper.getPdfAs(); - - PdfAsInternal pdfasInternal = PDFASHelper.getPdfAsInternal(); - - SignParameters params = sstate.getSignParameters(); - - SignatureDetailInformation sdi = sstate - .getSignatureDetailInformation(); - - SLResponse slResponse = sstate.getSignatureResponse(); - - LocalBKUParams bkuParams = new LocalBKUParams( - slResponse.getServer(), slResponse.getUserAgent(), - slResponse.getSignaturLayout()); - - // Perform signature - at.gv.egiz.pdfas.api.sign.SignResult signResult = pdfasInternal - .finishLocalSign(pdfas, params, sdi, bkuParams, false, - slResponse.getSLRespone()); - - // Preparing Result Response - SignResultImpl result = new SignResultImpl(); - - // Set Signer Certificate - result.setSignerCertificate(signResult.getSignerCertificate()); - at.gv.egiz.pdfas.api.sign.pos.SignaturePosition pdfasPos = signResult - .getSignaturePosition(); - - // Set Signature position - SignaturePosition pos = new SignaturePosition(pdfasPos.getX(), - pdfasPos.getY(), pdfasPos.getPage()); - /* - * pos.SetAuto(sstate.getPDFAsSignatureParameter() - * .getSignaturePosition().useAutoPositioning()); - */ - result.setSignaturePosition(pos); - - // Set signed Document - result.setSignedDocument(new ByteArrayDocumentSource( - ((ByteArrayDataSink) sstate.getOutput()).getData())); - - return result; - } catch (PdfAsException e) { - throw new SignatureException(e); - } - } - - @Override - public SignatureParameter newParameter() { - return new PdfAsSignatureParameter(); - } -} diff --git a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSignerFactory.java b/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSignerFactory.java deleted file mode 100644 index 68a29341..00000000 --- a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSignerFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.signer.pdfas; - -//Imports -import at.asit.pdfover.signator.Signer; -import at.asit.pdfover.signator.SignerFactory; - -/** - * Factory class for PDF-AS Signer - */ -public class PDFASSignerFactory extends SignerFactory { - - @Override - public Signer createSigner() { - return new PDFASSigner(); - } -} diff --git a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigningState.java b/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigningState.java deleted file mode 100644 index 4849d26e..00000000 --- a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigningState.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.signer.pdfas; - -//Imports -import at.asit.pdfover.signator.SLRequest; -import at.asit.pdfover.signator.SLResponse; -import at.asit.pdfover.signator.SigningState; -import at.gv.egiz.pdfas.api.io.DataSink; -import at.gv.egiz.pdfas.api.sign.SignatureDetailInformation; - -/** - * Signing State for PDFAS Wrapper - */ -public class PDFASSigningState implements SigningState { - - /** - * The Signature Layer request - */ - protected SLRequest slrequest; - - /** - * The PDF AS DataSink - */ - protected DataSink output; - - /** - * Gets the DataSink - * @return the datasink - */ - public DataSink getOutput() { - return this.output; - } - - /** - * Sets the datasing - * @param output the pdf as datasink - */ - public void setOutput(DataSink output) { - this.output = output; - } - - /** - * The Signature Layer response - */ - protected SLResponse slresponse; - - @Override - public SLRequest getSignatureRequest() { - return this.slrequest; - } - - @Override - public void setSignatureResponse(SLResponse response) { - this.slresponse = response; - } - - /** - * Sets the SL Request - * @param request The SL Request - */ - public void setSignatureRequest(SLRequest request) { - this.slrequest = request; - } - - /** - * Gets the SL Response - * @return The SL Repsonse object - */ - public SLResponse getSignatureResponse() { - return this.slresponse; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.signator.SigningState#hasSignatureResponse() - */ - @Override - public boolean hasSignatureResponse() { - return this.getSignatureResponse() != null; - } - - // ---------------------------------------- - // PDF AS Specific stuff - // ---------------------------------------- - - /** - * signature detail information - */ - protected SignatureDetailInformation signatureDetailInformation; - - /** - * PDF - AS sign parameters - */ - protected at.gv.egiz.pdfas.api.sign.SignParameters signParameters; - - /** - * Signature parameters - */ - protected PdfAsSignatureParameter pdfAsSignatureParameter; - - /** - * Gets PDF - AS Signature Parameters - * @return PdfAsSignatureParameter - */ - public PdfAsSignatureParameter getPdfAsSignatureParameter() { - return this.pdfAsSignatureParameter; - } - - /** - * Sets PDF - AS Signature Parameters - * @param pdfAsSignatureParameter - */ - public void setPdfAsSignatureParameter( - PdfAsSignatureParameter pdfAsSignatureParameter) { - this.pdfAsSignatureParameter = pdfAsSignatureParameter; - } - - /** - * Get Sign Parameters - * @return SignParameters - */ - public at.gv.egiz.pdfas.api.sign.SignParameters getSignParameters() { - return this.signParameters; - } - - /** - * Sets sign Parameter - * @param signParameters - */ - public void setSignParameters( - at.gv.egiz.pdfas.api.sign.SignParameters signParameters) { - this.signParameters = signParameters; - } - - /** - * Gets the signature detail information - * @return SignatureDetailInformation - */ - public SignatureDetailInformation getSignatureDetailInformation() { - return this.signatureDetailInformation; - } - - /** - * Sets the SignatureDetailInformation - * @param signatureDetailInformation - */ - public void setSignatureDetailInformation( - SignatureDetailInformation signatureDetailInformation) { - this.signatureDetailInformation = signatureDetailInformation; - } -} diff --git a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java b/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java deleted file mode 100644 index 3b4c6244..00000000 --- a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java +++ /dev/null @@ -1,603 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.signer.pdfas; - -//Imports -import java.awt.Image; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Locale; - -import javax.imageio.ImageIO; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.asit.pdfover.signator.SignatureDimension; -import at.asit.pdfover.signator.SignatureParameter; -import at.asit.pdfover.signator.SignaturePosition; -import at.gv.egiz.pdfas.api.io.DataSource; -import at.gv.egiz.pdfas.api.sign.pos.SignaturePositioning; -import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException; - -/** - * Implementation of SignatureParameter specific for PDF - AS Library - */ -public class PdfAsSignatureParameter extends SignatureParameter { - - /** - * SLF4J Logger instance - **/ - static final Logger log = LoggerFactory - .getLogger(PdfAsSignatureParameter.class); - - /** The profile ID for the german signature block */ - private static final String PROFILE_ID_DE = "SIGNATURBLOCK_SMALL_DE"; - /** The profile ID for the german signature block if a signature note is set */ - private static final String PROFILE_ID_DE_NOTE = "SIGNATURBLOCK_SMALL_DE_NOTE"; - /** The profile ID for the english signature block */ - private static final String PROFILE_ID_EN = "SIGNATURBLOCK_SMALL_EN"; - /** The profile ID for the english signature block if a signature note is set */ - private static final String PROFILE_ID_EN_NOTE = "SIGNATURBLOCK_SMALL_EN_NOTE"; - - private HashMap genericProperties = new HashMap(); - -// private static final int PLACEHOLDER_SCALE = 4; -// -// private int height = -1; -// -// private float perUnitHeight = 0; - - /** - * Gets the PDFAS Positioning - * - * @return SignaturePositioning - * @throws PDFDocumentException - */ - public SignaturePositioning getPDFASPositioning() - throws PDFDocumentException { - SignaturePosition position = this.getSignaturePosition(); - position.useAutoPositioning(); - - SignaturePositioning positioning = null; - if (!position.useAutoPositioning()) { - if (position.getPage() < 1) { - positioning = new SignaturePositioning(String.format( - (Locale) null, - "p:new;x:%f;y:%f;w:276", position.getX(), - position.getY())); - } else { - positioning = new SignaturePositioning(String.format( - (Locale) null, - "p:%d;x:%f;y:%f;w:276", position.getPage(), position.getX(), - position.getY())); - } - } else { - positioning = new SignaturePositioning("p:auto;x:auto;y:auto;w:276"); - } - - return positioning; - } - - /** - * Gets PDF - AS specific data source - * - * @return ByteArrayPDFASDataSource - */ - public DataSource getPDFASDataSource() { - return new ByteArrayPDFASDataSource(this.getInputDocument() - .getByteArray()); - } - - @Override - public void setProperty(String key, String value) { - this.genericProperties.put(key, value); -// this.height = -1; - } - - @Override - public String getProperty(String key) { - return this.genericProperties.get(key); - } - - /* (non-Javadoc) - * @see at.asit.pdfover.signator.SignatureParameter#setSignatureLanguage(java.lang.String) - */ - @Override - public void setSignatureLanguage(String signatureLanguage) { - super.setSignatureLanguage(signatureLanguage); -// this.height = -1; - } - - @Override - public SignatureDimension getPlaceholderDimension() { - // return new SignatureDimension(487, 206); - return new SignatureDimension(276, 126); - //return new SignatureDimension(getWidth(), getHeight()); - } - -// private static int getWidth() { -// return 276; -// } -// -// private int getHeight() { -// if (this.height < 0) -// { -// BufferedImage timage = new BufferedImage(1, 1, -// BufferedImage.TYPE_INT_RGB); -// try { -// this.height = (int) (getTableHeight(getSignatureTable(), null, getWidth() * PLACEHOLDER_SCALE, timage.getGraphics()) / PLACEHOLDER_SCALE); -// } catch (SignatureException e) { -// log.error("getTableHeight failed ...", e); -// } catch (SignatureTypesException e) { -// log.error("getTableHeight failed ...", e); -// } -// timage.flush(); -// } -// if (this.height < 0) -// return 95; -// -// return this.height; -// } - - /** - * Get the Signature Profile ID for this set of parameters - * @return the Signature Profile ID - */ - public String getSignatureProfileID() { - String lang = getSignatureLanguage(); - boolean useNote = (getProperty("SIG_NOTE") != null); - - if (lang != null && lang.equals("en")) - return useNote ? PROFILE_ID_EN_NOTE : PROFILE_ID_EN; - - return useNote ? PROFILE_ID_DE_NOTE : PROFILE_ID_DE; - } - - /* - * (non-Javadoc) - * - * @see at.asit.pdfover.signator.SignatureParameter#getPlaceholder() - */ - @Override - public Image getPlaceholder() { - - try { - Image logo = null; - try { - if (this.getEmblem() != null - && this.getEmblem().getFileName() != null - && new File(this.getEmblem().getFileName()) - .exists()) { - logo = ImageIO.read(new File(this.getEmblem() - .getFileName())); - - } - } - catch(Exception e) { - log.error("Failed to get emblem ...", e); - } - - Image img = null; - String lang = getSignatureLanguage(); - if (lang != null && lang.equals("en")) { - img = ImageIO.read(PdfAsSignatureParameter.class - .getResourceAsStream("/img/sign_prev_en.png")); - - if(logo != null) { - logo = logo.getScaledInstance(141, 140, - Image.SCALE_SMOOTH); - img.getGraphics().drawImage(logo, 6, 115, null); - } - - } else { - img = ImageIO.read(PdfAsSignatureParameter.class - .getResourceAsStream("/img/sign_prev_de.png")); - - if(logo != null) { - logo = logo.getScaledInstance(141, 140, - Image.SCALE_SMOOTH); - img.getGraphics().drawImage(logo, 6, 115, null); - } - } - return img; - } catch (IOException e) { - return new BufferedImage(getPlaceholderDimension().getWidth(), - getPlaceholderDimension().getHeight(), - BufferedImage.TYPE_INT_RGB); - } - -// Try to render signature block - disabled for now (just use images) -// -// try { -// PDFASHelper.getPdfAs(); -// -// -// float width = getPlaceholderDimension().getWidth() * PLACEHOLDER_SCALE; -// float height = getPlaceholderDimension().getHeight() * PLACEHOLDER_SCALE; -// -// Table table = this.getSignatureTable(); -// -// //log.info(table.toString()); -// -// BufferedImage timage = new BufferedImage(1, 1, -// BufferedImage.TYPE_INT_RGB); -// float[] heights = this.getTableHeights(table, table.getStyle(), -// height, (int)width, timage.getGraphics()); -// timage.flush(); -// float mheight = 0; -// -// for(int i = 0; i < heights.length; i++) { -// mheight += heights[i]; -// } -// -// this.height = (int) (mheight / PLACEHOLDER_SCALE); -// -// log.info("Width: " + width + " Height: " + height + " HShould: " + mheight); -// BufferedImage image = new BufferedImage((int) width, (int) mheight, -// BufferedImage.TYPE_INT_RGB); -// Graphics g = image.getGraphics(); -// -// g.setColor(table.getStyle().getBgColor()); -// g.fillRect(0, 0, (int) width, (int) mheight); -// -// g.setColor(Color.black); -// g.drawRect(0, 0, (int) width, (int) mheight); -// -// this.drawTable(0, 0, (int) width, (int) mheight, table, -// table.getStyle(), g, heights); -// -// g.dispose(); -// -// //save(image, "png"); -// -// return image; -// } catch (Exception ex) { -// try { -// return ImageIO.read(PdfAsSignatureParameter.class -// .getResourceAsStream("/img/fallbackPlaceholder.png")); -// } catch (IOException e) { -// return new BufferedImage(getPlaceholderDimension().getWidth(), -// getPlaceholderDimension().getHeight(), -// BufferedImage.TYPE_INT_RGB); -// } -// } - } - -// private Table getSignatureTable() throws SignatureException, SignatureTypesException { -// SignatureObject sign_obj = at.knowcenter.wag.egov.egiz.PdfAS -// .createSignatureObjectFromType(getSignatureProfileID()); -// -// sign_obj.fillValues(' ', true, false); -// sign_obj.setKZ(BinarySignator_1_1_0.MY_ID); -// return sign_obj.getAbstractTable(); -// } -// -// /** -// * used for debugging .. -// * -// * @param image -// * @param ext -// */ -// @SuppressWarnings("unused") -// @Deprecated -// private static void save(BufferedImage image, String ext) { -// String fileName = "savingAnImage"; -// File file = new File(fileName + "." + ext); -// try { -// ImageIO.write(image, ext, file); // ignore returned boolean -// log.debug("Saved as: " + file.getAbsolutePath()); -// } catch (IOException e) { -// System.out.println("Write error for " + file.getPath() + ": " -// + e.getMessage()); -// } -// } -// -// @SuppressWarnings("rawtypes") -// private int drawTable(int xoff, int yoff, int width, int height, -// Table table, Style parentstyle, Graphics g, float[] heights) { -// Style style = parentstyle; -// if (table.getStyle() != null) { -// style = table.getStyle(); -// } -// -// log.debug(String.format((Locale) null, "Table@ %dx%d", xoff, yoff)); -// -// Font oldFont = g.getFont(); -// Font font = PdfAsSignatureParameter.getFont(style); -// g.setFont(font); -// // draw background -// // graphic.setColor(style.getBgColor()); -// // graphic.fillRect(xoff, yoff, width, height); -// -// g.setColor(Color.black); -// -// // draw border -// if (style.getBorder() > 0) { -// g.setColor(Color.black); -// g.drawRect(xoff, yoff, width, height); -// } -// float[] colWidths = table.getColsRelativeWith(); -// float sum = 0; -// -// for (int i = 0; i < colWidths.length; i++) { -// sum += colWidths[i]; -// } -// -// float perUnit = width / sum; -// -// int padding = (int) (style.getPadding() * this.perUnitHeight * PLACEHOLDER_SCALE); -// -// ArrayList rows = table.getRows(); -// float roffset = 0; -// for (int rowidx = 0; rowidx < rows.size(); rowidx++) { -// ArrayList cols = (ArrayList) rows.get(rowidx); -// int rsize = (int) heights[rowidx]; -// for (int j = 0; j < cols.size(); j++) { -// Entry entry = (Entry) cols.get(j); -// float offset = 0; -// for (int k = 0; k < j; k++) { -// offset += colWidths[k] * perUnit; -// } -// if (entry.getType() == 0 || entry.getType() == 1) { -// // Text -// g.drawRect((int) (xoff + offset), -// (int) (yoff + roffset), -// (int) (colWidths[j] * perUnit), rsize); -// -// String[] lines = getLines(entry.getValue().toString(), (int)(colWidths[j] * perUnit), g.getFontMetrics(), (int) style.getPadding() * PLACEHOLDER_SCALE); -// -// for(int i = 0; i < lines.length; i++) { -// g.drawString(lines[i].toString(), (int) (xoff -// + offset + padding / PLACEHOLDER_SCALE), (int) (yoff + padding -// + roffset + (i + 1) * g.getFontMetrics().getHeight() * this.perUnitHeight)); -// } -// //g.drawString(entry.getValue().toString(), (int) (xoff -// // + offset + padding / PLACEHOLDER_SCALE), (int) (yoff + padding -// // + roffset + font.getSize() * this.perUnitHeight)); -// } else if (entry.getType() == 2) { -// // Image ... -// BufferedImage image; -// try { -// if (this.getEmblem() != null -// && this.getEmblem().getFileName() != null -// && new File(this.getEmblem().getFileName()) -// .exists()) { -// image = ImageIO.read(new File(this.getEmblem() -// .getFileName())); -// } else { -// image = ImageIO.read(new File(PDFASHelper -// .getWorkDir() -// + File.separator -// + entry.getValue().toString())); -// } -// int imgWidth = 30 * PLACEHOLDER_SCALE; -// int imgHeight = 30 * PLACEHOLDER_SCALE; -// Image img = image.getScaledInstance(imgWidth, imgHeight, -// Image.SCALE_SMOOTH); -// -// g.drawImage( -// img, -// (int) (xoff + offset + padding + (((colWidths[j] * perUnit) - imgWidth - 2* padding)) / 2), -// (int) (yoff + roffset + padding + ((rsize - imgHeight - 2* padding) / 2)), -// null); -// } catch (IOException e) { -// log.warn("Failed to paint emblem to placeholder image"); -// } -// } else { -// // Table -// -// int colWidth = (int) (colWidths[j] * perUnit); -// -// float[] cheights = this.getTableHeights( -// (Table) entry.getValue(), style, rsize, colWidth, g); -// -// this.drawTable( -// (int) (xoff + offset), -// (int) (yoff + roffset), -// (int) (colWidths[j] * perUnit), -// // (int)this.getTableHeight((Table) -// // entry.getValue(), style), -// rsize, (Table) entry.getValue(), style, g, -// cheights); -// /* -// * if (rsize < tsize) { rsize = tsize; } -// */ -// } -// } -// roffset += rsize; -// } -// -// g.setFont(oldFont); -// -// return (int) roffset; -// } -// -// private static Font getFont(Style style) { -// String def = "COURIER-NORMAL-8"; -// String fontString = style.getFont(); -// String[] font_arr = fontString.split(","); -// if (font_arr.length != 3) { -// return Font.decode(def); -// } -// Font font = Font.decode(String.format("%s-%s-%s", font_arr[0], font_arr[2], -// font_arr[1])); -// return font.deriveFont((float) font.getSize() * PLACEHOLDER_SCALE); -// } -// -// /** -// * extracts the value font -// * -// * @param style -// * the table style -// * @return the value font -// */ -// @SuppressWarnings("unused") -// private static Font getValueFont(Style style) { -// String def = "COURIER-NORMAL-8"; -// String fontString = style.getValueFont(); -// String[] font_arr = fontString.split(","); -// if (font_arr.length != 3) { -// return Font.decode(def); -// } -// Font font = Font.decode(String.format("%s-%s-%s", font_arr[0], font_arr[2], -// font_arr[1])); -// return font.deriveFont((float) font.getSize() * PLACEHOLDER_SCALE); -// } -// -// private static String[] getLines(String text, int width, FontMetrics fmetric, int padding) { -// String currentline = text; -// int averageCharWi = fmetric.charWidth('c'); -// -// int max_line_chars = (width - padding) / (averageCharWi); -// ArrayList lines = new ArrayList(); -// -// while(currentline.length() > max_line_chars) { -// int cutidx = currentline.substring(0, max_line_chars).lastIndexOf(' '); -// if(cutidx < 1) { -// cutidx = max_line_chars - 1; -// } else { -// cutidx++; -// } -// String tmpLine = currentline.substring(0, cutidx); -// lines.add(tmpLine); -// currentline = currentline.substring(cutidx); -// } -// lines.add(currentline); -// -// -// String[] arrline = new String[lines.size()]; -// for(int i = 0; i < lines.size(); i++) { -// arrline[i] = lines.get(i); -// } -// -// //log.debug(text + " needs " + lines.size() + " lines"); -// -// return arrline; -// } -// -// @SuppressWarnings("rawtypes") -// private float[] getTableHeights(Table table, Style parentstyle, float height, int width, Graphics g) { -// ArrayList rows = table.getRows(); -// float[] sizes = new float[rows.size()]; -// Style style = parentstyle; -// if (table.getStyle() != null) { -// style = table.getStyle(); -// } -// Font font = PdfAsSignatureParameter.getFont(style); -// g.setFont(font); -// -// float total_height = this.getTableHeight(table, parentstyle, width, g); -// -// float perUnit = height / total_height; -// -// this.perUnitHeight = perUnit; -// -// float[] colWidths = table.getColsRelativeWith(); -// float sum = 0; -// -// for (int i = 0; i < colWidths.length; i++) { -// sum += colWidths[i]; -// } -// -// float perUnitWidth = width / sum; -// -// for (int i = 0; i < rows.size(); i++) { -// Object robj = rows.get(i); -// ArrayList cols = (ArrayList) robj; -// float tsize = 0; -// float rsize = 0; -// for (int j = 0; j < cols.size(); j++) { -// Entry entry = (Entry) cols.get(j); -// if (entry.getType() == 0 || entry.getType() == 1) { -// int colWidth = (int) (colWidths[j] * perUnitWidth); -// -// float trsize = getLines(entry.getValue().toString(), colWidth, g.getFontMetrics(), (int) style.getPadding() * PLACEHOLDER_SCALE).length * g.getFontMetrics().getHeight() + (style.getPadding() * PLACEHOLDER_SCALE * 2); -// -// if (rsize < trsize) { -// rsize = trsize; -// } -// } else if (entry.getType() == 3) { -// -// int colWidth = (int) (colWidths[j] * perUnitWidth); -// -// tsize = this -// .getTableHeight((Table) entry.getValue(), style, colWidth, g); -// if (rsize < tsize) { -// rsize = tsize; -// } -// } -// } -// sizes[i] = perUnit * rsize; -// } -// -// return sizes; -// } -// -// @SuppressWarnings("rawtypes") -// private float getTableHeight(Table table, Style parentstyle, int width, Graphics g) { -// ArrayList rows = table.getRows(); -// Style style = parentstyle; -// if (table.getStyle() != null) { -// style = table.getStyle(); -// } -// float size = 0; -// -// float[] colWidths = table.getColsRelativeWith(); -// float sum = 0; -// -// for (int i = 0; i < colWidths.length; i++) { -// sum += colWidths[i]; -// } -// -// float perUnitWidth = width / sum; -// -// for (int i = 0; i < rows.size(); i++) { -// Object robj = rows.get(i); -// ArrayList cols = (ArrayList) robj; -// float tsize = 0; -// float rsize = 0; -// for (int j = 0; j < cols.size(); j++) { -// Entry entry = (Entry) cols.get(j); -// if (entry.getType() == 0 || entry.getType() == 1) { -// int colWidth = (int) (colWidths[j] * perUnitWidth); -// -// float trsize = getLines(entry.getValue().toString(), colWidth, g.getFontMetrics(), (int) style.getPadding() * PLACEHOLDER_SCALE).length * g.getFontMetrics().getHeight() + (style.getPadding() * PLACEHOLDER_SCALE * 2); -// -// if (rsize < trsize) { -// rsize = trsize; -// } -// -// /*if (rsize < ((style.getPadding() * PLACEHOLDER_SCALE * 2) + fontSize)) { -// rsize = ((style.getPadding() * PLACEHOLDER_SCALE * 2) + fontSize); -// }*/ -// } else if (entry.getType() == 3) { -// int colWidth = (int) (colWidths[j] * perUnitWidth); -// tsize = this -// .getTableHeight((Table) entry.getValue(), style, colWidth, g); -// if (rsize < tsize) { -// rsize = tsize; -// } -// } -// } -// size += rsize; -// } -// -// return size; -// } -} diff --git a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/exceptions/PDFASSLRequestException.java b/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/exceptions/PDFASSLRequestException.java deleted file mode 100644 index ceb25779..00000000 --- a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/exceptions/PDFASSLRequestException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.signer.pdfas.exceptions; - -/** - * - */ -public class PDFASSLRequestException extends Exception { - /** - * - */ - private static final long serialVersionUID = -7515747014505057787L; - - /** - * Constructor - * @param msg - */ - public PDFASSLRequestException(String msg) { - super(msg); - } -} diff --git a/pdf-over-signer/pdf-over-sigpdfas/src/main/resources/img/fallbackPlaceholder.png b/pdf-over-signer/pdf-over-sigpdfas/src/main/resources/img/fallbackPlaceholder.png deleted file mode 100644 index 4baafc19..00000000 Binary files a/pdf-over-signer/pdf-over-sigpdfas/src/main/resources/img/fallbackPlaceholder.png and /dev/null differ diff --git a/pdf-over-signer/pdf-over-sigpdfas/src/main/resources/img/sign_prev_de.png b/pdf-over-signer/pdf-over-sigpdfas/src/main/resources/img/sign_prev_de.png deleted file mode 100644 index c8ca09f4..00000000 Binary files a/pdf-over-signer/pdf-over-sigpdfas/src/main/resources/img/sign_prev_de.png and /dev/null differ diff --git a/pdf-over-signer/pdf-over-sigpdfas/src/main/resources/img/sign_prev_en.png b/pdf-over-signer/pdf-over-sigpdfas/src/main/resources/img/sign_prev_en.png deleted file mode 100644 index aa450fcc..00000000 Binary files a/pdf-over-signer/pdf-over-sigpdfas/src/main/resources/img/sign_prev_en.png and /dev/null differ diff --git a/pdf-over-signer/pdf-over-sigpdfas3/.classpath b/pdf-over-signer/pdf-over-sigpdfas3/.classpath new file mode 100644 index 00000000..eed8a51e --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas3/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pdf-over-signer/pdf-over-sigpdfas3/.project b/pdf-over-signer/pdf-over-sigpdfas3/.project new file mode 100644 index 00000000..a8f28341 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas3/.project @@ -0,0 +1,23 @@ + + + pdf-over-sigpdfas + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.core.resources.prefs b/pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..29abf999 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/=UTF-8 diff --git a/pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.jdt.core.prefs b/pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..d598cb6b --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,97 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled +org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL,LOW +org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX,NOTE diff --git a/pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.jdt.ui.prefs b/pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..05288cb4 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.text.custom_code_templates= diff --git a/pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.m2e.core.prefs b/pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..62e91186 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,5 @@ +#Thu Aug 02 12:33:52 CEST 2012 +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.mylyn.tasks.ui.prefs b/pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.mylyn.tasks.ui.prefs new file mode 100644 index 00000000..c6aa7359 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas3/.settings/org.eclipse.mylyn.tasks.ui.prefs @@ -0,0 +1,4 @@ +#Fri Aug 03 18:56:31 CEST 2012 +eclipse.preferences.version=1 +project.repository.kind=jira +project.repository.url=http\://jira.egovlabs.gv.at diff --git a/pdf-over-signer/pdf-over-sigpdfas3/pom.xml b/pdf-over-signer/pdf-over-sigpdfas3/pom.xml new file mode 100644 index 00000000..942412fc --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas3/pom.xml @@ -0,0 +1,26 @@ + + 4.0.0 + + pdf-over-signer + at.a-sit + 4.0.5-SNAPSHOT + .. + + pdf-over-sigpdfas3 + PDF-Over PDF-AS Signer + + ${project.basedir}/../.. + + + + at.a-sit + pdf-over-signator + ${project.parent.version} + + + eu.europa.ec.joinup.egovlabs.pdf-as + pdf-as-lib + 3.5.2 + + + diff --git a/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/ByteArrayPDFASDataSource.java b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/ByteArrayPDFASDataSource.java new file mode 100644 index 00000000..b2f95f50 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/ByteArrayPDFASDataSource.java @@ -0,0 +1,67 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.signer.pdfas; + +//Imports +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import at.gv.egiz.pdfas.api.io.DataSource; + +/** + * PDF - AS Specific Data Source with byte array representation + */ +public class ByteArrayPDFASDataSource implements DataSource { + + /** + * Internal data byte array + */ + private byte[] data; + + /** + * Default constructor + * @param data The byte[] to be used + */ + public ByteArrayPDFASDataSource(byte[] data) { + this.data = data; + } + + @Override + public InputStream createInputStream() { + return new ByteArrayInputStream(this.data); + } + + @Override + public int getLength() { + return this.data.length; + } + + @Override + public byte[] getAsByteArray() { + return this.data; + } + + @Override + public String getMimeType() { + return "application/pdf"; + } + + @Override + public String getCharacterEncoding() { + return "UTF8"; + } + +} \ No newline at end of file diff --git a/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java new file mode 100644 index 00000000..473bbf42 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java @@ -0,0 +1,102 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.signer.pdfas; + +//Imports +import java.io.File; + +import at.asit.pdfover.signator.SignatureException; +import at.gv.egiz.pdfas.api.PdfAs; +import at.gv.egiz.pdfas.api.exceptions.PdfAsException; +import at.gv.egiz.pdfas.api.internal.PdfAsInternal; + +/** + * Encapsulates PDF AS API Object to need just one initialization + */ +public class PDFASHelper { + + /** + * PDF AS Object + */ + private static PdfAs pdfAs = null; + + /** + * Internal Pdf AS Object + */ + private static PdfAsInternal pdfAsInternal = null; + + /** + * Creates PDF AS Object + * @return + * @throws PdfAsException + */ + private static PdfAs createPdfAs() throws PdfAsException { + File directory = new File ("."); + System.setProperty("log4j.configuration", directory.getAbsolutePath() + + "/log4j.properties"); + System.setProperty("pdf-as.work-dir", getWorkDir()); + return new at.gv.egiz.pdfas.impl.api.PdfAsObject(); + } + + /** + * Provides the working directory + * @return the working directory + */ + public static String getWorkDir() { + return System.getProperty("user.home") + "/.pdf-over"; + } + + /** + * Creates a PDF-AS Internal object + * @return the PDF-AS Internal object + * @throws PdfAsException + */ + private static PdfAsInternal createPdfAsInternal() throws PdfAsException { + return new at.gv.egiz.pdfas.impl.api.internal.PdfAsInternalObject(); + } + + /** + * Gets PDF-AS Object + * @return the PDF-AS Object + * @throws SignatureException + */ + public static synchronized PdfAs getPdfAs() throws SignatureException { + if (pdfAs == null) { + try { + pdfAs = createPdfAs(); + } catch(PdfAsException e) { + throw new SignatureException(e); + } + } + return pdfAs; + } + + /** + * Gets PDF-AS Internal object + * @return the PDF-AS Internal object + * @throws SignatureException + */ + public static synchronized PdfAsInternal getPdfAsInternal() throws SignatureException { + if(pdfAsInternal == null) { + try { + pdfAsInternal = createPdfAsInternal(); + } catch(PdfAsException e) { + throw new SignatureException(e); + } + } + return pdfAsInternal; + } +} diff --git a/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java new file mode 100644 index 00000000..f274068a --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.signer.pdfas; + +// Imports +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.signator.ByteArrayDocumentSource; +import at.asit.pdfover.signator.SLRequest; +import at.asit.pdfover.signer.pdfas.exceptions.PDFASSLRequestException; + +/** + * PDF - AS Security Layer Request implementation + */ +public class PDFASSLRequest extends SLRequest { + + /** + * SLF4J Logger instance + **/ + private static final Logger log = LoggerFactory.getLogger(PDFASSLRequest.class); + + /** + * Default constructor + * @param slRequest + * @param signData + * @throws PDFASSLRequestException + */ + public PDFASSLRequest(String slRequest, byte[] signData) throws PDFASSLRequestException { + if(!slRequest.contains(PDFASSigner.LOC_REF)) { + log.error("PDF-AS SL request doesn't contain " + PDFASSigner.LOC_REF); + log.debug("Request: " + slRequest); + throw new PDFASSLRequestException("PDF-AS SL request doesn't contain " + PDFASSigner.LOC_REF); + } + + // Modifing SL Request ... + setRequest(slRequest.replace(PDFASSigner.LOC_REF, SLRequest.DATAOBJECT_STRING)); + + setSignatureData(new ByteArrayDocumentSource(signData)); + } +} diff --git a/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigner.java b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigner.java new file mode 100644 index 00000000..6fa1c094 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigner.java @@ -0,0 +1,190 @@ +package at.asit.pdfover.signer.pdfas; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.signator.BKUs; +import at.asit.pdfover.signator.ByteArrayDocumentSource; +import at.asit.pdfover.signator.SLResponse; +import at.asit.pdfover.signator.SignResult; +import at.asit.pdfover.signator.SignResultImpl; +import at.asit.pdfover.signator.SignatureException; +import at.asit.pdfover.signator.SignatureParameter; +import at.asit.pdfover.signator.SignaturePosition; +import at.asit.pdfover.signator.Signer; +import at.asit.pdfover.signator.SigningState; +import at.asit.pdfover.signer.pdfas.exceptions.PDFASSLRequestException; +import at.gv.egiz.pdfas.api.PdfAs; +import at.gv.egiz.pdfas.api.commons.Constants; +import at.gv.egiz.pdfas.api.exceptions.PdfAsException; +import at.gv.egiz.pdfas.api.internal.LocalBKUParams; +import at.gv.egiz.pdfas.api.internal.PdfAsInternal; +import at.gv.egiz.pdfas.api.sign.SignParameters; +import at.gv.egiz.pdfas.api.sign.SignatureDetailInformation; +import at.gv.egiz.pdfas.io.ByteArrayDataSink; + +/** + * PDF AS Signer Implementation + */ +public class PDFASSigner implements Signer { + + /** + * SLF4J Logger instance + **/ + static final Logger log = LoggerFactory.getLogger(PDFASSigner.class); + + /** + * The template URL + */ + protected static final String URL_TEMPLATE = "http://pdfover.4.gv.at/template"; + + /** + * Location reference string + */ + protected static final String LOC_REF = "" + URL_TEMPLATE + + ""; + + @Override + public SigningState prepare(SignatureParameter parameter) + throws SignatureException { + try { + PdfAsSignatureParameter sign_para = null; + + if (PdfAsSignatureParameter.class.isInstance(parameter)) { + sign_para = PdfAsSignatureParameter.class.cast(parameter); + } + + if (sign_para == null) { + throw new SignatureException("Incorrect SignatureParameter!"); + } + + PdfAs pdfas = PDFASHelper.getPdfAs(); + + PDFASSigningState state = new PDFASSigningState(); + + SignParameters params = new SignParameters(); + params.setSignaturePositioning(sign_para.getPDFASPositioning()); + + if (parameter.getSignatureDevice() == BKUs.LOCAL) { + params.setSignatureDevice(Constants.SIGNATURE_DEVICE_BKU); + } else if (parameter.getSignatureDevice() == BKUs.MOBILE) { + params.setSignatureDevice(Constants.SIGNATURE_DEVICE_MOBILE); + // params.setSignatureDevice(Constants.SIGNATURE_DEVICE_MOBILETEST); + } + params.setSignatureType(Constants.SIGNATURE_TYPE_BINARY); + + params.setSignatureProfileId(sign_para.getSignatureProfileID()); + + params.setOutput(new ByteArrayDataSink()); + if (parameter.getEmblem() != null) { + params.setProfileOverrideValue("SIG_LABEL", parameter + .getEmblem().getFileName()); + } + + if(parameter.getProperty("SIG_NOTE") != null) { + params.setProfileOverrideValue("SIG_NOTE", parameter.getProperty("SIG_NOTE")); + } + + // Prepare Output sink + state.setOutput(new ByteArrayDataSink()); + params.setOutput(state.getOutput()); + + params.setDocument(sign_para.getPDFASDataSource()); + + state.setSignParameters(params); + + PdfAsInternal pdfasInternal = PDFASHelper.getPdfAsInternal(); + + // Prepares the document + SignatureDetailInformation sdi = pdfas.prepareSign(params); + + state.setSignatureDetailInformation(sdi); + + // Retrieve the SL Request + String slRequest = pdfasInternal.prepareLocalSignRequest(params, + false, URL_TEMPLATE, sdi); + + at.gv.egiz.pdfas.api.io.DataSource sig_data = sdi + .getSignatureData(); + + PDFASSLRequest request = new PDFASSLRequest(slRequest, + sig_data.getAsByteArray()); + + state.setSignatureRequest(request); + + return state; + } catch (PDFASSLRequestException e) { + throw new SignatureException(e); + } catch (PdfAsException e) { + throw new SignatureException(e); + } catch (Throwable t) { + throw new SignatureException(t); + } + } + + @Override + public SignResult sign(SigningState state) throws SignatureException { + try { + PDFASSigningState sstate = null; + + if (PDFASSigningState.class.isInstance(state)) { + sstate = PDFASSigningState.class.cast(state); + } + + if (sstate == null) { + throw new SignatureException("Incorrect SigningState!"); + } + + // Retrieve objects + PdfAs pdfas = PDFASHelper.getPdfAs(); + + PdfAsInternal pdfasInternal = PDFASHelper.getPdfAsInternal(); + + SignParameters params = sstate.getSignParameters(); + + SignatureDetailInformation sdi = sstate + .getSignatureDetailInformation(); + + SLResponse slResponse = sstate.getSignatureResponse(); + + LocalBKUParams bkuParams = new LocalBKUParams( + slResponse.getServer(), slResponse.getUserAgent(), + slResponse.getSignaturLayout()); + + // Perform signature + at.gv.egiz.pdfas.api.sign.SignResult signResult = pdfasInternal + .finishLocalSign(pdfas, params, sdi, bkuParams, false, + slResponse.getSLRespone()); + + // Preparing Result Response + SignResultImpl result = new SignResultImpl(); + + // Set Signer Certificate + result.setSignerCertificate(signResult.getSignerCertificate()); + at.gv.egiz.pdfas.api.sign.pos.SignaturePosition pdfasPos = signResult + .getSignaturePosition(); + + // Set Signature position + SignaturePosition pos = new SignaturePosition(pdfasPos.getX(), + pdfasPos.getY(), pdfasPos.getPage()); + /* + * pos.SetAuto(sstate.getPDFAsSignatureParameter() + * .getSignaturePosition().useAutoPositioning()); + */ + result.setSignaturePosition(pos); + + // Set signed Document + result.setSignedDocument(new ByteArrayDocumentSource( + ((ByteArrayDataSink) sstate.getOutput()).getData())); + + return result; + } catch (PdfAsException e) { + throw new SignatureException(e); + } + } + + @Override + public SignatureParameter newParameter() { + return new PdfAsSignatureParameter(); + } +} diff --git a/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSignerFactory.java b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSignerFactory.java new file mode 100644 index 00000000..68a29341 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSignerFactory.java @@ -0,0 +1,31 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.signer.pdfas; + +//Imports +import at.asit.pdfover.signator.Signer; +import at.asit.pdfover.signator.SignerFactory; + +/** + * Factory class for PDF-AS Signer + */ +public class PDFASSignerFactory extends SignerFactory { + + @Override + public Signer createSigner() { + return new PDFASSigner(); + } +} diff --git a/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigningState.java b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigningState.java new file mode 100644 index 00000000..247b1afc --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigningState.java @@ -0,0 +1,173 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.signer.pdfas; + +//Imports +import at.asit.pdfover.signator.BkuSlConnector; +import at.asit.pdfover.signator.SLRequest; +import at.asit.pdfover.signator.SLResponse; +import at.asit.pdfover.signator.SigningState; +import at.gv.egiz.pdfas.api.io.DataSink; +import at.gv.egiz.pdfas.api.sign.SignatureDetailInformation; + +/** + * Signing State for PDFAS Wrapper + */ +public class PDFASSigningState implements SigningState { + + /** + * The Signature Layer request + */ + protected SLRequest slrequest; + + /** + * The PDF AS DataSink + */ + protected DataSink output; + + /** + * Gets the DataSink + * @return the datasink + */ + public DataSink getOutput() { + return this.output; + } + + /** + * Sets the datasing + * @param output the pdf as datasink + */ + public void setOutput(DataSink output) { + this.output = output; + } + + /** + * The Signature Layer response + */ + protected SLResponse slresponse; + + @Override + public SLRequest getSignatureRequest() { + return this.slrequest; + } + + @Override + public void setSignatureResponse(SLResponse response) { + this.slresponse = response; + } + + /** + * Sets the SL Request + * @param request The SL Request + */ + public void setSignatureRequest(SLRequest request) { + this.slrequest = request; + } + + /** + * Gets the SL Response + * @return The SL Repsonse object + */ + public SLResponse getSignatureResponse() { + return this.slresponse; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.signator.SigningState#hasSignatureResponse() + */ + @Override + public boolean hasSignatureResponse() { + return this.getSignatureResponse() != null; + } + + // ---------------------------------------- + // PDF AS Specific stuff + // ---------------------------------------- + + /** + * signature detail information + */ + protected SignatureDetailInformation signatureDetailInformation; + + /** + * PDF - AS sign parameters + */ + protected at.gv.egiz.pdfas.api.sign.SignParameters signParameters; + + /** + * Signature parameters + */ + protected PdfAsSignatureParameter pdfAsSignatureParameter; + + /** + * Gets PDF - AS Signature Parameters + * @return PdfAsSignatureParameter + */ + public PdfAsSignatureParameter getPdfAsSignatureParameter() { + return this.pdfAsSignatureParameter; + } + + /** + * Sets PDF - AS Signature Parameters + * @param pdfAsSignatureParameter + */ + public void setPdfAsSignatureParameter( + PdfAsSignatureParameter pdfAsSignatureParameter) { + this.pdfAsSignatureParameter = pdfAsSignatureParameter; + } + + /** + * Get Sign Parameters + * @return SignParameters + */ + public at.gv.egiz.pdfas.api.sign.SignParameters getSignParameters() { + return this.signParameters; + } + + /** + * Sets sign Parameter + * @param signParameters + */ + public void setSignParameters( + at.gv.egiz.pdfas.api.sign.SignParameters signParameters) { + this.signParameters = signParameters; + } + + /** + * Gets the signature detail information + * @return SignatureDetailInformation + */ + public SignatureDetailInformation getSignatureDetailInformation() { + return this.signatureDetailInformation; + } + + /** + * Sets the SignatureDetailInformation + * @param signatureDetailInformation + */ + public void setSignatureDetailInformation( + SignatureDetailInformation signatureDetailInformation) { + this.signatureDetailInformation = signatureDetailInformation; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.signator.SigningState#setBKUConnector(at.asit.pdfover.signator.BkuSlConnector) + */ + @Override + public void setBKUConnector(BkuSlConnector connector) { + // Nothing to do here + } +} diff --git a/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java new file mode 100644 index 00000000..1ceb6493 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java @@ -0,0 +1,602 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.signer.pdfas; + +//Imports +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Locale; + +import javax.imageio.ImageIO; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.signator.SignatureDimension; +import at.asit.pdfover.signator.SignatureParameter; +import at.asit.pdfover.signator.SignaturePosition; +import at.gv.egiz.pdfas.api.io.DataSource; +import at.gv.egiz.pdfas.api.sign.pos.SignaturePositioning; +import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException; + +/** + * Implementation of SignatureParameter specific for PDF - AS Library + */ +public class PdfAsSignatureParameter extends SignatureParameter { + + /** + * SLF4J Logger instance + **/ + static final Logger log = LoggerFactory + .getLogger(PdfAsSignatureParameter.class); + + /** The profile ID for the german signature block */ + private static final String PROFILE_ID_DE = "SIGNATURBLOCK_SMALL_DE"; + /** The profile ID for the german signature block if a signature note is set */ + private static final String PROFILE_ID_DE_NOTE = "SIGNATURBLOCK_SMALL_DE_NOTE"; + /** The profile ID for the english signature block */ + private static final String PROFILE_ID_EN = "SIGNATURBLOCK_SMALL_EN"; + /** The profile ID for the english signature block if a signature note is set */ + private static final String PROFILE_ID_EN_NOTE = "SIGNATURBLOCK_SMALL_EN_NOTE"; + + private HashMap genericProperties = new HashMap(); + +// private static final int PLACEHOLDER_SCALE = 4; +// +// private int height = -1; +// +// private float perUnitHeight = 0; + + /** + * Gets the PDFAS Positioning + * + * @return SignaturePositioning + * @throws PDFDocumentException + */ + public SignaturePositioning getPDFASPositioning() + throws PDFDocumentException { + SignaturePosition position = this.getSignaturePosition(); + + SignaturePositioning positioning = null; + if (!position.useAutoPositioning()) { + if (position.getPage() < 1) { + positioning = new SignaturePositioning(String.format( + (Locale) null, + "p:new;x:%f;y:%f;w:276", position.getX(), + position.getY())); + } else { + positioning = new SignaturePositioning(String.format( + (Locale) null, + "p:%d;x:%f;y:%f;w:276", position.getPage(), position.getX(), + position.getY())); + } + } else { + positioning = new SignaturePositioning("p:auto;x:auto;y:auto;w:276"); + } + + return positioning; + } + + /** + * Gets PDF - AS specific data source + * + * @return ByteArrayPDFASDataSource + */ + public DataSource getPDFASDataSource() { + return new ByteArrayPDFASDataSource(this.getInputDocument() + .getByteArray()); + } + + @Override + public void setProperty(String key, String value) { + this.genericProperties.put(key, value); +// this.height = -1; + } + + @Override + public String getProperty(String key) { + return this.genericProperties.get(key); + } + + /* (non-Javadoc) + * @see at.asit.pdfover.signator.SignatureParameter#setSignatureLanguage(java.lang.String) + */ + @Override + public void setSignatureLanguage(String signatureLanguage) { + super.setSignatureLanguage(signatureLanguage); +// this.height = -1; + } + + @Override + public SignatureDimension getPlaceholderDimension() { + // return new SignatureDimension(487, 206); + return new SignatureDimension(276, 126); + //return new SignatureDimension(getWidth(), getHeight()); + } + +// private static int getWidth() { +// return 276; +// } +// +// private int getHeight() { +// if (this.height < 0) +// { +// BufferedImage timage = new BufferedImage(1, 1, +// BufferedImage.TYPE_INT_RGB); +// try { +// this.height = (int) (getTableHeight(getSignatureTable(), null, getWidth() * PLACEHOLDER_SCALE, timage.getGraphics()) / PLACEHOLDER_SCALE); +// } catch (SignatureException e) { +// log.error("getTableHeight failed ...", e); +// } catch (SignatureTypesException e) { +// log.error("getTableHeight failed ...", e); +// } +// timage.flush(); +// } +// if (this.height < 0) +// return 95; +// +// return this.height; +// } + + /** + * Get the Signature Profile ID for this set of parameters + * @return the Signature Profile ID + */ + public String getSignatureProfileID() { + String lang = getSignatureLanguage(); + boolean useNote = (getProperty("SIG_NOTE") != null); + + if (lang != null && lang.equals("en")) + return useNote ? PROFILE_ID_EN_NOTE : PROFILE_ID_EN; + + return useNote ? PROFILE_ID_DE_NOTE : PROFILE_ID_DE; + } + + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.signator.SignatureParameter#getPlaceholder() + */ + @Override + public Image getPlaceholder() { + + try { + Image logo = null; + try { + if (this.getEmblem() != null + && this.getEmblem().getFileName() != null + && new File(this.getEmblem().getFileName()) + .exists()) { + logo = ImageIO.read(new File(this.getEmblem() + .getFileName())); + + } + } + catch(Exception e) { + log.error("Failed to get emblem ...", e); + } + + Image img = null; + String lang = getSignatureLanguage(); + if (lang != null && lang.equals("en")) { + img = ImageIO.read(PdfAsSignatureParameter.class + .getResourceAsStream("/img/sign_prev_en.png")); + + if(logo != null) { + logo = logo.getScaledInstance(141, 140, + Image.SCALE_SMOOTH); + img.getGraphics().drawImage(logo, 6, 115, null); + } + + } else { + img = ImageIO.read(PdfAsSignatureParameter.class + .getResourceAsStream("/img/sign_prev_de.png")); + + if(logo != null) { + logo = logo.getScaledInstance(141, 140, + Image.SCALE_SMOOTH); + img.getGraphics().drawImage(logo, 6, 115, null); + } + } + return img; + } catch (IOException e) { + return new BufferedImage(getPlaceholderDimension().getWidth(), + getPlaceholderDimension().getHeight(), + BufferedImage.TYPE_INT_RGB); + } + +// Try to render signature block - disabled for now (just use images) +// +// try { +// PDFASHelper.getPdfAs(); +// +// +// float width = getPlaceholderDimension().getWidth() * PLACEHOLDER_SCALE; +// float height = getPlaceholderDimension().getHeight() * PLACEHOLDER_SCALE; +// +// Table table = this.getSignatureTable(); +// +// //log.info(table.toString()); +// +// BufferedImage timage = new BufferedImage(1, 1, +// BufferedImage.TYPE_INT_RGB); +// float[] heights = this.getTableHeights(table, table.getStyle(), +// height, (int)width, timage.getGraphics()); +// timage.flush(); +// float mheight = 0; +// +// for(int i = 0; i < heights.length; i++) { +// mheight += heights[i]; +// } +// +// this.height = (int) (mheight / PLACEHOLDER_SCALE); +// +// log.info("Width: " + width + " Height: " + height + " HShould: " + mheight); +// BufferedImage image = new BufferedImage((int) width, (int) mheight, +// BufferedImage.TYPE_INT_RGB); +// Graphics g = image.getGraphics(); +// +// g.setColor(table.getStyle().getBgColor()); +// g.fillRect(0, 0, (int) width, (int) mheight); +// +// g.setColor(Color.black); +// g.drawRect(0, 0, (int) width, (int) mheight); +// +// this.drawTable(0, 0, (int) width, (int) mheight, table, +// table.getStyle(), g, heights); +// +// g.dispose(); +// +// //save(image, "png"); +// +// return image; +// } catch (Exception ex) { +// try { +// return ImageIO.read(PdfAsSignatureParameter.class +// .getResourceAsStream("/img/fallbackPlaceholder.png")); +// } catch (IOException e) { +// return new BufferedImage(getPlaceholderDimension().getWidth(), +// getPlaceholderDimension().getHeight(), +// BufferedImage.TYPE_INT_RGB); +// } +// } + } + +// private Table getSignatureTable() throws SignatureException, SignatureTypesException { +// SignatureObject sign_obj = at.knowcenter.wag.egov.egiz.PdfAS +// .createSignatureObjectFromType(getSignatureProfileID()); +// +// sign_obj.fillValues(' ', true, false); +// sign_obj.setKZ(BinarySignator_1_1_0.MY_ID); +// return sign_obj.getAbstractTable(); +// } +// +// /** +// * used for debugging .. +// * +// * @param image +// * @param ext +// */ +// @SuppressWarnings("unused") +// @Deprecated +// private static void save(BufferedImage image, String ext) { +// String fileName = "savingAnImage"; +// File file = new File(fileName + "." + ext); +// try { +// ImageIO.write(image, ext, file); // ignore returned boolean +// log.debug("Saved as: " + file.getAbsolutePath()); +// } catch (IOException e) { +// System.out.println("Write error for " + file.getPath() + ": " +// + e.getMessage()); +// } +// } +// +// @SuppressWarnings("rawtypes") +// private int drawTable(int xoff, int yoff, int width, int height, +// Table table, Style parentstyle, Graphics g, float[] heights) { +// Style style = parentstyle; +// if (table.getStyle() != null) { +// style = table.getStyle(); +// } +// +// log.debug(String.format((Locale) null, "Table@ %dx%d", xoff, yoff)); +// +// Font oldFont = g.getFont(); +// Font font = PdfAsSignatureParameter.getFont(style); +// g.setFont(font); +// // draw background +// // graphic.setColor(style.getBgColor()); +// // graphic.fillRect(xoff, yoff, width, height); +// +// g.setColor(Color.black); +// +// // draw border +// if (style.getBorder() > 0) { +// g.setColor(Color.black); +// g.drawRect(xoff, yoff, width, height); +// } +// float[] colWidths = table.getColsRelativeWith(); +// float sum = 0; +// +// for (int i = 0; i < colWidths.length; i++) { +// sum += colWidths[i]; +// } +// +// float perUnit = width / sum; +// +// int padding = (int) (style.getPadding() * this.perUnitHeight * PLACEHOLDER_SCALE); +// +// ArrayList rows = table.getRows(); +// float roffset = 0; +// for (int rowidx = 0; rowidx < rows.size(); rowidx++) { +// ArrayList cols = (ArrayList) rows.get(rowidx); +// int rsize = (int) heights[rowidx]; +// for (int j = 0; j < cols.size(); j++) { +// Entry entry = (Entry) cols.get(j); +// float offset = 0; +// for (int k = 0; k < j; k++) { +// offset += colWidths[k] * perUnit; +// } +// if (entry.getType() == 0 || entry.getType() == 1) { +// // Text +// g.drawRect((int) (xoff + offset), +// (int) (yoff + roffset), +// (int) (colWidths[j] * perUnit), rsize); +// +// String[] lines = getLines(entry.getValue().toString(), (int)(colWidths[j] * perUnit), g.getFontMetrics(), (int) style.getPadding() * PLACEHOLDER_SCALE); +// +// for(int i = 0; i < lines.length; i++) { +// g.drawString(lines[i].toString(), (int) (xoff +// + offset + padding / PLACEHOLDER_SCALE), (int) (yoff + padding +// + roffset + (i + 1) * g.getFontMetrics().getHeight() * this.perUnitHeight)); +// } +// //g.drawString(entry.getValue().toString(), (int) (xoff +// // + offset + padding / PLACEHOLDER_SCALE), (int) (yoff + padding +// // + roffset + font.getSize() * this.perUnitHeight)); +// } else if (entry.getType() == 2) { +// // Image ... +// BufferedImage image; +// try { +// if (this.getEmblem() != null +// && this.getEmblem().getFileName() != null +// && new File(this.getEmblem().getFileName()) +// .exists()) { +// image = ImageIO.read(new File(this.getEmblem() +// .getFileName())); +// } else { +// image = ImageIO.read(new File(PDFASHelper +// .getWorkDir() +// + File.separator +// + entry.getValue().toString())); +// } +// int imgWidth = 30 * PLACEHOLDER_SCALE; +// int imgHeight = 30 * PLACEHOLDER_SCALE; +// Image img = image.getScaledInstance(imgWidth, imgHeight, +// Image.SCALE_SMOOTH); +// +// g.drawImage( +// img, +// (int) (xoff + offset + padding + (((colWidths[j] * perUnit) - imgWidth - 2* padding)) / 2), +// (int) (yoff + roffset + padding + ((rsize - imgHeight - 2* padding) / 2)), +// null); +// } catch (IOException e) { +// log.warn("Failed to paint emblem to placeholder image"); +// } +// } else { +// // Table +// +// int colWidth = (int) (colWidths[j] * perUnit); +// +// float[] cheights = this.getTableHeights( +// (Table) entry.getValue(), style, rsize, colWidth, g); +// +// this.drawTable( +// (int) (xoff + offset), +// (int) (yoff + roffset), +// (int) (colWidths[j] * perUnit), +// // (int)this.getTableHeight((Table) +// // entry.getValue(), style), +// rsize, (Table) entry.getValue(), style, g, +// cheights); +// /* +// * if (rsize < tsize) { rsize = tsize; } +// */ +// } +// } +// roffset += rsize; +// } +// +// g.setFont(oldFont); +// +// return (int) roffset; +// } +// +// private static Font getFont(Style style) { +// String def = "COURIER-NORMAL-8"; +// String fontString = style.getFont(); +// String[] font_arr = fontString.split(","); +// if (font_arr.length != 3) { +// return Font.decode(def); +// } +// Font font = Font.decode(String.format("%s-%s-%s", font_arr[0], font_arr[2], +// font_arr[1])); +// return font.deriveFont((float) font.getSize() * PLACEHOLDER_SCALE); +// } +// +// /** +// * extracts the value font +// * +// * @param style +// * the table style +// * @return the value font +// */ +// @SuppressWarnings("unused") +// private static Font getValueFont(Style style) { +// String def = "COURIER-NORMAL-8"; +// String fontString = style.getValueFont(); +// String[] font_arr = fontString.split(","); +// if (font_arr.length != 3) { +// return Font.decode(def); +// } +// Font font = Font.decode(String.format("%s-%s-%s", font_arr[0], font_arr[2], +// font_arr[1])); +// return font.deriveFont((float) font.getSize() * PLACEHOLDER_SCALE); +// } +// +// private static String[] getLines(String text, int width, FontMetrics fmetric, int padding) { +// String currentline = text; +// int averageCharWi = fmetric.charWidth('c'); +// +// int max_line_chars = (width - padding) / (averageCharWi); +// ArrayList lines = new ArrayList(); +// +// while(currentline.length() > max_line_chars) { +// int cutidx = currentline.substring(0, max_line_chars).lastIndexOf(' '); +// if(cutidx < 1) { +// cutidx = max_line_chars - 1; +// } else { +// cutidx++; +// } +// String tmpLine = currentline.substring(0, cutidx); +// lines.add(tmpLine); +// currentline = currentline.substring(cutidx); +// } +// lines.add(currentline); +// +// +// String[] arrline = new String[lines.size()]; +// for(int i = 0; i < lines.size(); i++) { +// arrline[i] = lines.get(i); +// } +// +// //log.debug(text + " needs " + lines.size() + " lines"); +// +// return arrline; +// } +// +// @SuppressWarnings("rawtypes") +// private float[] getTableHeights(Table table, Style parentstyle, float height, int width, Graphics g) { +// ArrayList rows = table.getRows(); +// float[] sizes = new float[rows.size()]; +// Style style = parentstyle; +// if (table.getStyle() != null) { +// style = table.getStyle(); +// } +// Font font = PdfAsSignatureParameter.getFont(style); +// g.setFont(font); +// +// float total_height = this.getTableHeight(table, parentstyle, width, g); +// +// float perUnit = height / total_height; +// +// this.perUnitHeight = perUnit; +// +// float[] colWidths = table.getColsRelativeWith(); +// float sum = 0; +// +// for (int i = 0; i < colWidths.length; i++) { +// sum += colWidths[i]; +// } +// +// float perUnitWidth = width / sum; +// +// for (int i = 0; i < rows.size(); i++) { +// Object robj = rows.get(i); +// ArrayList cols = (ArrayList) robj; +// float tsize = 0; +// float rsize = 0; +// for (int j = 0; j < cols.size(); j++) { +// Entry entry = (Entry) cols.get(j); +// if (entry.getType() == 0 || entry.getType() == 1) { +// int colWidth = (int) (colWidths[j] * perUnitWidth); +// +// float trsize = getLines(entry.getValue().toString(), colWidth, g.getFontMetrics(), (int) style.getPadding() * PLACEHOLDER_SCALE).length * g.getFontMetrics().getHeight() + (style.getPadding() * PLACEHOLDER_SCALE * 2); +// +// if (rsize < trsize) { +// rsize = trsize; +// } +// } else if (entry.getType() == 3) { +// +// int colWidth = (int) (colWidths[j] * perUnitWidth); +// +// tsize = this +// .getTableHeight((Table) entry.getValue(), style, colWidth, g); +// if (rsize < tsize) { +// rsize = tsize; +// } +// } +// } +// sizes[i] = perUnit * rsize; +// } +// +// return sizes; +// } +// +// @SuppressWarnings("rawtypes") +// private float getTableHeight(Table table, Style parentstyle, int width, Graphics g) { +// ArrayList rows = table.getRows(); +// Style style = parentstyle; +// if (table.getStyle() != null) { +// style = table.getStyle(); +// } +// float size = 0; +// +// float[] colWidths = table.getColsRelativeWith(); +// float sum = 0; +// +// for (int i = 0; i < colWidths.length; i++) { +// sum += colWidths[i]; +// } +// +// float perUnitWidth = width / sum; +// +// for (int i = 0; i < rows.size(); i++) { +// Object robj = rows.get(i); +// ArrayList cols = (ArrayList) robj; +// float tsize = 0; +// float rsize = 0; +// for (int j = 0; j < cols.size(); j++) { +// Entry entry = (Entry) cols.get(j); +// if (entry.getType() == 0 || entry.getType() == 1) { +// int colWidth = (int) (colWidths[j] * perUnitWidth); +// +// float trsize = getLines(entry.getValue().toString(), colWidth, g.getFontMetrics(), (int) style.getPadding() * PLACEHOLDER_SCALE).length * g.getFontMetrics().getHeight() + (style.getPadding() * PLACEHOLDER_SCALE * 2); +// +// if (rsize < trsize) { +// rsize = trsize; +// } +// +// /*if (rsize < ((style.getPadding() * PLACEHOLDER_SCALE * 2) + fontSize)) { +// rsize = ((style.getPadding() * PLACEHOLDER_SCALE * 2) + fontSize); +// }*/ +// } else if (entry.getType() == 3) { +// int colWidth = (int) (colWidths[j] * perUnitWidth); +// tsize = this +// .getTableHeight((Table) entry.getValue(), style, colWidth, g); +// if (rsize < tsize) { +// rsize = tsize; +// } +// } +// } +// size += rsize; +// } +// +// return size; +// } +} diff --git a/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/exceptions/PDFASSLRequestException.java b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/exceptions/PDFASSLRequestException.java new file mode 100644 index 00000000..ceb25779 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/exceptions/PDFASSLRequestException.java @@ -0,0 +1,34 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.signer.pdfas.exceptions; + +/** + * + */ +public class PDFASSLRequestException extends Exception { + /** + * + */ + private static final long serialVersionUID = -7515747014505057787L; + + /** + * Constructor + * @param msg + */ + public PDFASSLRequestException(String msg) { + super(msg); + } +} diff --git a/pdf-over-signer/pdf-over-sigpdfas3/src/main/resources/img/fallbackPlaceholder.png b/pdf-over-signer/pdf-over-sigpdfas3/src/main/resources/img/fallbackPlaceholder.png new file mode 100644 index 00000000..4baafc19 Binary files /dev/null and b/pdf-over-signer/pdf-over-sigpdfas3/src/main/resources/img/fallbackPlaceholder.png differ diff --git a/pdf-over-signer/pdf-over-sigpdfas3/src/main/resources/img/sign_prev_de.png b/pdf-over-signer/pdf-over-sigpdfas3/src/main/resources/img/sign_prev_de.png new file mode 100644 index 00000000..c8ca09f4 Binary files /dev/null and b/pdf-over-signer/pdf-over-sigpdfas3/src/main/resources/img/sign_prev_de.png differ diff --git a/pdf-over-signer/pdf-over-sigpdfas3/src/main/resources/img/sign_prev_en.png b/pdf-over-signer/pdf-over-sigpdfas3/src/main/resources/img/sign_prev_en.png new file mode 100644 index 00000000..aa450fcc Binary files /dev/null and b/pdf-over-signer/pdf-over-sigpdfas3/src/main/resources/img/sign_prev_en.png differ diff --git a/pdf-over-signer/pdf-over-sigpdfas4/.classpath b/pdf-over-signer/pdf-over-sigpdfas4/.classpath new file mode 100644 index 00000000..eed8a51e --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pdf-over-signer/pdf-over-sigpdfas4/.project b/pdf-over-signer/pdf-over-sigpdfas4/.project new file mode 100644 index 00000000..1d14e32f --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/.project @@ -0,0 +1,26 @@ + + + pdf-over-sigpdfas + + + pdf-as-common + pdf-as-lib + sigs-pades + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.core.resources.prefs b/pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..29abf999 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/=UTF-8 diff --git a/pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.jdt.core.prefs b/pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..d598cb6b --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,97 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled +org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL,LOW +org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX,NOTE diff --git a/pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.jdt.ui.prefs b/pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..05288cb4 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.text.custom_code_templates= diff --git a/pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.m2e.core.prefs b/pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..62e91186 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,5 @@ +#Thu Aug 02 12:33:52 CEST 2012 +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.mylyn.tasks.ui.prefs b/pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.mylyn.tasks.ui.prefs new file mode 100644 index 00000000..c6aa7359 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/.settings/org.eclipse.mylyn.tasks.ui.prefs @@ -0,0 +1,4 @@ +#Fri Aug 03 18:56:31 CEST 2012 +eclipse.preferences.version=1 +project.repository.kind=jira +project.repository.url=http\://jira.egovlabs.gv.at diff --git a/pdf-over-signer/pdf-over-sigpdfas4/pom.xml b/pdf-over-signer/pdf-over-sigpdfas4/pom.xml new file mode 100644 index 00000000..482eade1 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/pom.xml @@ -0,0 +1,65 @@ + + 4.0.0 + + pdf-over-signer + at.a-sit + 4.0.5-SNAPSHOT + .. + + pdf-over-sigpdfas4 + PDF-Over PDF-AS 4 Signer + + ${project.basedir}/../.. + 4.0.5-SNAPSHOT + + + + at.a-sit + pdf-over-signator + ${project.parent.version} + + + at.gv.egiz.pdfas + pdf-as-lib + ${pdf-as.version} + + + at.gv.egiz.pdfas + sigs-pades + ${pdf-as.version} + + + at.gv.egiz.pdfas + pdf-as-pdfbox + ${pdf-as.version} + + + iaik + iaik_jce_full_signed + 5.2 + + + iaik + iaik_eccelerate + 2.15 + + + iaik + iaik_cms + 2.15 + + + iaik + iaik_eccelerate_cms + 2.15 + + + + diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java new file mode 100644 index 00000000..33221285 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java @@ -0,0 +1,144 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.signer.pdfas; + +// Imports +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.signator.BkuSlConnector; +import at.asit.pdfover.signator.SignatureException; +import at.asit.pdfover.signer.pdfas.exceptions.PdfAs4SLRequestException; +import at.gv.egiz.pdfas.common.exceptions.PDFIOException; +import at.gv.egiz.pdfas.common.exceptions.PdfAsException; +import at.gv.egiz.pdfas.common.exceptions.SLPdfAsException; +import at.gv.egiz.pdfas.lib.api.sign.SignParameter; +import at.gv.egiz.sl.schema.CreateCMSSignatureResponseType; +import at.gv.egiz.sl.schema.ErrorResponseType; +import at.gv.egiz.sl.schema.InfoboxReadRequestType; +import at.gv.egiz.sl.schema.InfoboxReadResponseType; +import at.gv.egiz.sl.util.BaseSLConnector; +import at.gv.egiz.sl.util.RequestPackage; +import at.gv.egiz.sl.util.SLMarschaller; + +/** + * + */ +public class PdfAs4BKUSLConnector extends BaseSLConnector { + /** + * SLF4J Logger instance + **/ + private static final Logger log = LoggerFactory + .getLogger(PdfAs4BKUSLConnector.class); + + private BkuSlConnector connector; + + /** + * Constructor + * @param connector the BKU SL Connector + */ + public PdfAs4BKUSLConnector(BkuSlConnector connector) { + this.connector = connector; + } + + + /* (non-Javadoc) + * @see at.gv.egiz.sl.util.ISLConnector#sendInfoboxReadRequest(at.gv.egiz.sl.schema.InfoboxReadRequestType, at.gv.egiz.pdfas.lib.api.sign.SignParameter) + */ + @Override + public InfoboxReadResponseType sendInfoboxReadRequest( + InfoboxReadRequestType request, SignParameter parameter) + throws PdfAsException { + JAXBElement element = null; + try { + String slRequestString = SLMarschaller.marshalToString(this.of.createInfoboxReadRequest(request)); + log.trace(slRequestString); + + PdfAs4SLRequest slRequest = new PdfAs4SLRequest(slRequestString, null); + String slResponse = this.connector.handleSLRequest(slRequest).getSLRespone(); + + element = (JAXBElement) SLMarschaller + .unmarshalFromString(slResponse); + } catch (JAXBException e) { + throw new PDFIOException("error.pdf.io.03", e); + } catch (PdfAs4SLRequestException e) { + throw new PDFIOException("error.pdf.io.03", e); + } catch (SignatureException e) { + throw new PDFIOException("error.pdf.io.03", e); + } + + if (element == null) { + throw new PDFIOException("error.pdf.io.04"); + } + + if (element.getValue() instanceof InfoboxReadResponseType) { + InfoboxReadResponseType infoboxReadResponseType = (InfoboxReadResponseType) element + .getValue(); + return infoboxReadResponseType; + } else if (element.getValue() instanceof ErrorResponseType) { + ErrorResponseType errorResponseType = (ErrorResponseType) element + .getValue(); + throw new SLPdfAsException(errorResponseType.getErrorCode(), + errorResponseType.getInfo()); + } + throw new PdfAsException("error.pdf.io.03"); + } + + /* (non-Javadoc) + * @see at.gv.egiz.sl.util.ISLConnector#sendCMSRequest(at.gv.egiz.sl.util.RequestPackage, at.gv.egiz.pdfas.lib.api.sign.SignParameter) + */ + @Override + public CreateCMSSignatureResponseType sendCMSRequest(RequestPackage pack, + SignParameter parameter) throws PdfAsException { + JAXBElement element = null; + try { + String slRequestString = SLMarschaller.marshalToString(this.of.createCreateCMSSignatureRequest(pack.getRequestType())); + log.debug(slRequestString); + + PdfAs4SLRequest slRequest = new PdfAs4SLRequest(slRequestString, pack.getSignatureData()); + String slResponse = this.connector.handleSLRequest(slRequest).getSLRespone(); + + element = (JAXBElement) SLMarschaller + .unmarshalFromString(slResponse); + } catch (JAXBException e) { + throw new PDFIOException("error.pdf.io.03", e); + } catch (PdfAs4SLRequestException e) { + throw new PDFIOException("error.pdf.io.03", e); + } catch (SignatureException e) { + throw new PDFIOException("error.pdf.io.03", e); + } + + if (element == null) { + throw new PDFIOException("error.pdf.io.05"); + } + + if (element.getValue() instanceof CreateCMSSignatureResponseType) { + CreateCMSSignatureResponseType createCMSSignatureResponseType = (CreateCMSSignatureResponseType) element + .getValue(); + log.debug(createCMSSignatureResponseType.toString()); + return createCMSSignatureResponseType; + } else if (element.getValue() instanceof ErrorResponseType) { + ErrorResponseType errorResponseType = (ErrorResponseType) element + .getValue(); + throw new SLPdfAsException(errorResponseType.getErrorCode(), + errorResponseType.getInfo()); + } + throw new PdfAsException("error.pdf.io.03"); + } +} diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Helper.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Helper.java new file mode 100644 index 00000000..21a6bbdb --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Helper.java @@ -0,0 +1,79 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.signer.pdfas; + +// Imports +import java.io.File; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.signator.SignatureException; +import at.gv.egiz.pdfas.lib.api.PdfAs; +import at.gv.egiz.pdfas.lib.api.PdfAsFactory; + +/** + * PDF-AS 4 Helper + */ +public class PdfAs4Helper { + /** + * SLF4J Logger instance + **/ + @SuppressWarnings("unused") + private static final Logger log = LoggerFactory + .getLogger(PdfAs4Helper.class); + + /** + * PDF-AS Object + */ + private static PdfAs pdfAs = null; + + /** + * Gets PDF-AS Object + * @return the PDF-AS Object + * @throws SignatureException + */ + public static synchronized PdfAs getPdfAs() throws SignatureException { + if (pdfAs == null) { + try { + pdfAs = createPdfAs(); + } catch(Exception e) { + throw new SignatureException(e); + } + } + return pdfAs; + } + + /** + * Creates PDF-AS Object + * @return the PDF-AS Object + * @throws PdfAsException + */ + private static PdfAs createPdfAs() { + File directory = new File ("."); + System.setProperty("log4j.configuration", directory.getAbsolutePath() + + "/log4j.properties"); + return PdfAsFactory.createPdfAs(new File(getWorkDir())); + } + + /** + * Provides the working directory + * @return the working directory + */ + public static String getWorkDir() { + return System.getProperty("user.home") + "/.pdf-over"; + } +} diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SLRequest.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SLRequest.java new file mode 100644 index 00000000..87babd59 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SLRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.signer.pdfas; + +// Imports +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.signator.ByteArrayDocumentSource; +import at.asit.pdfover.signator.SLRequest; +import at.asit.pdfover.signer.pdfas.exceptions.PdfAs4SLRequestException; + +/** + * PDF - AS Security Layer Request implementation + */ +public class PdfAs4SLRequest extends SLRequest { + + /** + * SLF4J Logger instance + **/ + @SuppressWarnings("unused") + private static final Logger log = LoggerFactory.getLogger(PdfAs4SLRequest.class); + + /** + * Default constructor + * @param slRequest + * @param signData + * @throws PdfAs4SLRequestException + */ + public PdfAs4SLRequest(String slRequest, byte[] signData) throws PdfAs4SLRequestException { +// if(!slRequest.contains(PdfAs4Signer.LOC_REF)) { +// log.error("PDF-AS SL request doesn't contain " + PdfAs4Signer.LOC_REF); +// log.debug("Request: " + slRequest); +// throw new PdfAs4SLRequestException("PDF-AS SL request doesn't contain " + PdfAs4Signer.LOC_REF); +// } +// +// // Modifing SL Request ... +// setRequest(slRequest.replace(PdfAs4Signer.LOC_REF, SLRequest.DATAOBJECT_STRING)); + + setRequest(slRequest); + setSignatureData(signData == null ? null : new ByteArrayDocumentSource(signData)); + } +} diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java new file mode 100644 index 00000000..38aabadd --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java @@ -0,0 +1,161 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.signer.pdfas; + +//Imports +import iaik.x509.X509Certificate; + +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.util.HashMap; +import java.util.Locale; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.signator.SignatureDimension; +import at.asit.pdfover.signator.SignatureParameter; +import at.asit.pdfover.signator.SignaturePosition; +import at.gv.egiz.pdfas.lib.api.Configuration; +import at.gv.egiz.pdfas.lib.api.PdfAs; +import at.gv.egiz.pdfas.lib.api.PdfAsFactory; +import at.gv.egiz.pdfas.lib.api.sign.SignParameter; + +/** + * Implementation of SignatureParameter for PDF-AS 4 Library + */ +public class PdfAs4SignatureParameter extends SignatureParameter { + /** The profile ID for the German signature block */ + private static final String PROFILE_ID_DE = "SIGNATURBLOCK_SMALL_DE_PDFA"; + /** The profile ID for the German signature block if a signature note is set */ + private static final String PROFILE_ID_DE_NOTE = "SIGNATURBLOCK_SMALL_DE_NOTE_PDFA"; + /** The profile ID for the English signature block */ + private static final String PROFILE_ID_EN = "SIGNATURBLOCK_SMALL_EN_PDFA"; + /** The profile ID for the English signature block if a signature note is set */ + private static final String PROFILE_ID_EN_NOTE = "SIGNATURBLOCK_SMALL_EN_NOTE_PDFA"; + + private HashMap genericProperties = new HashMap(); + + private int sig_w = 229; + private int sig_h = 77; + + /** + * SLF4J Logger instance + **/ + static final Logger log = LoggerFactory + .getLogger(PdfAs4SignatureParameter.class); + + /* (non-Javadoc) + * @see at.asit.pdfover.signator.SignatureParameter#getPlaceholderDimension() + */ + @Override + public SignatureDimension getPlaceholderDimension() { + return new SignatureDimension(this.sig_w, this.sig_h); + } + + /* (non-Javadoc) + * @see at.asit.pdfover.signator.SignatureParameter#getPlaceholder() + */ + @Override + public Image getPlaceholder() { + String sigProfile = getPdfAsSignatureProfileId(); + String sigEmblem = (getEmblem() == null ? null : getEmblem().getFileName()); + String sigNote = getProperty("SIG_NOTE"); + + try { + X509Certificate cert = new X509Certificate(PdfAs4SignatureParameter.class.getResourceAsStream("/qualified.cer")); + PdfAs pdfas = PdfAs4Helper.getPdfAs(); + Configuration conf = pdfas.getConfiguration(); + if (sigEmblem != null && !sigEmblem.trim().equals("")) { + conf.setValue("sig_obj." + sigProfile + ".value.SIG_LABEL", sigEmblem); + } + if (sigNote != null) { + conf.setValue("sig_obj." + sigProfile + ".value.SIG_NOTE", sigNote); + } + SignParameter param = PdfAsFactory + .createSignParameter(conf, null, null); + param.setSignatureProfileId(sigProfile); + Image img = pdfas.generateVisibleSignaturePreview(param, cert, 72*4); + this.sig_w = img.getWidth(null)/4; + this.sig_h = img.getHeight(null)/4; + + return img; + } catch (Exception e) { + log.error("Failed to get signature placeholder", e); + return new BufferedImage(getPlaceholderDimension().getWidth(), + getPlaceholderDimension().getHeight(), + BufferedImage.TYPE_INT_RGB); + } + } + + /* (non-Javadoc) + * @see at.asit.pdfover.signator.SignatureParameter#setProperty(java.lang.String, java.lang.String) + */ + @Override + public void setProperty(String key, String value) { + this.genericProperties.put(key, value); + } + + /* (non-Javadoc) + * @see at.asit.pdfover.signator.SignatureParameter#getProperty(java.lang.String) + */ + @Override + public String getProperty(String key) { + return this.genericProperties.get(key); + } + + /** + * Gets the Signature Position String for PDF-AS + * + * @return Signature Position String + */ + public String getPdfAsSignaturePosition() { + SignaturePosition in_pos = getSignaturePosition(); + String out_pos; + + if (!in_pos.useAutoPositioning()) { + if (in_pos.getPage() < 1) { + out_pos = String.format( + (Locale) null, + "p:new;x:%f;y:%f", in_pos.getX(), + in_pos.getY()); + } else { + out_pos = String.format( + (Locale) null, + "p:%d;x:%f;y:%f", in_pos.getPage(), in_pos.getX(), + in_pos.getY()); + } + } else { + out_pos = "p:auto;x:auto;y:auto"; + } + + return out_pos; + } + + /** + * Get the Signature Profile ID for this set of parameters + * @return the Signature Profile ID + */ + public String getPdfAsSignatureProfileId() { + String lang = getSignatureLanguage(); + boolean useNote = (getProperty("SIG_NOTE") != null); + + if (lang != null && lang.equals("en")) + return useNote ? PROFILE_ID_EN_NOTE : PROFILE_ID_EN; + + return useNote ? PROFILE_ID_DE_NOTE : PROFILE_ID_DE; + } +} diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java new file mode 100644 index 00000000..0f42a517 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java @@ -0,0 +1,146 @@ +package at.asit.pdfover.signer.pdfas; + +import java.io.ByteArrayOutputStream; +import java.util.UUID; + +import javax.activation.DataSource; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.signator.ByteArrayDocumentSource; +import at.asit.pdfover.signator.SignResult; +import at.asit.pdfover.signator.SignResultImpl; +import at.asit.pdfover.signator.SignatureException; +import at.asit.pdfover.signator.SignatureParameter; +import at.asit.pdfover.signator.SignaturePosition; +import at.asit.pdfover.signator.Signer; +import at.asit.pdfover.signator.SigningState; +import at.gv.egiz.pdfas.common.exceptions.PDFASError; +import at.gv.egiz.pdfas.common.exceptions.PdfAsException; +import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource; +import at.gv.egiz.pdfas.lib.api.Configuration; +import at.gv.egiz.pdfas.lib.api.PdfAs; +import at.gv.egiz.pdfas.lib.api.PdfAsFactory; +import at.gv.egiz.pdfas.lib.api.sign.SignParameter; +import at.gv.egiz.pdfas.sigs.pades.PAdESSigner; +import at.gv.egiz.sl.util.ISLConnector; +import at.knowcenter.wag.egov.egiz.pdf.TablePos; + +/** + * PDF AS Signer Implementation + */ +public class PdfAs4Signer implements Signer { + + /** + * SLF4J Logger instance + **/ + static final Logger log = LoggerFactory.getLogger(PdfAs4Signer.class); + + /** + * The template URL + */ + protected static final String URL_TEMPLATE = "http://pdfover.4.gv.at/template"; + + /** + * Location reference string + */ + protected static final String LOC_REF = "" + URL_TEMPLATE + + ""; + + @Override + public SigningState prepare(SignatureParameter parameter) + throws SignatureException { + PdfAs4SignatureParameter sign_para = null; + + if (PdfAs4SignatureParameter.class.isInstance(parameter)) { + sign_para = PdfAs4SignatureParameter.class.cast(parameter); + } + + if (sign_para == null) { + throw new SignatureException("Incorrect SignatureParameter!"); + } + + String sigProfile = sign_para.getPdfAsSignatureProfileId(); + String sigEmblem = (sign_para.getEmblem() == null ? null : sign_para.getEmblem().getFileName()); + String sigNote = sign_para.getProperty("SIG_NOTE"); + String sigPos = sign_para.getPdfAsSignaturePosition(); + + PdfAs pdfas = PdfAs4Helper.getPdfAs(); + Configuration config = pdfas.getConfiguration(); + if (sigEmblem != null && !sigEmblem.trim().isEmpty()) { + config.setValue("sig_obj." + sigProfile + ".value.SIG_LABEL", sigEmblem); + } + + if(sigNote != null) { + config.setValue("sig_obj." + sigProfile + ".value.SIG_NOTE", sigNote); + } + + PdfAs4SigningState state = new PdfAs4SigningState(); + ByteArrayOutputStream output = new ByteArrayOutputStream(); + DataSource input = new ByteArrayDataSource(parameter.getInputDocument().getByteArray()); + SignParameter param = PdfAsFactory.createSignParameter(config, input, output); + param.setSignaturePosition(sigPos); + param.setSignatureProfileId(sigProfile); + String id = UUID.randomUUID().toString(); + param.setTransactionId(id); + state.setSignParameter(param); + state.setOutput(output); + return state; + } + + @Override + public SignResult sign(SigningState state) throws SignatureException { + try { + PdfAs4SigningState sstate = null; + + if (PdfAs4SigningState.class.isInstance(state)) { + sstate = PdfAs4SigningState.class.cast(state); + } + + if (sstate == null) { + throw new SignatureException("Incorrect SigningState!"); + } + + // Retrieve objects + PdfAs pdfas = PdfAs4Helper.getPdfAs(); + + SignParameter param = sstate.getSignParameter(); + + ISLConnector connector = new PdfAs4BKUSLConnector(sstate.getBKUConnector()); + param.setPlainSigner(new PAdESSigner(connector)); + + pdfas.sign(param); + + // Preparing Result Response + SignResultImpl result = new SignResultImpl(); + +// // Set Signer Certificate +// result.setSignerCertificate(..); + + // Set Signature position + TablePos tp = new TablePos(param.getSignaturePosition()); + SignaturePosition sp; + if (tp.isXauto() && tp.isYauto()) + sp = new SignaturePosition(); + else if (tp.isPauto()) + sp = new SignaturePosition(tp.getPosX(), tp.getPosY()); + else + sp = new SignaturePosition(tp.getPosX(), tp.getPosY(), tp.getPage()); + result.setSignaturePosition(sp); + + // Set signed Document + result.setSignedDocument(new ByteArrayDocumentSource(sstate.getOutput().toByteArray())); + return result; + } catch (PdfAsException e) { + throw new SignatureException(e); + } catch (PDFASError e) { + throw new SignatureException(e); + } + } + + @Override + public SignatureParameter newParameter() { + return new PdfAs4SignatureParameter(); + } +} diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignerFactory.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignerFactory.java new file mode 100644 index 00000000..3fa7ce16 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignerFactory.java @@ -0,0 +1,31 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.signer.pdfas; + +//Imports +import at.asit.pdfover.signator.Signer; +import at.asit.pdfover.signator.SignerFactory; + +/** + * Factory class for PDF-AS Signer + */ +public class PdfAs4SignerFactory extends SignerFactory { + + @Override + public Signer createSigner() { + return new PdfAs4Signer(); + } +} diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java new file mode 100644 index 00000000..b8280142 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java @@ -0,0 +1,133 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.signer.pdfas; + +//Imports +import java.io.ByteArrayOutputStream; + +import at.asit.pdfover.signator.BkuSlConnector; +import at.asit.pdfover.signator.SLRequest; +import at.asit.pdfover.signator.SLResponse; +import at.asit.pdfover.signator.SigningState; +import at.gv.egiz.pdfas.lib.api.sign.SignParameter; + +/** + * Signing State for PDFAS Wrapper + */ +public class PdfAs4SigningState implements SigningState { + + /** + * The Signature Layer request + */ + private SLRequest slrequest; + + /** + * The Signature Layer response + */ + private SLResponse slresponse; + + /** + * The Sign Parameters + */ + private SignParameter parameter; + + private ByteArrayOutputStream output; + + private BkuSlConnector connector; + + /* (non-Javadoc) + * @see at.asit.pdfover.signator.SigningState#getSignatureRequest() + */ + @Override + public SLRequest getSignatureRequest() { + return this.slrequest; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.signator.SigningState#setSignatureResponse(at.asit.pdfover.signator.SLResponse) + */ + @Override + public void setSignatureResponse(SLResponse response) { + this.slresponse = response; + } + + /** + * Sets the SL Request + * @param request The SL Request + */ + public void setSignatureRequest(SLRequest request) { + this.slrequest = request; + } + + /** + * Gets the SL Response + * @return The SL Response object + */ + public SLResponse getSignatureResponse() { + return this.slresponse; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.signator.SigningState#hasSignatureResponse() + */ + @Override + public boolean hasSignatureResponse() { + return this.slresponse != null; + } + + /** + * @return the output + */ + public ByteArrayOutputStream getOutput() { + return this.output; + } + + /** + * @param output the output to set + */ + public void setOutput(ByteArrayOutputStream output) { + this.output = output; + } + + /** + * @return the parameter + */ + public SignParameter getSignParameter() { + return this.parameter; + } + + /** + * @param parameter the parameter to set + */ + public void setSignParameter(SignParameter parameter) { + this.parameter = parameter; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.signator.SigningState#setBKUConnector(at.asit.pdfover.signator.BkuSlConnector) + */ + @Override + public void setBKUConnector(BkuSlConnector connector) { + this.connector = connector; + } + + /** + * @return the connector + */ + public BkuSlConnector getBKUConnector() { + return this.connector; + } +} diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/exceptions/PdfAs4SLRequestException.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/exceptions/PdfAs4SLRequestException.java new file mode 100644 index 00000000..70fe04c3 --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/exceptions/PdfAs4SLRequestException.java @@ -0,0 +1,34 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.signer.pdfas.exceptions; + +/** + * + */ +public class PdfAs4SLRequestException extends Exception { + /** + * + */ + private static final long serialVersionUID = 6855855001105199269L; + + /** + * Constructor + * @param msg + */ + public PdfAs4SLRequestException(String msg) { + super(msg); + } +} diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/resources/qualified.cer b/pdf-over-signer/pdf-over-sigpdfas4/src/main/resources/qualified.cer new file mode 100644 index 00000000..e083c81e --- /dev/null +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/resources/qualified.cer @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDJjCCAg4CCQDj2QcuXR0CJjANBgkqhkiG9w0BAQsFADBVMQswCQYDVQQGEwJB +VDEPMA0GA1UECAwGU3R5cmlhMQ0wCwYDVQQHDARHcmF6MQ0wCwYDVQQKDARFR0la +MRcwFQYDVQQDDA5NYXggTXVzdGVybWFubjAeFw0xNDExMDYwOTQyMTVaFw0yNDEx +MDMwOTQyMTVaMFUxCzAJBgNVBAYTAkFUMQ8wDQYDVQQIDAZTdHlyaWExDTALBgNV +BAcMBEdyYXoxDTALBgNVBAoMBEVHSVoxFzAVBgNVBAMMDk1heCBNdXN0ZXJtYW5u +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwKREoPZyoxmmXiULkXA/ +onwGn+J9pXX2f9AZ7ktHhoRmV3ZJgfv2rCcSO1gAwRUyJY2MFfaDMfQchooHS7e0 ++nOFKfHt5QtwkK6TYImWiFZRjoTgsDW8tTFrrR82k6LNUi5Upj3l6t7mxOdWdJBA +U0cmqALW5QQTbnbeJFVlCrTiIRBgB+G+jXBu8C64/HS5rbUUccPXxU8Mi3OnUVVd +R9AL5RothHeCIcw19rAXaU7+o/jNPeTm5mdJqG+3+mca7qBBszvOPCTnMj81fdmX +R7NWCkkT8gAlB602IBhWUUx/Az8zVglsDoL61RNXn5EA2Ajq75qUkalN5zJNytie +AQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBZuxsCprwxByxRab8S97HP1Qpb8dlM +TVdqCYMRNCik4e7l04OAJdX62H1xtL3npoT0C+pM+fkUNk9E18UTvA3jyeQXJ6f+ +z1nzdTbHVE1HANveqvUgq+LqTCTfVLk09mFmEIZnkPVd97XarmxrfCJbCaiYljka +b63ER+87QE9YiN38nZpIlocOcI9QQVpE8boRCjgyJF3i84lIbKgwM32nWs0Sz+p1 +ewWHeQw3oziie3MfH3Xkag341i/k+7VF0FxLuPn7DZB4M5pZmjy0DNA/bdhGNu96 +pOjb/TWp18KMqCMrMAGLz/cjgWqbC4KkzPUtYx6HmCdtVXHWwRV7Lgto +-----END CERTIFICATE----- diff --git a/repo/at/gv/egiz/pdfas/pdf-as-common/4.0.5-SNAPSHOT/pdf-as-common-4.0.5-SNAPSHOT.jar b/repo/at/gv/egiz/pdfas/pdf-as-common/4.0.5-SNAPSHOT/pdf-as-common-4.0.5-SNAPSHOT.jar new file mode 100644 index 00000000..4183c047 Binary files /dev/null and b/repo/at/gv/egiz/pdfas/pdf-as-common/4.0.5-SNAPSHOT/pdf-as-common-4.0.5-SNAPSHOT.jar differ diff --git a/repo/at/gv/egiz/pdfas/pdf-as-common/4.0.5-SNAPSHOT/pdf-as-common-4.0.5-SNAPSHOT.pom b/repo/at/gv/egiz/pdfas/pdf-as-common/4.0.5-SNAPSHOT/pdf-as-common-4.0.5-SNAPSHOT.pom new file mode 100644 index 00000000..84065103 --- /dev/null +++ b/repo/at/gv/egiz/pdfas/pdf-as-common/4.0.5-SNAPSHOT/pdf-as-common-4.0.5-SNAPSHOT.pom @@ -0,0 +1,46 @@ + + + 4.0.0 + at.gv.egiz.pdfas + pdf-as-common + 4.0.5-SNAPSHOT + + + junit + junit + 4.8.2 + test + + + junit + junit + 4.+ + test + + + org.slf4j + slf4j-api + 1.7.7 + compile + + + ognl + ognl + 3.0.6 + compile + + + commons-collections + commons-collections + 3.2 + compile + + + commons-io + commons-io + 2.4 + compile + + + diff --git a/repo/at/gv/egiz/pdfas/pdf-as-lib/4.0.5-SNAPSHOT/pdf-as-lib-4.0.5-SNAPSHOT.jar b/repo/at/gv/egiz/pdfas/pdf-as-lib/4.0.5-SNAPSHOT/pdf-as-lib-4.0.5-SNAPSHOT.jar new file mode 100644 index 00000000..46fb28ce Binary files /dev/null and b/repo/at/gv/egiz/pdfas/pdf-as-lib/4.0.5-SNAPSHOT/pdf-as-lib-4.0.5-SNAPSHOT.jar differ diff --git a/repo/at/gv/egiz/pdfas/pdf-as-lib/4.0.5-SNAPSHOT/pdf-as-lib-4.0.5-SNAPSHOT.pom b/repo/at/gv/egiz/pdfas/pdf-as-lib/4.0.5-SNAPSHOT/pdf-as-lib-4.0.5-SNAPSHOT.pom new file mode 100644 index 00000000..ccd5ebde --- /dev/null +++ b/repo/at/gv/egiz/pdfas/pdf-as-lib/4.0.5-SNAPSHOT/pdf-as-lib-4.0.5-SNAPSHOT.pom @@ -0,0 +1,88 @@ + + + 4.0.0 + at.gv.egiz.pdfas + pdf-as-lib + 4.0.5-SNAPSHOT + + + junit + junit + 4.8.2 + test + + + junit + junit + 4.+ + test + + + org.apache.httpcomponents + httpmime + 4.3.5 + compile + + + org.apache.httpcomponents + httpclient + 4.3.5 + compile + + + org.apache.commons + commons-lang3 + 3.3.2 + compile + + + org.slf4j + slf4j-api + 1.7.7 + compile + + + ch.qos.logback + logback-classic + 1.1.2 + compile + + + org.apache.commons + commons-collections4 + 4.0 + compile + + + ognl + ognl + 3.0.8 + compile + + + com.google.zxing + core + 3.1.0 + compile + + + at.gv.egiz.pdfas + pdf-as-common + 4.0.5-SNAPSHOT + compile + + + com.google.zxing + javase + 3.1.0 + compile + + + commons-io + commons-io + 2.4 + compile + + + diff --git a/repo/at/gv/egiz/pdfas/pdf-as-pdfbox/pdf-as-pdfbox-4.0.5-SNAPSHOT.jar b/repo/at/gv/egiz/pdfas/pdf-as-pdfbox/pdf-as-pdfbox-4.0.5-SNAPSHOT.jar new file mode 100644 index 00000000..0ffee51c Binary files /dev/null and b/repo/at/gv/egiz/pdfas/pdf-as-pdfbox/pdf-as-pdfbox-4.0.5-SNAPSHOT.jar differ diff --git a/repo/at/gv/egiz/pdfas/pdf-as-pdfbox/pdf-as-pdfbox-4.0.5-SNAPSHOT.pom b/repo/at/gv/egiz/pdfas/pdf-as-pdfbox/pdf-as-pdfbox-4.0.5-SNAPSHOT.pom new file mode 100644 index 00000000..a80c9694 --- /dev/null +++ b/repo/at/gv/egiz/pdfas/pdf-as-pdfbox/pdf-as-pdfbox-4.0.5-SNAPSHOT.pom @@ -0,0 +1,58 @@ + + + 4.0.0 + at.gv.egiz.pdfas + pdf-as-pdfbox + 4.0.5-SNAPSHOT + + + junit + junit + 4.8.2 + test + + + junit + junit + 4.+ + test + + + org.slf4j + slf4j-api + 1.7.7 + compile + + + ognl + ognl + 3.0.6 + compile + + + commons-collections + commons-collections + 3.2 + compile + + + org.apache.pdfbox + pdfbox + 1.8.7 + compile + + + commons-io + commons-io + 2.4 + compile + + + at.gv.egiz.pdfas + pdf-as-lib + 4.0.5-SNAPSHOT + compile + + + diff --git a/repo/at/gv/egiz/pdfas/sigs-pades/4.0.5-SNAPSHOT/sigs-pades-4.0.5-SNAPSHOT.jar b/repo/at/gv/egiz/pdfas/sigs-pades/4.0.5-SNAPSHOT/sigs-pades-4.0.5-SNAPSHOT.jar new file mode 100644 index 00000000..2e283200 Binary files /dev/null and b/repo/at/gv/egiz/pdfas/sigs-pades/4.0.5-SNAPSHOT/sigs-pades-4.0.5-SNAPSHOT.jar differ diff --git a/repo/at/gv/egiz/pdfas/sigs-pades/4.0.5-SNAPSHOT/sigs-pades-4.0.5-SNAPSHOT.pom b/repo/at/gv/egiz/pdfas/sigs-pades/4.0.5-SNAPSHOT/sigs-pades-4.0.5-SNAPSHOT.pom new file mode 100644 index 00000000..d63f756f --- /dev/null +++ b/repo/at/gv/egiz/pdfas/sigs-pades/4.0.5-SNAPSHOT/sigs-pades-4.0.5-SNAPSHOT.pom @@ -0,0 +1,40 @@ + + + 4.0.0 + at.gv.egiz.pdfas + sigs-pades + 4.0.5-SNAPSHOT + + + junit + junit + 4.8.2 + test + + + junit + junit + 4.+ + test + + + org.apache.commons + commons-collections4 + 4.0 + compile + + + at.gv.egiz.pdfas + pdf-as-common + 4.0.5-SNAPSHOT + compile + + + at.gv.egiz.pdfas + pdf-as-lib + 4.0.5-SNAPSHOT + compile + + + diff --git a/repo/eu/europa/ec/joinup/egovlabs/pdf-as/pdf-as-lib/3.5.2/pdf-as-lib-3.5.2.zip b/repo/eu/europa/ec/joinup/egovlabs/pdf-as/pdf-as-lib/3.5.2/pdf-as-lib-3.5.2.zip deleted file mode 100644 index 50e1cd2e..00000000 Binary files a/repo/eu/europa/ec/joinup/egovlabs/pdf-as/pdf-as-lib/3.5.2/pdf-as-lib-3.5.2.zip and /dev/null differ diff --git a/repo/iaik/iaik_cms/2.15/iaik_cms-2.15.jar b/repo/iaik/iaik_cms/2.15/iaik_cms-2.15.jar new file mode 100644 index 00000000..2696ed2b Binary files /dev/null and b/repo/iaik/iaik_cms/2.15/iaik_cms-2.15.jar differ diff --git a/repo/iaik/iaik_cms/2.15/iaik_cms-2.15.pom b/repo/iaik/iaik_cms/2.15/iaik_cms-2.15.pom new file mode 100644 index 00000000..b7913010 --- /dev/null +++ b/repo/iaik/iaik_cms/2.15/iaik_cms-2.15.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + iaik + iaik_cms + 2.15 + POM was created from install:install-file + diff --git a/repo/iaik/iaik_eccelerate/2.15/iaik_eccelerate-2.15.jar b/repo/iaik/iaik_eccelerate/2.15/iaik_eccelerate-2.15.jar new file mode 100644 index 00000000..43b1ffb7 Binary files /dev/null and b/repo/iaik/iaik_eccelerate/2.15/iaik_eccelerate-2.15.jar differ diff --git a/repo/iaik/iaik_eccelerate/2.15/iaik_eccelerate-2.15.pom b/repo/iaik/iaik_eccelerate/2.15/iaik_eccelerate-2.15.pom new file mode 100644 index 00000000..ccedb7c9 --- /dev/null +++ b/repo/iaik/iaik_eccelerate/2.15/iaik_eccelerate-2.15.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + iaik + iaik_eccelerate + 2.15 + POM was created from install:install-file + diff --git a/repo/iaik/iaik_eccelerate_cms/2.15/iaik_eccelerate_cms-2.15.jar b/repo/iaik/iaik_eccelerate_cms/2.15/iaik_eccelerate_cms-2.15.jar new file mode 100644 index 00000000..c2db15ea Binary files /dev/null and b/repo/iaik/iaik_eccelerate_cms/2.15/iaik_eccelerate_cms-2.15.jar differ diff --git a/repo/iaik/iaik_eccelerate_cms/2.15/iaik_eccelerate_cms-2.15.pom b/repo/iaik/iaik_eccelerate_cms/2.15/iaik_eccelerate_cms-2.15.pom new file mode 100644 index 00000000..31351086 --- /dev/null +++ b/repo/iaik/iaik_eccelerate_cms/2.15/iaik_eccelerate_cms-2.15.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + iaik + iaik_eccelerate_cms + 2.15 + POM was created from install:install-file + diff --git a/repo/iaik/iaik_jce_full_signed/5.2/iaik_jce_full_signed-5.2.jar b/repo/iaik/iaik_jce_full_signed/5.2/iaik_jce_full_signed-5.2.jar new file mode 100644 index 00000000..18cb0a0b Binary files /dev/null and b/repo/iaik/iaik_jce_full_signed/5.2/iaik_jce_full_signed-5.2.jar differ diff --git a/repo/iaik/iaik_jce_full_signed/5.2/iaik_jce_full_signed-5.2.pom b/repo/iaik/iaik_jce_full_signed/5.2/iaik_jce_full_signed-5.2.pom new file mode 100644 index 00000000..13a36b5c --- /dev/null +++ b/repo/iaik/iaik_jce_full_signed/5.2/iaik_jce_full_signed-5.2.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + iaik + iaik_jce_full_signed + 5.2 + POM was created from install:install-file + -- cgit v1.2.3